Commit ac7d7558 by pupi1985

PHPDoc update in db/favorites, db/post-create, qa-feed and qa-install

parent 6366d887
...@@ -106,9 +106,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -106,9 +106,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
* Add the entity $entitytype with $entityid to the favorites list of $userid. Handles switching streams across from * Add the entity $entitytype with $entityid to the favorites list of $userid. Handles switching streams across from
* per-user to per-entity based on how many other users have favorited the entity (see long explanation above). If * per-user to per-entity based on how many other users have favorited the entity (see long explanation above). If
* appropriate, it also adds recent events from that entity to the user's event stream. * appropriate, it also adds recent events from that entity to the user's event stream.
* @param $userid * @param mixed $userid
* @param $entitytype * @param string $entitytype
* @param $entityid * @param int $entityid
*/ */
function qa_db_favorite_create($userid, $entitytype, $entityid) function qa_db_favorite_create($userid, $entitytype, $entityid)
{ {
...@@ -186,9 +186,9 @@ function qa_db_favorite_create($userid, $entitytype, $entityid) ...@@ -186,9 +186,9 @@ function qa_db_favorite_create($userid, $entitytype, $entityid)
/** /**
* Delete the entity $entitytype with $entityid from the favorites list of $userid, removing any corresponding events * Delete the entity $entitytype with $entityid from the favorites list of $userid, removing any corresponding events
* from the user's stream. * from the user's stream.
* @param $userid * @param mixed $userid
* @param $entitytype * @param string $entitytype
* @param $entityid * @param int $entityid
*/ */
function qa_db_favorite_delete($userid, $entitytype, $entityid) function qa_db_favorite_delete($userid, $entitytype, $entityid)
{ {
......
...@@ -27,19 +27,19 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,19 +27,19 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Create a new post in the database and return its ID (based on auto-incrementing) * Create a new post in the database and return its ID (based on auto-incrementing)
* @param $type * @param string $type
* @param $parentid * @param int $parentid
* @param $userid * @param mixed $userid
* @param $cookieid * @param string $cookieid
* @param $ip * @param string $ip
* @param $title * @param string $title
* @param $content * @param string $content
* @param $format * @param string $format
* @param $tagstring * @param string $tagstring
* @param $notify * @param bool $notify
* @param $categoryid * @param int|null $categoryid
* @param $name * @param string|null $name
* @return mixed * @return string
*/ */
function qa_db_post_create($type, $parentid, $userid, $cookieid, $ip, $title, $content, $format, $tagstring, $notify, $categoryid = null, $name = null) function qa_db_post_create($type, $parentid, $userid, $cookieid, $ip, $title, $content, $format, $tagstring, $notify, $categoryid = null, $name = null)
{ {
...@@ -55,8 +55,8 @@ function qa_db_post_create($type, $parentid, $userid, $cookieid, $ip, $title, $c ...@@ -55,8 +55,8 @@ function qa_db_post_create($type, $parentid, $userid, $cookieid, $ip, $title, $c
/** /**
* Recalculate the full category path (i.e. columns catidpath1/2/3) for posts from $firstpostid to $lastpostid (if specified) * Recalculate the full category path (i.e. columns catidpath1/2/3) for posts from $firstpostid to $lastpostid (if specified)
* @param $firstpostid * @param int $firstpostid
* @param $lastpostid * @param int|null $lastpostid
*/ */
function qa_db_posts_calc_category_path($firstpostid, $lastpostid = null) function qa_db_posts_calc_category_path($firstpostid, $lastpostid = null)
{ {
...@@ -76,8 +76,8 @@ function qa_db_posts_calc_category_path($firstpostid, $lastpostid = null) ...@@ -76,8 +76,8 @@ function qa_db_posts_calc_category_path($firstpostid, $lastpostid = null)
/** /**
* Get the full category path (including categoryid) for $postid * Get the full category path (including categoryid) for $postid
* @param $postid * @param int $postid
* @return array|null * @return array
*/ */
function qa_db_post_get_category_path($postid) function qa_db_post_get_category_path($postid)
{ {
...@@ -90,7 +90,7 @@ function qa_db_post_get_category_path($postid) ...@@ -90,7 +90,7 @@ function qa_db_post_get_category_path($postid)
/** /**
* Update the cached number of answers for $questionid in the database, along with the highest netvotes of any of its answers * Update the cached number of answers for $questionid in the database, along with the highest netvotes of any of its answers
* @param $questionid * @param int $questionid
*/ */
function qa_db_post_acount_update($questionid) function qa_db_post_acount_update($questionid)
{ {
...@@ -105,7 +105,7 @@ function qa_db_post_acount_update($questionid) ...@@ -105,7 +105,7 @@ function qa_db_post_acount_update($questionid)
/** /**
* Recalculate the number of questions for each category in $path retrieved via qa_db_post_get_category_path() * Recalculate the number of questions for each category in $path retrieved via qa_db_post_get_category_path()
* @param $path * @param array $path
*/ */
function qa_db_category_path_qcount_update($path) function qa_db_category_path_qcount_update($path)
{ {
...@@ -118,7 +118,7 @@ function qa_db_category_path_qcount_update($path) ...@@ -118,7 +118,7 @@ function qa_db_category_path_qcount_update($path)
/** /**
* Update the cached number of questions for category $categoryid in the database, including its subcategories * Update the cached number of questions for category $categoryid in the database, including its subcategories
* @param $categoryid * @param int|null $categoryid
*/ */
function qa_db_ifcategory_qcount_update($categoryid) function qa_db_ifcategory_qcount_update($categoryid)
{ {
...@@ -136,12 +136,12 @@ function qa_db_ifcategory_qcount_update($categoryid) ...@@ -136,12 +136,12 @@ function qa_db_ifcategory_qcount_update($categoryid)
/** /**
* Add rows into the database title index, where $postid contains the words $wordids - this does the same sort * Add rows into the database title index, where $postid contains the words $wordids - this does the same sort
* of thing as qa_db_posttags_add_post_wordids() in a different way, for no particularly good reason. * of thing as qa_db_posttags_add_post_wordids() in a different way, for no particularly good reason.
* @param $postid * @param int $postid
* @param $wordids * @param array $wordids
*/ */
function qa_db_titlewords_add_post_wordids($postid, $wordids) function qa_db_titlewords_add_post_wordids($postid, $wordids)
{ {
if (count($wordids)) { if (!empty($wordids)) {
$rowstoadd = array(); $rowstoadd = array();
foreach ($wordids as $wordid) foreach ($wordids as $wordid)
$rowstoadd[] = array($postid, $wordid); $rowstoadd[] = array($postid, $wordid);
...@@ -157,14 +157,14 @@ function qa_db_titlewords_add_post_wordids($postid, $wordids) ...@@ -157,14 +157,14 @@ function qa_db_titlewords_add_post_wordids($postid, $wordids)
/** /**
* Add rows into the database content index, where $postid (of $type, with the antecedent $questionid) * Add rows into the database content index, where $postid (of $type, with the antecedent $questionid)
* has words as per the keys of $wordidcounts, and the corresponding number of those words in the values. * has words as per the keys of $wordidcounts, and the corresponding number of those words in the values.
* @param $postid * @param int $postid
* @param $type * @param string $type
* @param $questionid * @param int $questionid
* @param $wordidcounts * @param array $wordidcounts
*/ */
function qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $wordidcounts) function qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $wordidcounts)
{ {
if (count($wordidcounts)) { if (!empty($wordidcounts)) {
$rowstoadd = array(); $rowstoadd = array();
foreach ($wordidcounts as $wordid => $count) foreach ($wordidcounts as $wordid => $count)
$rowstoadd[] = array($postid, $wordid, $count, $type, $questionid); $rowstoadd[] = array($postid, $wordid, $count, $type, $questionid);
...@@ -179,12 +179,12 @@ function qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $ ...@@ -179,12 +179,12 @@ function qa_db_contentwords_add_post_wordidcounts($postid, $type, $questionid, $
/** /**
* Add rows into the database index of individual tag words, where $postid contains the words $wordids * Add rows into the database index of individual tag words, where $postid contains the words $wordids
* @param $postid * @param int $postid
* @param $wordids * @param array $wordids
*/ */
function qa_db_tagwords_add_post_wordids($postid, $wordids) function qa_db_tagwords_add_post_wordids($postid, $wordids)
{ {
if (count($wordids)) { if (!empty($wordids)) {
$rowstoadd = array(); $rowstoadd = array();
foreach ($wordids as $wordid) foreach ($wordids as $wordid)
$rowstoadd[] = array($postid, $wordid); $rowstoadd[] = array($postid, $wordid);
...@@ -199,12 +199,12 @@ function qa_db_tagwords_add_post_wordids($postid, $wordids) ...@@ -199,12 +199,12 @@ function qa_db_tagwords_add_post_wordids($postid, $wordids)
/** /**
* Add rows into the database index of whole tags, where $postid contains the tags $wordids * Add rows into the database index of whole tags, where $postid contains the tags $wordids
* @param $postid * @param int $postid
* @param $wordids * @param array $wordids
*/ */
function qa_db_posttags_add_post_wordids($postid, $wordids) function qa_db_posttags_add_post_wordids($postid, $wordids)
{ {
if (count($wordids)) { if (!empty($wordids)) {
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^posttags (postid, wordid, postcreated) SELECT postid, wordid, created FROM ^words, ^posts WHERE postid=# AND wordid IN ($)', 'INSERT INTO ^posttags (postid, wordid, postcreated) SELECT postid, wordid, created FROM ^words, ^posts WHERE postid=# AND wordid IN ($)',
$postid, $wordids $postid, $wordids
...@@ -215,12 +215,12 @@ function qa_db_posttags_add_post_wordids($postid, $wordids) ...@@ -215,12 +215,12 @@ function qa_db_posttags_add_post_wordids($postid, $wordids)
/** /**
* Return an array mapping each word in $words to its corresponding wordid in the database * Return an array mapping each word in $words to its corresponding wordid in the database
* @param $words * @param array $words
* @return array * @return array
*/ */
function qa_db_word_mapto_ids($words) function qa_db_word_mapto_ids($words)
{ {
if (count($words)) { if (!empty($words)) {
return qa_db_read_all_assoc(qa_db_query_sub( return qa_db_read_all_assoc(qa_db_query_sub(
'SELECT wordid, word FROM ^words WHERE word IN ($)', $words 'SELECT wordid, word FROM ^words WHERE word IN ($)', $words
), 'word', 'wordid'); ), 'word', 'wordid');
...@@ -232,7 +232,7 @@ function qa_db_word_mapto_ids($words) ...@@ -232,7 +232,7 @@ function qa_db_word_mapto_ids($words)
/** /**
* Return an array mapping each word in $words to its corresponding wordid in the database, adding any that are missing * Return an array mapping each word in $words to its corresponding wordid in the database, adding any that are missing
* @param $words * @param array $words
* @return array * @return array
*/ */
function qa_db_word_mapto_ids_add($words) function qa_db_word_mapto_ids_add($words)
...@@ -245,7 +245,7 @@ function qa_db_word_mapto_ids_add($words) ...@@ -245,7 +245,7 @@ function qa_db_word_mapto_ids_add($words)
$wordstoadd[] = $word; $wordstoadd[] = $word;
} }
if (count($wordstoadd)) { if (!empty($wordstoadd)) {
qa_db_query_sub('LOCK TABLES ^words WRITE'); // to prevent two requests adding the same word qa_db_query_sub('LOCK TABLES ^words WRITE'); // to prevent two requests adding the same word
$wordtoid = qa_db_word_mapto_ids($words); // map it again in case table content changed before it was locked $wordtoid = qa_db_word_mapto_ids($words); // map it again in case table content changed before it was locked
...@@ -269,7 +269,7 @@ function qa_db_word_mapto_ids_add($words) ...@@ -269,7 +269,7 @@ function qa_db_word_mapto_ids_add($words)
/** /**
* Update the titlecount column in the database for the words in $wordids, based on how many posts they appear in the title of * Update the titlecount column in the database for the words in $wordids, based on how many posts they appear in the title of
* @param $wordids * @param array $wordids
*/ */
function qa_db_word_titlecount_update($wordids) function qa_db_word_titlecount_update($wordids)
{ {
...@@ -284,7 +284,7 @@ function qa_db_word_titlecount_update($wordids) ...@@ -284,7 +284,7 @@ function qa_db_word_titlecount_update($wordids)
/** /**
* Update the contentcount column in the database for the words in $wordids, based on how many posts they appear in the content of * Update the contentcount column in the database for the words in $wordids, based on how many posts they appear in the content of
* @param $wordids * @param array $wordids
*/ */
function qa_db_word_contentcount_update($wordids) function qa_db_word_contentcount_update($wordids)
{ {
...@@ -299,7 +299,7 @@ function qa_db_word_contentcount_update($wordids) ...@@ -299,7 +299,7 @@ function qa_db_word_contentcount_update($wordids)
/** /**
* Update the tagwordcount column in the database for the individual tag words in $wordids, based on how many posts they appear in the tags of * Update the tagwordcount column in the database for the individual tag words in $wordids, based on how many posts they appear in the tags of
* @param $wordids * @param array $wordids
*/ */
function qa_db_word_tagwordcount_update($wordids) function qa_db_word_tagwordcount_update($wordids)
{ {
...@@ -314,7 +314,7 @@ function qa_db_word_tagwordcount_update($wordids) ...@@ -314,7 +314,7 @@ function qa_db_word_tagwordcount_update($wordids)
/** /**
* Update the tagcount column in the database for the whole tags in $wordids, based on how many posts they appear as tags of * Update the tagcount column in the database for the whole tags in $wordids, based on how many posts they appear as tags of
* @param $wordids * @param array $wordids
*/ */
function qa_db_word_tagcount_update($wordids) function qa_db_word_tagcount_update($wordids)
{ {
......
...@@ -35,7 +35,7 @@ require_once QA_INCLUDE_DIR . 'app/options.php'; ...@@ -35,7 +35,7 @@ require_once QA_INCLUDE_DIR . 'app/options.php';
/** /**
* Database failure handler function for RSS feeds - outputs HTTP and text errors * Database failure handler function for RSS feeds - outputs HTTP and text errors
* @param $type * @param string $type
* @param int $errno * @param int $errno
* @param string $error * @param string $error
* @param string $query * @param string $query
...@@ -62,8 +62,8 @@ function qa_feed_not_found() ...@@ -62,8 +62,8 @@ function qa_feed_not_found()
/** /**
* Common function to load appropriate set of questions for requested feed, check category exists, and set up page title * Common function to load appropriate set of questions for requested feed, check category exists, and set up page title
* @param array $categoryslugs * @param array $categoryslugs
* @param string $allkey * @param string|null $allkey
* @param string $catkey * @param string|null $catkey
* @param string $title * @param string $title
* @param array $questionselectspec1 * @param array $questionselectspec1
* @param array $questionselectspec2 * @param array $questionselectspec2
......
...@@ -34,7 +34,7 @@ qa_report_process_stage('init_install'); ...@@ -34,7 +34,7 @@ qa_report_process_stage('init_install');
if (!function_exists('qa_install_db_fail_handler')) { if (!function_exists('qa_install_db_fail_handler')) {
/** /**
* Handler function for database failures during the installation process * Handler function for database failures during the installation process
* @param $type * @param string $type
* @param int $errno * @param int $errno
* @param string $error * @param string $error
* @param string $query * @param string $query
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment