Unverified Commit 7763be86 by Scott Committed by GitHub

Merge pull request #734 from pupi1985/patch-122

Add data types to PHPDocs
parents 5669d75e 6ca33b27
...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Return the URL which will output $blobid from the database when requested, $absolute or relative * Return the URL which will output $blobid from the database when requested, $absolute or relative
* @param $blobid * @param string $blobid
* @param bool $absolute * @param bool $absolute
* @return mixed|string * @return string
*/ */
function qa_get_blob_url($blobid, $absolute = false) function qa_get_blob_url($blobid, $absolute = false)
{ {
...@@ -41,8 +41,8 @@ function qa_get_blob_url($blobid, $absolute = false) ...@@ -41,8 +41,8 @@ function qa_get_blob_url($blobid, $absolute = false)
/** /**
* Return the full path to the on-disk directory for blob $blobid (subdirectories are named by the first 3 digits of $blobid) * Return the full path to the on-disk directory for blob $blobid (subdirectories are named by the first 3 digits of $blobid)
* @param $blobid * @param string $blobid
* @return mixed|string * @return string
*/ */
function qa_get_blob_directory($blobid) function qa_get_blob_directory($blobid)
{ {
...@@ -54,9 +54,9 @@ function qa_get_blob_directory($blobid) ...@@ -54,9 +54,9 @@ function qa_get_blob_directory($blobid)
/** /**
* Return the full page and filename of blob $blobid which is in $format ($format is used as the file name suffix e.g. .jpg) * Return the full page and filename of blob $blobid which is in $format ($format is used as the file name suffix e.g. .jpg)
* @param $blobid * @param string $blobid
* @param $format * @param string $format
* @return mixed|string * @return string
*/ */
function qa_get_blob_filename($blobid, $format) function qa_get_blob_filename($blobid, $format)
{ {
...@@ -69,13 +69,13 @@ function qa_get_blob_filename($blobid, $format) ...@@ -69,13 +69,13 @@ function qa_get_blob_filename($blobid, $format)
/** /**
* Create a new blob (storing the content in the database or on disk as appropriate) with $content and $format, returning its blobid. * Create a new blob (storing the content in the database or on disk as appropriate) with $content and $format, returning its blobid.
* Pass the original name of the file uploaded in $sourcefilename and the $userid, $cookieid and $ip of the user creating it * Pass the original name of the file uploaded in $sourcefilename and the $userid, $cookieid and $ip of the user creating it
* @param $content * @param string $content
* @param $format * @param string $format
* @param $sourcefilename * @param string|null $sourcefilename
* @param $userid * @param mixed|null $userid
* @param $cookieid * @param string|null $cookieid
* @param $ip * @param string $ip
* @return mixed|null|string * @return string
*/ */
function qa_create_blob($content, $format, $sourcefilename = null, $userid = null, $cookieid = null, $ip = null) function qa_create_blob($content, $format, $sourcefilename = null, $userid = null, $cookieid = null, $ip = null)
{ {
...@@ -97,10 +97,10 @@ function qa_create_blob($content, $format, $sourcefilename = null, $userid = nul ...@@ -97,10 +97,10 @@ function qa_create_blob($content, $format, $sourcefilename = null, $userid = nul
/** /**
* Write the on-disk file for blob $blobid with $content and $format. Returns true if the write succeeded, false otherwise. * Write the on-disk file for blob $blobid with $content and $format. Returns true if the write succeeded, false otherwise.
* @param $blobid * @param string $blobid
* @param $content * @param string $content
* @param $format * @param string $format
* @return bool|mixed * @return bool
*/ */
function qa_write_blob_file($blobid, $content, $format) function qa_write_blob_file($blobid, $content, $format)
{ {
...@@ -130,8 +130,8 @@ function qa_write_blob_file($blobid, $content, $format) ...@@ -130,8 +130,8 @@ function qa_write_blob_file($blobid, $content, $format)
/** /**
* Retrieve blob $blobid from the database, reading the content from disk if appropriate * Retrieve blob $blobid from the database, reading the content from disk if appropriate
* @param $blobid * @param string $blobid
* @return array|mixed|null * @return array
*/ */
function qa_read_blob($blobid) function qa_read_blob($blobid)
{ {
...@@ -150,9 +150,9 @@ function qa_read_blob($blobid) ...@@ -150,9 +150,9 @@ function qa_read_blob($blobid)
/** /**
* Read the content of blob $blobid in $format from disk. On failure, it will return false. * Read the content of blob $blobid in $format from disk. On failure, it will return false.
* @param $blobid * @param string $blobid
* @param $format * @param string $format
* @return mixed|null|string * @return false|string|null
*/ */
function qa_read_blob_file($blobid, $format) function qa_read_blob_file($blobid, $format)
{ {
...@@ -168,7 +168,7 @@ function qa_read_blob_file($blobid, $format) ...@@ -168,7 +168,7 @@ function qa_read_blob_file($blobid, $format)
/** /**
* Delete blob $blobid from the database, and remove the on-disk file if appropriate * Delete blob $blobid from the database, and remove the on-disk file if appropriate
* @param $blobid * @param string $blobid
* @return mixed * @return mixed
*/ */
function qa_delete_blob($blobid) function qa_delete_blob($blobid)
...@@ -190,8 +190,8 @@ function qa_delete_blob($blobid) ...@@ -190,8 +190,8 @@ function qa_delete_blob($blobid)
/** /**
* Delete the on-disk file for blob $blobid in $format * Delete the on-disk file for blob $blobid in $format
* @param $blobid * @param string $blobid
* @param $format * @param string $format
* @return mixed * @return mixed
*/ */
function qa_delete_blob_file($blobid, $format) function qa_delete_blob_file($blobid, $format)
...@@ -204,8 +204,8 @@ function qa_delete_blob_file($blobid, $format) ...@@ -204,8 +204,8 @@ function qa_delete_blob_file($blobid, $format)
/** /**
* Check if blob $blobid exists * Check if blob $blobid exists
* @param $blobid * @param string $blobid
* @return bool|mixed * @return bool
*/ */
function qa_blob_exists($blobid) function qa_blob_exists($blobid)
{ {
......
...@@ -38,8 +38,8 @@ function qa_captcha_available() ...@@ -38,8 +38,8 @@ function qa_captcha_available()
/** /**
* Return an HTML string explaining $captchareason (from qa_user_captcha_reason()) to the user about why they are seeing a captcha * Return an HTML string explaining $captchareason (from qa_user_captcha_reason()) to the user about why they are seeing a captcha
* @param $captchareason * @param string $captchareason
* @return mixed|null|string * @return string|null
*/ */
function qa_captcha_reason_note($captchareason) function qa_captcha_reason_note($captchareason)
{ {
...@@ -66,10 +66,10 @@ function qa_captcha_reason_note($captchareason) ...@@ -66,10 +66,10 @@ function qa_captcha_reason_note($captchareason)
/** /**
* Prepare $qa_content for showing a captcha, adding the element to $fields, given previous $errors, and a $note to display. * Prepare $qa_content for showing a captcha, adding the element to $fields, given previous $errors, and a $note to display.
* Returns JavaScript required to load CAPTCHA when field is shown by user (e.g. clicking comment button). * Returns JavaScript required to load CAPTCHA when field is shown by user (e.g. clicking comment button).
* @param $qa_content * @param array $qa_content
* @param $fields * @param array $fields
* @param $errors * @param array $errors
* @param $note * @param string $note
* @return string * @return string
*/ */
function qa_set_up_captcha_field(&$qa_content, &$fields, $errors, $note = null) function qa_set_up_captcha_field(&$qa_content, &$fields, $errors, $note = null)
...@@ -105,7 +105,7 @@ function qa_set_up_captcha_field(&$qa_content, &$fields, $errors, $note = null) ...@@ -105,7 +105,7 @@ function qa_set_up_captcha_field(&$qa_content, &$fields, $errors, $note = null)
/** /**
* Check if captcha is submitted correctly, and if not, set $errors['captcha'] to a descriptive string. * Check if captcha is submitted correctly, and if not, set $errors['captcha'] to a descriptive string.
* @param $errors * @param array $errors
* @return bool * @return bool
*/ */
function qa_captcha_validate_post(&$errors) function qa_captcha_validate_post(&$errors)
......
...@@ -27,6 +27,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,6 +27,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Return the user identification cookie sent by the browser for this page request, or null if none * Return the user identification cookie sent by the browser for this page request, or null if none
* @return string|null
*/ */
function qa_cookie_get() function qa_cookie_get()
{ {
...@@ -39,6 +40,7 @@ function qa_cookie_get() ...@@ -39,6 +40,7 @@ function qa_cookie_get()
/** /**
* Return user identification cookie sent by browser if valid, or create a new one if not. * Return user identification cookie sent by browser if valid, or create a new one if not.
* Either way, extend for another year (this is used when an anonymous post is created) * Either way, extend for another year (this is used when an anonymous post is created)
* @return string
*/ */
function qa_cookie_get_create() function qa_cookie_get_create()
{ {
...@@ -63,8 +65,8 @@ function qa_cookie_get_create() ...@@ -63,8 +65,8 @@ function qa_cookie_get_create()
/** /**
* Called after a database write $action performed by a user identified by $cookieid, * Called after a database write $action performed by a user identified by $cookieid,
* relating to $questionid, $answerid and/or $commentid * relating to $questionid, $answerid and/or $commentid
* @param $cookieid * @param string $cookieid
* @param $action * @param string $action
*/ */
function qa_cookie_report_action($cookieid, $action) function qa_cookie_report_action($cookieid, $action)
{ {
......
...@@ -24,6 +24,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -24,6 +24,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
exit; exit;
} }
use Q2A\Exceptions\FatalErrorException;
use Q2A\Notifications\Email; use Q2A\Notifications\Email;
use Q2A\Notifications\Mailer; use Q2A\Notifications\Mailer;
use Q2A\Notifications\Status as NotifyStatus; use Q2A\Notifications\Status as NotifyStatus;
...@@ -44,21 +45,22 @@ function qa_suspend_notifications($suspend = true) ...@@ -44,21 +45,22 @@ function qa_suspend_notifications($suspend = true)
* Send email to person with $userid and/or $email and/or $handle (null/invalid values are ignored or retrieved from * Send email to person with $userid and/or $email and/or $handle (null/invalid values are ignored or retrieved from
* user database as appropriate). Email uses $subject and $body, after substituting each key in $subs with its * user database as appropriate). Email uses $subject and $body, after substituting each key in $subs with its
* corresponding value, plus applying some standard substitutions such as ^site_title, ^site_url, ^handle and ^email. * corresponding value, plus applying some standard substitutions such as ^site_title, ^site_url, ^handle and ^email.
* @param $userid * If notifications are suspended, then a null value is returned.
* @param $email * @param mixed $userid
* @param $handle * @param string $email
* @param $subject * @param string $handle
* @param $body * @param string $subject
* @param $subs * @param string $body
* @param bool $html * @param array $subs
* @return bool * @param bool|false $html
* @return bool|null
*/ */
function qa_send_notification($userid, $email, $handle, $subject, $body, $subs, $html = false) function qa_send_notification($userid, $email, $handle, $subject, $body, $subs, $html = false)
{ {
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); } if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
if (NotifyStatus::isSuspended()) { if (NotifyStatus::isSuspended()) {
return; return null;
} }
if ($userid) { if ($userid) {
...@@ -74,8 +76,9 @@ function qa_send_notification($userid, $email, $handle, $subject, $body, $subs, ...@@ -74,8 +76,9 @@ function qa_send_notification($userid, $email, $handle, $subject, $body, $subs,
/** /**
* Send the email based on the $params array - the following keys are required (some can be empty): fromemail, * Send the email based on the $params array - the following keys are required (some can be empty): fromemail,
* fromname, toemail, toname, subject, body, html * fromname, toemail, toname, subject, body, html
* @param $params * @param array $params
* @return bool * @return bool
* @throws phpmailerException
*/ */
function qa_send_email($params) function qa_send_email($params)
{ {
......
...@@ -33,12 +33,12 @@ require_once QA_INCLUDE_DIR . 'app/updates.php'; ...@@ -33,12 +33,12 @@ require_once QA_INCLUDE_DIR . 'app/updates.php';
* to $lastpostid whose antecedent question is $questionid, and was caused by $lastuserid. Pass a unix $timestamp for * to $lastpostid whose antecedent question is $questionid, and was caused by $lastuserid. Pass a unix $timestamp for
* the event time or leave as null to use now. This will add an event to $questionid's and $lastuserid's streams. If * the event time or leave as null to use now. This will add an event to $questionid's and $lastuserid's streams. If
* $otheruserid is set, it will also add an notification-style event for that user, unless they are the one who did it. * $otheruserid is set, it will also add an notification-style event for that user, unless they are the one who did it.
* @param $questionid * @param int $questionid
* @param $lastpostid * @param int $lastpostid
* @param $updatetype * @param string $updatetype
* @param $lastuserid * @param mixed $lastuserid
* @param $otheruserid * @param mixed|null $otheruserid
* @param $timestamp * @param int|null $timestamp
*/ */
function qa_create_event_for_q_user($questionid, $lastpostid, $updatetype, $lastuserid, $otheruserid = null, $timestamp = null) function qa_create_event_for_q_user($questionid, $lastpostid, $updatetype, $lastuserid, $otheruserid = null, $timestamp = null)
{ {
...@@ -57,11 +57,11 @@ function qa_create_event_for_q_user($questionid, $lastpostid, $updatetype, $last ...@@ -57,11 +57,11 @@ function qa_create_event_for_q_user($questionid, $lastpostid, $updatetype, $last
* being created with those tags or having one of those tags added afterwards). The event of type $updatetype relates * being created with those tags or having one of those tags added afterwards). The event of type $updatetype relates
* to the question $questionid, and was caused by $lastuserid. Pass a unix $timestamp for the event time or leave as * to the question $questionid, and was caused by $lastuserid. Pass a unix $timestamp for the event time or leave as
* null to use now. * null to use now.
* @param $tagstring * @param string $tagstring
* @param $questionid * @param int $questionid
* @param $updatetype * @param string $updatetype
* @param $lastuserid * @param mixed $lastuserid
* @param $timestamp * @param int $timestamp
*/ */
function qa_create_event_for_tags($tagstring, $questionid, $updatetype, $lastuserid, $timestamp = null) function qa_create_event_for_tags($tagstring, $questionid, $updatetype, $lastuserid, $timestamp = null)
{ {
...@@ -80,11 +80,11 @@ function qa_create_event_for_tags($tagstring, $questionid, $updatetype, $lastuse ...@@ -80,11 +80,11 @@ function qa_create_event_for_tags($tagstring, $questionid, $updatetype, $lastuse
* that category or being moved to it later on), along with all of its ancestor categories. The event of type * that category or being moved to it later on), along with all of its ancestor categories. The event of type
* $updatetype relates to the question $questionid, and was caused by $lastuserid. Pass a unix $timestamp for the event * $updatetype relates to the question $questionid, and was caused by $lastuserid. Pass a unix $timestamp for the event
* time or leave as null to use now. * time or leave as null to use now.
* @param $categoryid * @param int|null $categoryid
* @param $questionid * @param int $questionid
* @param $updatetype * @param string $updatetype
* @param $lastuserid * @param mixed $lastuserid
* @param $timestamp * @param int|null $timestamp
*/ */
function qa_create_event_for_category($categoryid, $questionid, $updatetype, $lastuserid, $timestamp = null) function qa_create_event_for_category($categoryid, $questionid, $updatetype, $lastuserid, $timestamp = null)
{ {
......
...@@ -84,8 +84,8 @@ function qa_user_favorite_set($userid, $handle, $cookieid, $entitytype, $entityi ...@@ -84,8 +84,8 @@ function qa_user_favorite_set($userid, $handle, $cookieid, $entitytype, $entityi
/** /**
* Returns content to set in $qa_content['q_list'] for a user's favorite $questions. Pre-generated * Returns content to set in $qa_content['q_list'] for a user's favorite $questions. Pre-generated
* user HTML in $usershtml. * user HTML in $usershtml.
* @param $questions * @param array $questions
* @param $usershtml * @param array $usershtml
* @return array * @return array
*/ */
function qa_favorite_q_list_view($questions, $usershtml) function qa_favorite_q_list_view($questions, $usershtml)
...@@ -118,8 +118,8 @@ function qa_favorite_q_list_view($questions, $usershtml) ...@@ -118,8 +118,8 @@ function qa_favorite_q_list_view($questions, $usershtml)
/** /**
* Returns content to set in $qa_content['ranking_users'] for a user's favorite $users. Pre-generated * Returns content to set in $qa_content['ranking_users'] for a user's favorite $users. Pre-generated
* user HTML in $usershtml. * user HTML in $usershtml.
* @param $users * @param array $users
* @param $usershtml * @param array $usershtml
* @return array|null * @return array|null
*/ */
function qa_favorite_users_view($users, $usershtml) function qa_favorite_users_view($users, $usershtml)
...@@ -154,7 +154,7 @@ function qa_favorite_users_view($users, $usershtml) ...@@ -154,7 +154,7 @@ function qa_favorite_users_view($users, $usershtml)
/** /**
* Returns content to set in $qa_content['ranking_tags'] for a user's favorite $tags. * Returns content to set in $qa_content['ranking_tags'] for a user's favorite $tags.
* @param $tags * @param array $tags
* @return array * @return array
*/ */
function qa_favorite_tags_view($tags) function qa_favorite_tags_view($tags)
...@@ -181,7 +181,7 @@ function qa_favorite_tags_view($tags) ...@@ -181,7 +181,7 @@ function qa_favorite_tags_view($tags)
/** /**
* Returns content to set in $qa_content['nav_list_categories'] for a user's favorite $categories. * Returns content to set in $qa_content['nav_list_categories'] for a user's favorite $categories.
* @param $categories * @param array $categories
* @return array * @return array
*/ */
function qa_favorite_categories_view($categories) function qa_favorite_categories_view($categories)
......
...@@ -30,8 +30,8 @@ define('QA_PAGE_FLAGS_NEW_WINDOW', 2); ...@@ -30,8 +30,8 @@ define('QA_PAGE_FLAGS_NEW_WINDOW', 2);
/** /**
* Return textual representation of $seconds * Return textual representation of $seconds
* @param $seconds * @param int $seconds
* @return mixed|string * @return string
*/ */
function qa_time_to_string($seconds) function qa_time_to_string($seconds)
{ {
...@@ -69,9 +69,9 @@ function qa_time_to_string($seconds) ...@@ -69,9 +69,9 @@ function qa_time_to_string($seconds)
/** /**
* Check if $post is by user $userid, or if post is anonymous and $userid not specified, then * Check if $post is by user $userid, or if post is anonymous and $userid not specified, then
* check if $post is by the anonymous user identified by $cookieid * check if $post is by the anonymous user identified by $cookieid
* @param $post * @param array $post
* @param $userid * @param mixed $userid
* @param $cookieid * @param string $cookieid
* @return bool * @return bool
*/ */
function qa_post_is_by_user($post, $userid, $cookieid) function qa_post_is_by_user($post, $userid, $cookieid)
...@@ -92,7 +92,6 @@ function qa_post_is_by_user($post, $userid, $cookieid) ...@@ -92,7 +92,6 @@ function qa_post_is_by_user($post, $userid, $cookieid)
/** /**
* Return array which maps the 'userid' and/or 'lastuserid' of each user to its HTML representation. * Return array which maps the 'userid' and/or 'lastuserid' of each user to its HTML representation.
* For internal user management, corresponding 'handle' and/or 'lasthandle' are required in each element. * For internal user management, corresponding 'handle' and/or 'lasthandle' are required in each element.
*
* @param array $useridhandles User IDs or usernames. * @param array $useridhandles User IDs or usernames.
* @param bool $microdata Whether to include microdata. * @param bool $microdata Whether to include microdata.
* @return array The HTML. * @return array The HTML.
...@@ -143,6 +142,7 @@ function qa_userids_handles_html($useridhandles, $microdata = false) ...@@ -143,6 +142,7 @@ function qa_userids_handles_html($useridhandles, $microdata = false)
* users tend to favorite many more questions than other things.) The top-level array can contain three keys - 'user' for favorited * users tend to favorite many more questions than other things.) The top-level array can contain three keys - 'user' for favorited
* users, 'tag' for tags, 'category' for categories. The next level down has the identifier for each favorited entity in the *key* * users, 'tag' for tags, 'category' for categories. The next level down has the identifier for each favorited entity in the *key*
* of the array, and true for its value. If no user is logged in the empty array is returned. The result is cached for future calls. * of the array, and true for its value. If no user is logged in the empty array is returned. The result is cached for future calls.
* @return array
*/ */
function qa_get_favorite_non_qs_map() function qa_get_favorite_non_qs_map()
{ {
...@@ -182,7 +182,6 @@ function qa_get_favorite_non_qs_map() ...@@ -182,7 +182,6 @@ function qa_get_favorite_non_qs_map()
/** /**
* Convert textual tag to HTML representation, linked to its tag page. * Convert textual tag to HTML representation, linked to its tag page.
*
* @param string $tag The tag. * @param string $tag The tag.
* @param bool $microdata Whether to include microdata. * @param bool $microdata Whether to include microdata.
* @param bool $favorited Show the tag as favorited. * @param bool $favorited Show the tag as favorited.
...@@ -203,8 +202,8 @@ function qa_tag_html($tag, $microdata = false, $favorited = false) ...@@ -203,8 +202,8 @@ function qa_tag_html($tag, $microdata = false, $favorited = false)
/** /**
* Given $navcategories retrieved for $categoryid from the database (using qa_db_category_nav_selectspec(...)), * Given $navcategories retrieved for $categoryid from the database (using qa_db_category_nav_selectspec(...)),
* return an array of elements from $navcategories for the hierarchy down to $categoryid. * return an array of elements from $navcategories for the hierarchy down to $categoryid.
* @param $navcategories * @param array $navcategories
* @param $categoryid * @param int $categoryid
* @return array * @return array
*/ */
function qa_category_path($navcategories, $categoryid) function qa_category_path($navcategories, $categoryid)
...@@ -221,8 +220,8 @@ function qa_category_path($navcategories, $categoryid) ...@@ -221,8 +220,8 @@ function qa_category_path($navcategories, $categoryid)
/** /**
* Given $navcategories retrieved for $categoryid from the database (using qa_db_category_nav_selectspec(...)), * Given $navcategories retrieved for $categoryid from the database (using qa_db_category_nav_selectspec(...)),
* return some HTML that shows the category hierarchy down to $categoryid. * return some HTML that shows the category hierarchy down to $categoryid.
* @param $navcategories * @param array $navcategories
* @param $categoryid * @param int $categoryid
* @return string * @return string
*/ */
function qa_category_path_html($navcategories, $categoryid) function qa_category_path_html($navcategories, $categoryid)
...@@ -240,8 +239,8 @@ function qa_category_path_html($navcategories, $categoryid) ...@@ -240,8 +239,8 @@ function qa_category_path_html($navcategories, $categoryid)
/** /**
* Given $navcategories retrieved for $categoryid from the database (using qa_db_category_nav_selectspec(...)), * Given $navcategories retrieved for $categoryid from the database (using qa_db_category_nav_selectspec(...)),
* return a Q2A request string that represents the category hierarchy down to $categoryid. * return a Q2A request string that represents the category hierarchy down to $categoryid.
* @param $navcategories * @param array $navcategories
* @param $categoryid * @param int $categoryid
* @return string * @return string
*/ */
function qa_category_path_request($navcategories, $categoryid) function qa_category_path_request($navcategories, $categoryid)
...@@ -258,8 +257,8 @@ function qa_category_path_request($navcategories, $categoryid) ...@@ -258,8 +257,8 @@ function qa_category_path_request($navcategories, $categoryid)
/** /**
* Return HTML to use for $ip address, which links to appropriate page with $anchorhtml * Return HTML to use for $ip address, which links to appropriate page with $anchorhtml
* @param $ip * @param string $ip
* @param null $anchorhtml * @param string|null $anchorhtml
* @return mixed|string * @return mixed|string
*/ */
function qa_ip_anchor_html($ip, $anchorhtml = null) function qa_ip_anchor_html($ip, $anchorhtml = null)
...@@ -280,11 +279,11 @@ function qa_ip_anchor_html($ip, $anchorhtml = null) ...@@ -280,11 +279,11 @@ function qa_ip_anchor_html($ip, $anchorhtml = null)
* $dummy is a placeholder (used to be $categories parameter but that's no longer needed) * $dummy is a placeholder (used to be $categories parameter but that's no longer needed)
* $options is an array which sets what is displayed (see qa_post_html_defaults() in /qa-include/app/options.php) * $options is an array which sets what is displayed (see qa_post_html_defaults() in /qa-include/app/options.php)
* If something is missing from $post (e.g. ['content']), correponding HTML also omitted. * If something is missing from $post (e.g. ['content']), correponding HTML also omitted.
* @param $post * @param array $post
* @param $userid * @param mixed $userid
* @param $cookieid * @param string $cookieid
* @param $usershtml * @param array $usershtml
* @param $dummy * @param null $dummy
* @param array $options * @param array $options
* @return array * @return array
*/ */
...@@ -683,7 +682,6 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt ...@@ -683,7 +682,6 @@ function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $opt
/** /**
* Generate array of mostly HTML representing a message, to be passed to theme layer. * Generate array of mostly HTML representing a message, to be passed to theme layer.
*
* @param array $message The message object (as retrieved from database). * @param array $message The message object (as retrieved from database).
* @param array $options Viewing options (see qa_message_html_defaults() in /qa-include/app/options.php). * @param array $options Viewing options (see qa_message_html_defaults() in /qa-include/app/options.php).
* @return array The HTML. * @return array The HTML.
...@@ -738,9 +736,8 @@ function qa_message_html_fields($message, $options = array()) ...@@ -738,9 +736,8 @@ function qa_message_html_fields($message, $options = array())
/** /**
* Generate array of split HTML (prefix, data, suffix) to represent author of post. * Generate array of split HTML (prefix, data, suffix) to represent author of post.
*
* @param bool $isbyuser True if the current user made the post. * @param bool $isbyuser True if the current user made the post.
* @param int $postuserid The post user's ID. * @param int|null $postuserid The post user's ID.
* @param array $usershtml Array of HTML representing usernames. * @param array $usershtml Array of HTML representing usernames.
* @param string $ip The post user's IP. * @param string $ip The post user's IP.
* @param bool|string $microdata Whether to include microdata. * @param bool|string $microdata Whether to include microdata.
...@@ -776,9 +773,8 @@ function qa_who_to_html($isbyuser, $postuserid, $usershtml, $ip = null, $microda ...@@ -776,9 +773,8 @@ function qa_who_to_html($isbyuser, $postuserid, $usershtml, $ip = null, $microda
/** /**
* Generate array of split HTML (prefix, data, suffix) to represent a timestamp, optionally with the full date. * Generate array of split HTML (prefix, data, suffix) to represent a timestamp, optionally with the full date.
*
* @param int $timestamp Unix timestamp. * @param int $timestamp Unix timestamp.
* @param int $fulldatedays Number of days after which to show the full date. * @param int|null $fulldatedays Number of days after which to show the full date.
* @return array The HTML. * @return array The HTML.
*/ */
function qa_when_to_html($timestamp, $fulldatedays) function qa_when_to_html($timestamp, $fulldatedays)
...@@ -815,12 +811,12 @@ function qa_when_to_html($timestamp, $fulldatedays) ...@@ -815,12 +811,12 @@ function qa_when_to_html($timestamp, $fulldatedays)
* $question, as retrieved from database, with fields prefixed 'o' for the answer, comment or edit. * $question, as retrieved from database, with fields prefixed 'o' for the answer, comment or edit.
* $userid, $cookieid, $usershtml, $options are passed through to qa_post_html_fields(). If $question['opersonal'] * $userid, $cookieid, $usershtml, $options are passed through to qa_post_html_fields(). If $question['opersonal']
* is set and true then the item is displayed with its personal relevance to the user (for user updates page). * is set and true then the item is displayed with its personal relevance to the user (for user updates page).
* @param $question * @param array $question
* @param $userid * @param mixed $userid
* @param $cookieid * @param string $cookieid
* @param $usershtml * @param array $usershtml
* @param $dummy * @param null $dummy
* @param $options * @param array $options
* @return array * @return array
*/ */
function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options) function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options)
...@@ -979,12 +975,12 @@ function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $d ...@@ -979,12 +975,12 @@ function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $d
/** /**
* Based on the elements in $question, return HTML to be passed to theme layer to link * Based on the elements in $question, return HTML to be passed to theme layer to link
* to the question, or to an associated answer, comment or edit. * to the question, or to an associated answer, comment or edit.
* @param $question * @param array $question
* @param $userid * @param mixed $userid
* @param $cookieid * @param string $cookieid
* @param $usershtml * @param array $usershtml
* @param $dummy * @param null $dummy
* @param $options * @param array $options
* @return array * @return array
*/ */
function qa_any_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options) function qa_any_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options)
...@@ -1001,8 +997,8 @@ function qa_any_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dum ...@@ -1001,8 +997,8 @@ function qa_any_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dum
/** /**
* Each element in $questions represents a question and optional associated answer, comment or edit, as retrieved from database. * Each element in $questions represents a question and optional associated answer, comment or edit, as retrieved from database.
* Return it sorted by the date appropriate for each element, without removing duplicate references to the same question. * Return it sorted by the date appropriate for each element, without removing duplicate references to the same question.
* @param $questions * @param array $questions
* @return mixed * @return array
*/ */
function qa_any_sort_by_date($questions) function qa_any_sort_by_date($questions)
{ {
...@@ -1022,7 +1018,7 @@ function qa_any_sort_by_date($questions) ...@@ -1022,7 +1018,7 @@ function qa_any_sort_by_date($questions)
/** /**
* Each element in $questions represents a question and optional associated answer, comment or edit, as retrieved from database. * Each element in $questions represents a question and optional associated answer, comment or edit, as retrieved from database.
* Return it sorted by the date appropriate for each element, and keep only the first item related to each question. * Return it sorted by the date appropriate for each element, and keep only the first item related to each question.
* @param $questions * @param array $questions
* @return array * @return array
*/ */
function qa_any_sort_and_dedupe($questions) function qa_any_sort_and_dedupe($questions)
...@@ -1079,7 +1075,7 @@ function qa_any_sort_and_dedupe($questions) ...@@ -1079,7 +1075,7 @@ function qa_any_sort_and_dedupe($questions)
/** /**
* Each element in $questions represents a question and optional associated answer, comment or edit, as retrieved from database. * Each element in $questions represents a question and optional associated answer, comment or edit, as retrieved from database.
* Return an array of elements (userid,handle) for the appropriate user for each element. * Return an array of elements (userid,handle) for the appropriate user for each element.
* @param $questions * @param array $questions
* @return array * @return array
*/ */
function qa_any_get_userids_handles($questions) function qa_any_get_userids_handles($questions)
...@@ -1108,7 +1104,7 @@ function qa_any_get_userids_handles($questions) ...@@ -1108,7 +1104,7 @@ function qa_any_get_userids_handles($questions)
* Return $html with any URLs converted into links (with nofollow and in a new window if $newwindow). * Return $html with any URLs converted into links (with nofollow and in a new window if $newwindow).
* Closing parentheses/brackets are removed from the link if they don't have a matching opening one. This avoids creating * Closing parentheses/brackets are removed from the link if they don't have a matching opening one. This avoids creating
* incorrect URLs from (http://www.question2answer.org) but allow URLs such as http://www.wikipedia.org/Computers_(Software) * incorrect URLs from (http://www.question2answer.org) but allow URLs such as http://www.wikipedia.org/Computers_(Software)
* @param $html * @param string $html
* @param bool $newwindow * @param bool $newwindow
* @return mixed * @return mixed
*/ */
...@@ -1160,7 +1156,7 @@ function qa_html_convert_urls($html, $newwindow = false) ...@@ -1160,7 +1156,7 @@ function qa_html_convert_urls($html, $newwindow = false)
/** /**
* Return HTML representation of $url (if it appears to be an URL), linked with nofollow and in a new window if $newwindow * Return HTML representation of $url (if it appears to be an URL), linked with nofollow and in a new window if $newwindow
* @param $url * @param string $url
* @param bool $newwindow * @param bool $newwindow
* @return mixed|string * @return mixed|string
*/ */
...@@ -1182,9 +1178,9 @@ function qa_url_to_html_link($url, $newwindow = false) ...@@ -1182,9 +1178,9 @@ function qa_url_to_html_link($url, $newwindow = false)
/** /**
* Return $htmlmessage with ^1...^6 substituted for links to log in or register or confirm email and come back to $topage with $params * Return $htmlmessage with ^1...^6 substituted for links to log in or register or confirm email and come back to $topage with $params
* @param $htmlmessage * @param string $htmlmessage
* @param null $topage * @param string|null $topage
* @param null $params * @param string|null $params
* @return string * @return string
*/ */
function qa_insert_login_links($htmlmessage, $topage = null, $params = null) function qa_insert_login_links($htmlmessage, $topage = null, $params = null)
...@@ -1214,14 +1210,14 @@ function qa_insert_login_links($htmlmessage, $topage = null, $params = null) ...@@ -1214,14 +1210,14 @@ function qa_insert_login_links($htmlmessage, $topage = null, $params = null)
* $start is current offset, there are $pagesize items per page and $count items in total * $start is current offset, there are $pagesize items per page and $count items in total
* (unless $hasmore is true in which case there are at least $count items). * (unless $hasmore is true in which case there are at least $count items).
* Show links to $prevnext pages before and after this one and include $params in the URLs. * Show links to $prevnext pages before and after this one and include $params in the URLs.
* @param $request * @param string $request
* @param $start * @param int $start
* @param $pagesize * @param int $pagesize
* @param $count * @param int $count
* @param $prevnext * @param int $prevnext
* @param array $params * @param array $params
* @param bool $hasmore * @param bool $hasmore
* @param null $anchor * @param string|null $anchor
* @return array|null * @return array|null
*/ */
function qa_html_page_links($request, $start, $pagesize, $count, $prevnext, $params = array(), $hasmore = false, $anchor = null) function qa_html_page_links($request, $start, $pagesize, $count, $prevnext, $params = array(), $hasmore = false, $anchor = null)
...@@ -1286,8 +1282,8 @@ function qa_html_page_links($request, $start, $pagesize, $count, $prevnext, $par ...@@ -1286,8 +1282,8 @@ function qa_html_page_links($request, $start, $pagesize, $count, $prevnext, $par
* Return HTML that suggests browsing all questions (in the category specified by $categoryrequest, if * Return HTML that suggests browsing all questions (in the category specified by $categoryrequest, if
* it's not null) and also popular tags if $usingtags is true * it's not null) and also popular tags if $usingtags is true
* @param bool $usingtags * @param bool $usingtags
* @param null $categoryrequest * @param string|null $categoryrequest
* @return mixed|string * @return string
*/ */
function qa_html_suggest_qs_tags($usingtags = false, $categoryrequest = null) function qa_html_suggest_qs_tags($usingtags = false, $categoryrequest = null)
{ {
...@@ -1313,8 +1309,8 @@ function qa_html_suggest_qs_tags($usingtags = false, $categoryrequest = null) ...@@ -1313,8 +1309,8 @@ function qa_html_suggest_qs_tags($usingtags = false, $categoryrequest = null)
/** /**
* Return HTML that suggest getting things started by asking a question, in $categoryid if not null * Return HTML that suggest getting things started by asking a question, in $categoryid if not null
* @param null $categoryid * @param int|null $categoryid
* @return mixed|string * @return string
*/ */
function qa_html_suggest_ask($categoryid = null) function qa_html_suggest_ask($categoryid = null)
{ {
...@@ -1336,12 +1332,12 @@ function qa_html_suggest_ask($categoryid = null) ...@@ -1336,12 +1332,12 @@ function qa_html_suggest_ask($categoryid = null)
/** /**
* Return the navigation structure for the category hierarchical menu, with $selectedid selected, * Return the navigation structure for the category hierarchical menu, with $selectedid selected,
* and links beginning with $pathprefix, and showing question counts if $showqcount * and links beginning with $pathprefix, and showing question counts if $showqcount
* @param $categories * @param array $categories
* @param null $selectedid * @param int|null $selectedid
* @param string $pathprefix * @param string $pathprefix
* @param bool $showqcount * @param bool $showqcount
* @param null $pathparams * @param array|null $pathparams
* @return array|mixed * @return array
*/ */
function qa_category_navigation($categories, $selectedid = null, $pathprefix = '', $showqcount = true, $pathparams = null) function qa_category_navigation($categories, $selectedid = null, $pathprefix = '', $showqcount = true, $pathparams = null)
{ {
...@@ -1361,14 +1357,14 @@ function qa_category_navigation($categories, $selectedid = null, $pathprefix = ' ...@@ -1361,14 +1357,14 @@ function qa_category_navigation($categories, $selectedid = null, $pathprefix = '
/** /**
* Recursion function used by qa_category_navigation(...) to build hierarchical category menu. * Recursion function used by qa_category_navigation(...) to build hierarchical category menu.
* @param $parentcategories * @param array $parentcategories
* @param $parentid * @param int|null $parentid
* @param $selecteds * @param array $selecteds
* @param $pathprefix * @param string $pathprefix
* @param $showqcount * @param bool $showqcount
* @param $pathparams * @param array $pathparams
* @param null $favoritemap * @param array|null $favoritemap
* @return array|mixed * @return array
*/ */
function qa_category_navigation_sub($parentcategories, $parentid, $selecteds, $pathprefix, $showqcount, $pathparams, $favoritemap = null) function qa_category_navigation_sub($parentcategories, $parentid, $selecteds, $pathprefix, $showqcount, $pathparams, $favoritemap = null)
{ {
...@@ -1407,6 +1403,7 @@ function qa_category_navigation_sub($parentcategories, $parentid, $selecteds, $p ...@@ -1407,6 +1403,7 @@ function qa_category_navigation_sub($parentcategories, $parentid, $selecteds, $p
/** /**
* Return the sub navigation structure for user listing pages * Return the sub navigation structure for user listing pages
* @return array|null
*/ */
function qa_users_sub_navigation() function qa_users_sub_navigation()
{ {
...@@ -1455,8 +1452,8 @@ function qa_users_sub_navigation() ...@@ -1455,8 +1452,8 @@ function qa_users_sub_navigation()
/** /**
* Return the sub navigation structure for navigating between the different pages relating to a user * Return the sub navigation structure for navigating between the different pages relating to a user
* @param $handle * @param string $handle
* @param $selected * @param string $selected
* @param bool $ismyuser * @param bool $ismyuser
* @return array * @return array
*/ */
...@@ -1526,7 +1523,7 @@ function qa_user_sub_navigation($handle, $selected, $ismyuser = false) ...@@ -1526,7 +1523,7 @@ function qa_user_sub_navigation($handle, $selected, $ismyuser = false)
/** /**
* Return the sub navigation structure for private message pages * Return the sub navigation structure for private message pages
* @deprecated 1.8.0 This menu is no longer used. * @deprecated 1.8.0 This menu is no longer used.
* @param null $selected * @param string|null $selected
* @return array * @return array
*/ */
function qa_messages_sub_navigation($selected = null) function qa_messages_sub_navigation($selected = null)
...@@ -1552,7 +1549,6 @@ function qa_messages_sub_navigation($selected = null) ...@@ -1552,7 +1549,6 @@ function qa_messages_sub_navigation($selected = null)
/** /**
* Return the sub navigation structure for user account pages. * Return the sub navigation structure for user account pages.
*
* @deprecated Deprecated from 1.6.3; use `qa_user_sub_navigation()` instead. * @deprecated Deprecated from 1.6.3; use `qa_user_sub_navigation()` instead.
*/ */
function qa_account_sub_navigation() function qa_account_sub_navigation()
...@@ -1573,7 +1569,7 @@ function qa_account_sub_navigation() ...@@ -1573,7 +1569,7 @@ function qa_account_sub_navigation()
/** /**
* Return the url for $page retrieved from the database * Return the url for $page retrieved from the database
* @param $page * @param array $page
* @return string * @return string
*/ */
function qa_custom_page_url($page) function qa_custom_page_url($page)
...@@ -1586,8 +1582,8 @@ function qa_custom_page_url($page) ...@@ -1586,8 +1582,8 @@ function qa_custom_page_url($page)
/** /**
* Add an element to the $navigation array corresponding to $page retrieved from the database * Add an element to the $navigation array corresponding to $page retrieved from the database
* @param $navigation * @param array $navigation
* @param $page * @param array $page
*/ */
function qa_navigation_add_page(&$navigation, $page) function qa_navigation_add_page(&$navigation, $page)
{ {
...@@ -1607,7 +1603,7 @@ function qa_navigation_add_page(&$navigation, $page) ...@@ -1607,7 +1603,7 @@ function qa_navigation_add_page(&$navigation, $page)
/** /**
* Convert an admin option for matching into a threshold for the score given by database search * Convert an admin option for matching into a threshold for the score given by database search
* @param $match * @param int $match
* @return int * @return int
*/ */
function qa_match_to_min_score($match) function qa_match_to_min_score($match)
...@@ -1618,7 +1614,6 @@ function qa_match_to_min_score($match) ...@@ -1618,7 +1614,6 @@ function qa_match_to_min_score($match)
/** /**
* Adds JavaScript to the page to handle toggling of form fields based on other fields. * Adds JavaScript to the page to handle toggling of form fields based on other fields.
*
* @param array $qa_content Page content array. * @param array $qa_content Page content array.
* @param array $effects List of rules for element toggling, with the structure: * @param array $effects List of rules for element toggling, with the structure:
* array('target1' => 'source1', 'target2' => 'source2', ...) * array('target1' => 'source1', 'target2' => 'source2', ...)
...@@ -1676,13 +1671,13 @@ function qa_set_display_rules(&$qa_content, $effects) ...@@ -1676,13 +1671,13 @@ function qa_set_display_rules(&$qa_content, $effects)
/** /**
* Set up $qa_content and $field (with HTML name $fieldname) for tag auto-completion, where * Set up $qa_content and $field (with HTML name $fieldname) for tag auto-completion, where
* $exampletags are suggestions and $completetags are simply the most popular ones. Show up to $maxtags. * $exampletags are suggestions and $completetags are simply the most popular ones. Show up to $maxtags.
* @param $qa_content * @param array $qa_content
* @param $field * @param array $field
* @param $fieldname * @param string $fieldname
* @param $tags * @param array $tags
* @param $exampletags * @param array $exampletags
* @param $completetags * @param array $completetags
* @param $maxtags * @param int $maxtags
*/ */
function qa_set_up_tag_field(&$qa_content, &$field, $fieldname, $tags, $exampletags, $completetags, $maxtags) function qa_set_up_tag_field(&$qa_content, &$field, $fieldname, $tags, $exampletags, $completetags, $maxtags)
{ {
...@@ -1716,7 +1711,7 @@ function qa_set_up_tag_field(&$qa_content, &$field, $fieldname, $tags, $examplet ...@@ -1716,7 +1711,7 @@ function qa_set_up_tag_field(&$qa_content, &$field, $fieldname, $tags, $examplet
/** /**
* Get a list of user-entered tags submitted from a field that was created with qa_set_up_tag_field(...) * Get a list of user-entered tags submitted from a field that was created with qa_set_up_tag_field(...)
* @param $fieldname * @param string $fieldname
* @return array * @return array
*/ */
function qa_get_tags_field_value($fieldname) function qa_get_tags_field_value($fieldname)
...@@ -1738,15 +1733,15 @@ function qa_get_tags_field_value($fieldname) ...@@ -1738,15 +1733,15 @@ function qa_get_tags_field_value($fieldname)
* If $allownone is true, it will allow selection of no category. If $allownosub is true, it will allow a category to be * If $allownone is true, it will allow selection of no category. If $allownosub is true, it will allow a category to be
* selected without selecting a subcategory within. Set $maxdepth to the maximum depth of category that can be selected * selected without selecting a subcategory within. Set $maxdepth to the maximum depth of category that can be selected
* (or null for no maximum) and $excludecategoryid to a category that should not be included. * (or null for no maximum) and $excludecategoryid to a category that should not be included.
* @param $qa_content * @param array $qa_content
* @param $field * @param array $field
* @param $fieldname * @param string $fieldname
* @param $navcategories * @param array $navcategories
* @param $categoryid * @param int $categoryid
* @param $allownone * @param int $allownone
* @param $allownosub * @param int $allownosub
* @param null $maxdepth * @param int|null $maxdepth
* @param null $excludecategoryid * @param int|null $excludecategoryid
*/ */
function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategories, $categoryid, $allownone, $allownosub, $maxdepth = null, $excludecategoryid = null) function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategories, $categoryid, $allownone, $allownosub, $maxdepth = null, $excludecategoryid = null)
{ {
...@@ -1834,8 +1829,8 @@ function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategor ...@@ -1834,8 +1829,8 @@ function qa_set_up_category_field(&$qa_content, &$field, $fieldname, $navcategor
/** /**
* Get the user-entered category id submitted from a field that was created with qa_set_up_category_field(...) * Get the user-entered category id submitted from a field that was created with qa_set_up_category_field(...)
* @param $fieldname * @param string $fieldname
* @return mixed|null * @return string|null
*/ */
function qa_get_category_field_value($fieldname) function qa_get_category_field_value($fieldname)
{ {
...@@ -1858,9 +1853,9 @@ function qa_get_category_field_value($fieldname) ...@@ -1858,9 +1853,9 @@ function qa_get_category_field_value($fieldname)
/** /**
* Set up $qa_content and add to $fields to allow the user to enter their name for a post if they are not logged in * Set up $qa_content and add to $fields to allow the user to enter their name for a post if they are not logged in
* $inname is from previous submission/validation. Pass $fieldprefix to add a prefix to the form field name used. * $inname is from previous submission/validation. Pass $fieldprefix to add a prefix to the form field name used.
* @param $qa_content * @param array $qa_content
* @param $fields * @param array $fields
* @param $inname * @param string $inname
* @param string $fieldprefix * @param string $fieldprefix
*/ */
function qa_set_up_name_field(&$qa_content, &$fields, $inname, $fieldprefix = '') function qa_set_up_name_field(&$qa_content, &$fields, $inname, $fieldprefix = '')
...@@ -1878,13 +1873,13 @@ function qa_set_up_name_field(&$qa_content, &$fields, $inname, $fieldprefix = '' ...@@ -1878,13 +1873,13 @@ function qa_set_up_name_field(&$qa_content, &$fields, $inname, $fieldprefix = ''
* $basetype is 'Q', 'A' or 'C' for question, answer or comment. $login_email is the email of logged in user, * $basetype is 'Q', 'A' or 'C' for question, answer or comment. $login_email is the email of logged in user,
* or null if this is an anonymous post. $innotify, $inemail and $errors_email are from previous submission/validation. * or null if this is an anonymous post. $innotify, $inemail and $errors_email are from previous submission/validation.
* Pass $fieldprefix to add a prefix to the form field names and IDs used. * Pass $fieldprefix to add a prefix to the form field names and IDs used.
* @param $qa_content * @param array $qa_content
* @param $fields * @param array $fields
* @param $basetype * @param string $basetype
* @param $login_email * @param string|null $login_email
* @param $innotify * @param string $innotify
* @param $inemail * @param string $inemail
* @param $errors_email * @param string $errors_email
* @param string $fieldprefix * @param string $fieldprefix
*/ */
function qa_set_up_notify_fields(&$qa_content, &$fields, $basetype, $login_email, $innotify, $inemail, $errors_email, $fieldprefix = '') function qa_set_up_notify_fields(&$qa_content, &$fields, $basetype, $login_email, $innotify, $inemail, $errors_email, $fieldprefix = '')
...@@ -1959,10 +1954,10 @@ function qa_get_site_theme() ...@@ -1959,10 +1954,10 @@ function qa_get_site_theme()
/** /**
* Return the initialized class for $theme (or the default if it's gone), passing $template, $content and $request. * Return the initialized class for $theme (or the default if it's gone), passing $template, $content and $request.
* Also applies any registered plugin layers. * Also applies any registered plugin layers.
* @param $theme * @param string $theme
* @param $template * @param string $template
* @param $content * @param array $content
* @param $request * @param string $request
* @return qa_html_theme_base * @return qa_html_theme_base
*/ */
function qa_load_theme_class($theme, $template, $content, $request) function qa_load_theme_class($theme, $template, $content, $request)
...@@ -2055,9 +2050,9 @@ function qa_load_theme_class($theme, $template, $content, $request) ...@@ -2055,9 +2050,9 @@ function qa_load_theme_class($theme, $template, $content, $request)
/** /**
* Return an instantiation of the appropriate editor module class, given $content in $format * Return an instantiation of the appropriate editor module class, given $content in $format
* Pass the preferred module name in $editorname, on return it will contain the name of the module used. * Pass the preferred module name in $editorname, on return it will contain the name of the module used.
* @param $content string * @param string $content
* @param $format string * @param string $format
* @param $editorname string * @param string $editorname
* @return object * @return object
*/ */
function qa_load_editor($content, $format, &$editorname) function qa_load_editor($content, $format, &$editorname)
...@@ -2092,7 +2087,7 @@ function qa_load_editor($content, $format, &$editorname) ...@@ -2092,7 +2087,7 @@ function qa_load_editor($content, $format, &$editorname)
* $content, $format, $fieldname, $rows and $focusnow are passed through to the module's get_field() method. ($focusnow * $content, $format, $fieldname, $rows and $focusnow are passed through to the module's get_field() method. ($focusnow
* is deprecated as a parameter to get_field() but it's still passed through for old editor modules.) Based on * is deprecated as a parameter to get_field() but it's still passed through for old editor modules.) Based on
* $focusnow and $loadnow, also add the editor's load and/or focus scripts to $qa_content's onload handlers. * $focusnow and $loadnow, also add the editor's load and/or focus scripts to $qa_content's onload handlers.
* @param $editor object * @param object $editor
* @param array $qa_content * @param array $qa_content
* @param string $content * @param string $content
* @param string $format * @param string $format
...@@ -2100,7 +2095,7 @@ function qa_load_editor($content, $format, &$editorname) ...@@ -2100,7 +2095,7 @@ function qa_load_editor($content, $format, &$editorname)
* @param int $rows * @param int $rows
* @param bool $focusnow * @param bool $focusnow
* @param bool $loadnow * @param bool $loadnow
* @return string|array * @return array
*/ */
function qa_editor_load_field($editor, &$qa_content, $content, $format, $fieldname, $rows, $focusnow = false, $loadnow = true) function qa_editor_load_field($editor, &$qa_content, $content, $format, $fieldname, $rows, $focusnow = false, $loadnow = true)
{ {
...@@ -2192,12 +2187,12 @@ function qa_get_post_title($fieldname) ...@@ -2192,12 +2187,12 @@ function qa_get_post_title($fieldname)
/** /**
* Retrieve the POST from an editor module's HTML field named $contentfield, where the editor's name was in HTML field $editorfield * Retrieve the POST from an editor module's HTML field named $contentfield, where the editor's name was in HTML field $editorfield
* Assigns the module's output to $incontent and $informat, editor's name in $ineditor, text rendering of content in $intext * Assigns the module's output to $incontent and $informat, editor's name in $ineditor, text rendering of content in $intext
* @param $editorfield * @param string $editorfield
* @param $contentfield * @param string $contentfield
* @param $ineditor * @param string $ineditor
* @param $incontent * @param string $incontent
* @param $informat * @param string $informat
* @param $intext * @param string $intext
*/ */
function qa_get_post_content($editorfield, $contentfield, &$ineditor, &$incontent, &$informat, &$intext) function qa_get_post_content($editorfield, $contentfield, &$ineditor, &$incontent, &$informat, &$intext)
{ {
...@@ -2217,8 +2212,8 @@ function qa_get_post_content($editorfield, $contentfield, &$ineditor, &$inconten ...@@ -2217,8 +2212,8 @@ function qa_get_post_content($editorfield, $contentfield, &$ineditor, &$inconten
/** /**
* Check if any of the 'content', 'format' or 'text' elements have changed between $oldfields and $fields * Check if any of the 'content', 'format' or 'text' elements have changed between $oldfields and $fields
* If so, recalculate $fields['text'] based on $fields['content'] and $fields['format'] * If so, recalculate $fields['text'] based on $fields['content'] and $fields['format']
* @param $fields * @param array $fields
* @param $oldfields * @param array $oldfields
*/ */
function qa_update_post_text(&$fields, $oldfields) function qa_update_post_text(&$fields, $oldfields)
{ {
...@@ -2234,12 +2229,12 @@ function qa_update_post_text(&$fields, $oldfields) ...@@ -2234,12 +2229,12 @@ function qa_update_post_text(&$fields, $oldfields)
/** /**
* Return the <img...> HTML to display avatar $blobid whose stored size is $width and $height * Return the <img...> HTML to display avatar $blobid whose stored size is $width and $height
* Constrain the image to $size (width AND height) and pad it to that size if $padding is true * Constrain the image to $size (width AND height) and pad it to that size if $padding is true
* @param $blobId * @param string $blobId
* @param $width * @param int $width
* @param $height * @param int $height
* @param $size * @param int $size
* @param bool $padding * @param bool $padding
* @return null|string * @return string|null
*/ */
function qa_get_avatar_blob_html($blobId, $width, $height, $size, $padding = false) function qa_get_avatar_blob_html($blobId, $width, $height, $size, $padding = false)
{ {
...@@ -2277,9 +2272,9 @@ function qa_get_avatar_blob_html($blobId, $width, $height, $size, $padding = fal ...@@ -2277,9 +2272,9 @@ function qa_get_avatar_blob_html($blobId, $width, $height, $size, $padding = fal
/** /**
* Return the <img...> HTML to display the Gravatar for $email, constrained to $size * Return the <img...> HTML to display the Gravatar for $email, constrained to $size
* @param $email * @param string $email
* @param $size * @param int|null $size
* @return mixed|null|string * @return string|null
*/ */
function qa_get_gravatar_html($email, $size) function qa_get_gravatar_html($email, $size)
{ {
...@@ -2300,9 +2295,9 @@ function qa_get_gravatar_html($email, $size) ...@@ -2300,9 +2295,9 @@ function qa_get_gravatar_html($email, $size)
/** /**
* Retrieve the appropriate user title from $pointstitle for a user with $userpoints points, or null if none * Retrieve the appropriate user title from $pointstitle for a user with $userpoints points, or null if none
* @param $userpoints * @param int $userpoints
* @param $pointstitle * @param array $pointstitle
* @return null * @return string|null
*/ */
function qa_get_points_title_html($userpoints, $pointstitle) function qa_get_points_title_html($userpoints, $pointstitle)
{ {
...@@ -2318,9 +2313,9 @@ function qa_get_points_title_html($userpoints, $pointstitle) ...@@ -2318,9 +2313,9 @@ function qa_get_points_title_html($userpoints, $pointstitle)
/** /**
* Return an form to add to the $qa_content['notices'] array for displaying a user notice with id $noticeid * Return an form to add to the $qa_content['notices'] array for displaying a user notice with id $noticeid
* and $content. Pass the raw database information for the notice in $rawnotice. * and $content. Pass the raw database information for the notice in $rawnotice.
* @param $noticeid * @param string $noticeid
* @param $content * @param string $content
* @param null $rawnotice * @param array|null $rawnotice
* @return array * @return array
*/ */
function qa_notice_form($noticeid, $content, $rawnotice = null) function qa_notice_form($noticeid, $content, $rawnotice = null)
...@@ -2341,10 +2336,10 @@ function qa_notice_form($noticeid, $content, $rawnotice = null) ...@@ -2341,10 +2336,10 @@ function qa_notice_form($noticeid, $content, $rawnotice = null)
/** /**
* Return a form to set in $qa_content['favorite'] for the favoriting button for entity $entitytype with $entityid. * Return a form to set in $qa_content['favorite'] for the favoriting button for entity $entitytype with $entityid.
* Set $favorite to whether the entity is currently a favorite and a description title for the button in $title. * Set $favorite to whether the entity is currently a favorite and a description title for the button in $title.
* @param $entitytype * @param string $entitytype
* @param $entityid * @param mixed $entityid
* @param $favorite * @param bool $favorite
* @param $title * @param string $title
* @return array * @return array
*/ */
function qa_favorite_form($entitytype, $entityid, $favorite, $title) function qa_favorite_form($entitytype, $entityid, $favorite, $title)
......
...@@ -167,7 +167,7 @@ function qa_is_ip_blocked() ...@@ -167,7 +167,7 @@ function qa_is_ip_blocked()
/** /**
* Return an array of the clauses within $blockipstring, each of which can contain hyphens or asterisks * Return an array of the clauses within $blockipstring, each of which can contain hyphens or asterisks
* @param $blockipstring * @param string $blockipstring
* @return array * @return array
*/ */
function qa_block_ips_explode($blockipstring) function qa_block_ips_explode($blockipstring)
...@@ -216,9 +216,9 @@ function qa_block_ip_match($ip, $blockipclause) ...@@ -216,9 +216,9 @@ function qa_block_ip_match($ip, $blockipclause)
/** /**
* Check if IP falls between two others. * Check if IP falls between two others.
* @param $ip * @param string $ip
* @param $startip * @param string $startip
* @param $endip * @param string $endip
* @return bool * @return bool
*/ */
function qa_ip_between($ip, $startip, $endip) function qa_ip_between($ip, $startip, $endip)
...@@ -294,7 +294,7 @@ function qa_report_write_action($userid, $cookieid, $action, $questionid, $answe ...@@ -294,7 +294,7 @@ function qa_report_write_action($userid, $cookieid, $action, $questionid, $answe
/** /**
* Take note for rate limits that a user and/or the requesting IP just performed an action. * Take note for rate limits that a user and/or the requesting IP just performed an action.
* @param int $userid User performing the action. * @param int|null $userid User performing the action.
* @param string $action One of the QA_LIMIT_* constants defined above. * @param string $action One of the QA_LIMIT_* constants defined above.
* @return mixed * @return mixed
*/ */
......
...@@ -120,10 +120,10 @@ function qa_mailing_perform_step() ...@@ -120,10 +120,10 @@ function qa_mailing_perform_step()
/** /**
* Send a single message from the mailing, to $userid with $handle and $email. * Send a single message from the mailing, to $userid with $handle and $email.
* Pass the user's existing $emailcode if there is one, otherwise a new one will be set up * Pass the user's existing $emailcode if there is one, otherwise a new one will be set up
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $email * @param string $email
* @param $emailcode * @param string $emailcode
* @return bool * @return bool
*/ */
function qa_mailing_send_one($userid, $handle, $email, $emailcode) function qa_mailing_send_one($userid, $handle, $email, $emailcode)
...@@ -152,6 +152,7 @@ function qa_mailing_send_one($userid, $handle, $email, $emailcode) ...@@ -152,6 +152,7 @@ function qa_mailing_send_one($userid, $handle, $email, $emailcode)
/** /**
* Return a message describing current progress in the mailing * Return a message describing current progress in the mailing
* @return string|null
*/ */
function qa_mailing_progress_message() function qa_mailing_progress_message()
{ {
......
...@@ -28,10 +28,10 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -28,10 +28,10 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Returns an HTML string describing the reason why user $fromuserid cannot post on the wall of $touserid who has * Returns an HTML string describing the reason why user $fromuserid cannot post on the wall of $touserid who has
* user flags $touserflags. If there is no such reason the function returns false. * user flags $touserflags. If there is no such reason the function returns false.
* @param $fromuserid * @param mixed $fromuserid
* @param $touserid * @param mixed $touserid
* @param $touserflags * @param int $touserflags
* @return bool|mixed|string * @return bool|string
*/ */
function qa_wall_error_html($fromuserid, $touserid, $touserflags) function qa_wall_error_html($fromuserid, $touserid, $touserflags)
{ {
...@@ -78,13 +78,13 @@ function qa_wall_error_html($fromuserid, $touserid, $touserflags) ...@@ -78,13 +78,13 @@ function qa_wall_error_html($fromuserid, $touserid, $touserflags)
/** /**
* Adds a post to the wall of user $touserid with handle $tohandle, containing $content in $format (e.g. '' for text or 'html') * Adds a post to the wall of user $touserid with handle $tohandle, containing $content in $format (e.g. '' for text or 'html')
* The post is by user $userid with handle $handle, and $cookieid is the user's current cookie (used for reporting the event). * The post is by user $userid with handle $handle, and $cookieid is the user's current cookie (used for reporting the event).
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $touserid * @param mixed $touserid
* @param $tohandle * @param string $tohandle
* @param $content * @param string $content
* @param $format * @param string $format
* @return mixed * @return mixed
*/ */
function qa_wall_add_post($userid, $handle, $cookieid, $touserid, $tohandle, $content, $format) function qa_wall_add_post($userid, $handle, $cookieid, $touserid, $tohandle, $content, $format)
...@@ -113,10 +113,10 @@ function qa_wall_add_post($userid, $handle, $cookieid, $touserid, $tohandle, $co ...@@ -113,10 +113,10 @@ function qa_wall_add_post($userid, $handle, $cookieid, $touserid, $tohandle, $co
/** /**
* Deletes the wall post described in $message (as obtained via qa_db_recent_messages_selectspec()). The deletion was performed * Deletes the wall post described in $message (as obtained via qa_db_recent_messages_selectspec()). The deletion was performed
* by user $userid with handle $handle, and $cookieid is the user's current cookie (all used for reporting the event). * by user $userid with handle $handle, and $cookieid is the user's current cookie (all used for reporting the event).
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $message * @param array $message
*/ */
function qa_wall_delete_post($userid, $handle, $cookieid, $message) function qa_wall_delete_post($userid, $handle, $cookieid, $message)
{ {
...@@ -136,9 +136,9 @@ function qa_wall_delete_post($userid, $handle, $cookieid, $message) ...@@ -136,9 +136,9 @@ function qa_wall_delete_post($userid, $handle, $cookieid, $message)
* Return the list of messages in $usermessages (as obtained via qa_db_recent_messages_selectspec()) with additional * Return the list of messages in $usermessages (as obtained via qa_db_recent_messages_selectspec()) with additional
* fields indicating what actions can be performed on them by the current user. The messages were retrieved beginning * fields indicating what actions can be performed on them by the current user. The messages were retrieved beginning
* at offset $start in the database. Currently only 'deleteable' is relevant. * at offset $start in the database. Currently only 'deleteable' is relevant.
* @param $usermessages * @param array $usermessages
* @param $start * @param int $start
* @return mixed * @return array
*/ */
function qa_wall_posts_add_rules($usermessages, $start) function qa_wall_posts_add_rules($usermessages, $start)
{ {
...@@ -166,7 +166,7 @@ function qa_wall_posts_add_rules($usermessages, $start) ...@@ -166,7 +166,7 @@ function qa_wall_posts_add_rules($usermessages, $start)
/** /**
* Returns an element to add to $qa_content['message_list']['messages'] for $message (as obtained via * Returns an element to add to $qa_content['message_list']['messages'] for $message (as obtained via
* qa_db_recent_messages_selectspec() and then qa_wall_posts_add_rules()). * qa_db_recent_messages_selectspec() and then qa_wall_posts_add_rules()).
* @param $message * @param array $message
* @return array * @return array
*/ */
function qa_wall_post_view($message) function qa_wall_post_view($message)
...@@ -197,8 +197,8 @@ function qa_wall_post_view($message) ...@@ -197,8 +197,8 @@ function qa_wall_post_view($message)
/** /**
* Returns an element to add to $qa_content['message_list']['messages'] with a link to view all wall posts * Returns an element to add to $qa_content['message_list']['messages'] with a link to view all wall posts
* @param $handle * @param string $handle
* @param $start * @param int $start
* @return array * @return array
*/ */
function qa_wall_view_more_link($handle, $start) function qa_wall_view_more_link($handle, $start)
...@@ -214,11 +214,11 @@ function qa_wall_view_more_link($handle, $start) ...@@ -214,11 +214,11 @@ function qa_wall_view_more_link($handle, $start)
* Hides the private message described in $message (as obtained via qa_db_messages_inbox_selectspec() or qa_db_messages_outbox_selectspec()). * Hides the private message described in $message (as obtained via qa_db_messages_inbox_selectspec() or qa_db_messages_outbox_selectspec()).
* If both sender and receiver have hidden the message, it gets deleted from the database. * If both sender and receiver have hidden the message, it gets deleted from the database.
* Note: currently no event is reported here, so $handle/$cookieid are unused. * Note: currently no event is reported here, so $handle/$cookieid are unused.
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $message * @param array $message
* @param $box * @param string $box
*/ */
function qa_pm_delete($userid, $handle, $cookieid, $message, $box) function qa_pm_delete($userid, $handle, $cookieid, $message, $box)
{ {
......
...@@ -43,7 +43,7 @@ define('QA_PERMIT_SUPERS', 0); ...@@ -43,7 +43,7 @@ define('QA_PERMIT_SUPERS', 0);
/** /**
* Return an array [name] => [value] of settings for each option in $names. * Return an array [name] => [value] of settings for each option in $names.
* If any options are missing from the database, set them to their defaults * If any options are missing from the database, set them to their defaults
* @param $names * @param array $names
* @return array * @return array
*/ */
function qa_get_options($names) function qa_get_options($names)
...@@ -96,8 +96,8 @@ function qa_get_options($names) ...@@ -96,8 +96,8 @@ function qa_get_options($names)
/** /**
* Return the value of option $name if it has already been loaded, otherwise return null * Return the value of option $name if it has already been loaded, otherwise return null
* (used to prevent a database query if it's not essential for us to know the option value) * (used to prevent a database query if it's not essential for us to know the option value)
* @param $name * @param string $name
* @return * @return string
*/ */
function qa_opt_if_loaded($name) function qa_opt_if_loaded($name)
{ {
...@@ -139,7 +139,7 @@ function qa_preload_options() ...@@ -139,7 +139,7 @@ function qa_preload_options()
/** /**
* Load the options from the $results of the database selectspecs defined in qa_preload_options() * Load the options from the $results of the database selectspecs defined in qa_preload_options()
* @param $results * @param array $results
* @return mixed * @return mixed
*/ */
function qa_load_options_results($results) function qa_load_options_results($results)
...@@ -161,8 +161,8 @@ function qa_load_options_results($results) ...@@ -161,8 +161,8 @@ function qa_load_options_results($results)
/** /**
* Set an option $name to $value (application level) in both cache and database, unless * Set an option $name to $value (application level) in both cache and database, unless
* $todatabase=false, in which case set it in the cache only * $todatabase=false, in which case set it in the cache only
* @param $name * @param string $name
* @param $value * @param mixed|null $value
* @param bool $todatabase * @param bool $todatabase
* @return mixed * @return mixed
*/ */
...@@ -181,7 +181,7 @@ function qa_set_option($name, $value, $todatabase = true) ...@@ -181,7 +181,7 @@ function qa_set_option($name, $value, $todatabase = true)
/** /**
* Reset the options in $names to their defaults * Reset the options in $names to their defaults
* @param $names * @param array $names
* @return mixed * @return mixed
*/ */
function qa_reset_options($names) function qa_reset_options($names)
...@@ -196,7 +196,7 @@ function qa_reset_options($names) ...@@ -196,7 +196,7 @@ function qa_reset_options($names)
/** /**
* Return the default value for option $name * Return the default value for option $name
* @param $name * @param string $name
* @return bool|mixed|string * @return bool|mixed|string
*/ */
function qa_default_option($name) function qa_default_option($name)
...@@ -561,7 +561,7 @@ function qa_default_site_title() ...@@ -561,7 +561,7 @@ function qa_default_site_title()
/** /**
* Return an array of defaults for the $options parameter passed to qa_post_html_fields() and its ilk for posts of $basetype='Q'/'A'/'C' * Return an array of defaults for the $options parameter passed to qa_post_html_fields() and its ilk for posts of $basetype='Q'/'A'/'C'
* Set $full to true if these posts will be viewed in full, i.e. on a question page rather than a question listing * Set $full to true if these posts will be viewed in full, i.e. on a question page rather than a question listing
* @param $basetype * @param string $basetype
* @param bool $full * @param bool $full
* @return array|mixed * @return array|mixed
*/ */
...@@ -601,8 +601,8 @@ function qa_post_html_defaults($basetype, $full = false) ...@@ -601,8 +601,8 @@ function qa_post_html_defaults($basetype, $full = false)
* Return an array of options for post $post to pass in the $options parameter to qa_post_html_fields() and its ilk. Preferably, * Return an array of options for post $post to pass in the $options parameter to qa_post_html_fields() and its ilk. Preferably,
* call qa_post_html_defaults() previously and pass its output in $defaults, to save excessive recalculation for each item in a * call qa_post_html_defaults() previously and pass its output in $defaults, to save excessive recalculation for each item in a
* list. Set $full to true if these posts will be viewed in full, i.e. on a question page rather than a question listing. * list. Set $full to true if these posts will be viewed in full, i.e. on a question page rather than a question listing.
* @param $post * @param array $post
* @param $defaults * @param array|null $defaults
* @param bool $full * @param bool $full
* @return array|mixed|null * @return array|mixed|null
*/ */
......
...@@ -227,8 +227,8 @@ function qa_get_request_content() ...@@ -227,8 +227,8 @@ function qa_get_request_content()
/** /**
* Output the $qa_content via the theme class after doing some pre-processing, mainly relating to Javascript * Output the $qa_content via the theme class after doing some pre-processing, mainly relating to Javascript
* @param $qa_content * @param array $qa_content
* @return mixed * @return mixed
*/ */
function qa_output_content($qa_content) function qa_output_content($qa_content)
...@@ -382,7 +382,7 @@ function qa_output_content($qa_content) ...@@ -382,7 +382,7 @@ function qa_output_content($qa_content)
/** /**
* Update any statistics required by the fields in $qa_content, and return true if something was done * Update any statistics required by the fields in $qa_content, and return true if something was done
* @param $qa_content * @param array $qa_content
* @return bool * @return bool
*/ */
function qa_do_content_stats($qa_content) function qa_do_content_stats($qa_content)
...@@ -487,7 +487,7 @@ function qa_controller_routing() ...@@ -487,7 +487,7 @@ function qa_controller_routing()
/** /**
* Sets the template which should be passed to the theme class, telling it which type of page it's displaying * Sets the template which should be passed to the theme class, telling it which type of page it's displaying
* @param $template * @param string $template
*/ */
function qa_set_template($template) function qa_set_template($template)
{ {
......
...@@ -33,10 +33,10 @@ require_once QA_INCLUDE_DIR . 'util/string.php'; ...@@ -33,10 +33,10 @@ require_once QA_INCLUDE_DIR . 'util/string.php';
/** /**
* Return value to store in database combining $notify and $email values entered by user $userid (or null for anonymous) * Return value to store in database combining $notify and $email values entered by user $userid (or null for anonymous)
* @param $userid * @param mixed $userid
* @param $notify * @param bool $notify
* @param $email * @param string $email
* @return null|string * @return string|null
*/ */
function qa_combine_notify_email($userid, $notify, $email) function qa_combine_notify_email($userid, $notify, $email)
{ {
...@@ -48,22 +48,22 @@ function qa_combine_notify_email($userid, $notify, $email) ...@@ -48,22 +48,22 @@ function qa_combine_notify_email($userid, $notify, $email)
* Add a question (application level) - create record, update appropriate counts, index it, send notifications. * Add a question (application level) - create record, update appropriate counts, index it, send notifications.
* If question is follow-on from an answer, $followanswer should contain answer database record, otherwise null. * If question is follow-on from an answer, $followanswer should contain answer database record, otherwise null.
* See /qa-include/app/posts.php for a higher-level function which is easier to use. * See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $followanswer * @param array $followanswer
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $title * @param string $title
* @param $content * @param string $content
* @param $format * @param string $format
* @param $text * @param string $text
* @param $tagstring * @param string $tagstring
* @param $notify * @param bool $notify
* @param $email * @param string $email
* @param $categoryid * @param int|null $categoryid
* @param $extravalue * @param string|null $extravalue
* @param bool $queued * @param bool $queued
* @param $name * @param string|null $name
* @return mixed * @return int
*/ */
function qa_question_create($followanswer, $userid, $handle, $cookieid, $title, $content, $format, $text, $tagstring, $notify, $email, function qa_question_create($followanswer, $userid, $handle, $cookieid, $title, $content, $format, $text, $tagstring, $notify, $email,
$categoryid = null, $extravalue = null, $queued = false, $name = null) $categoryid = null, $extravalue = null, $queued = false, $name = null)
...@@ -113,7 +113,7 @@ function qa_question_create($followanswer, $userid, $handle, $cookieid, $title, ...@@ -113,7 +113,7 @@ function qa_question_create($followanswer, $userid, $handle, $cookieid, $title,
/** /**
* Perform various common cached count updating operations to reflect changes in the question whose id is $postid * Perform various common cached count updating operations to reflect changes in the question whose id is $postid
* @param $postid * @param int|null $postid
*/ */
function qa_update_counts_for_q($postid) function qa_update_counts_for_q($postid)
{ {
...@@ -130,8 +130,8 @@ function qa_update_counts_for_q($postid) ...@@ -130,8 +130,8 @@ function qa_update_counts_for_q($postid)
/** /**
* Return an array containing the elements of $inarray whose key is in $keys * Return an array containing the elements of $inarray whose key is in $keys
* @param $inarray * @param array $inarray
* @param $keys * @param array $keys
* @return array * @return array
*/ */
function qa_array_filter_by_keys($inarray, $keys) function qa_array_filter_by_keys($inarray, $keys)
...@@ -163,16 +163,16 @@ function qa_suspend_post_indexing($suspend = true) ...@@ -163,16 +163,16 @@ function qa_suspend_post_indexing($suspend = true)
/** /**
* Add post $postid (which comes under $questionid) of $type (Q/A/C) to the database index, with $title, $text, * Add post $postid (which comes under $questionid) of $type (Q/A/C) to the database index, with $title, $text,
* $tagstring and $categoryid. Calls through to all installed search modules. * $tagstring and $categoryid. Calls through to all installed search modules.
* @param $postid * @param int $postid
* @param $type * @param string $type
* @param $questionid * @param int $questionid
* @param $parentid * @param int $parentid
* @param $title * @param string $title
* @param $content * @param string $content
* @param $format * @param string $format
* @param $text * @param string $text
* @param $tagstring * @param string $tagstring
* @param $categoryid * @param int $categoryid
*/ */
function qa_post_index($postid, $type, $questionid, $parentid, $title, $content, $format, $text, $tagstring, $categoryid) function qa_post_index($postid, $type, $questionid, $parentid, $title, $content, $format, $text, $tagstring, $categoryid)
{ {
...@@ -193,18 +193,18 @@ function qa_post_index($postid, $type, $questionid, $parentid, $title, $content, ...@@ -193,18 +193,18 @@ function qa_post_index($postid, $type, $questionid, $parentid, $title, $content,
* Add an answer (application level) - create record, update appropriate counts, index it, send notifications. * Add an answer (application level) - create record, update appropriate counts, index it, send notifications.
* $question should contain database record for the question this is an answer to. * $question should contain database record for the question this is an answer to.
* See /qa-include/app/posts.php for a higher-level function which is easier to use. * See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $content * @param string $content
* @param $format * @param string $format
* @param $text * @param string $text
* @param $notify * @param bool $notify
* @param $email * @param string $email
* @param $question * @param array $question
* @param bool $queued * @param bool $queued
* @param $name * @param string|null $name
* @return mixed * @return int
*/ */
function qa_answer_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question, $queued = false, $name = null) function qa_answer_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question, $queued = false, $name = null)
{ {
...@@ -244,7 +244,7 @@ function qa_answer_create($userid, $handle, $cookieid, $content, $format, $text, ...@@ -244,7 +244,7 @@ function qa_answer_create($userid, $handle, $cookieid, $content, $format, $text,
/** /**
* Perform various common cached count updating operations to reflect changes in an answer of question $questionid * Perform various common cached count updating operations to reflect changes in an answer of question $questionid
* @param $questionid * @param int $questionid
*/ */
function qa_update_q_counts_for_a($questionid) function qa_update_q_counts_for_a($questionid)
{ {
...@@ -263,20 +263,20 @@ function qa_update_q_counts_for_a($questionid) ...@@ -263,20 +263,20 @@ function qa_update_q_counts_for_a($questionid)
* $commentsfollows should contain database records for all previous comments on the same question or answer, * $commentsfollows should contain database records for all previous comments on the same question or answer,
* but it can also contain other records that are ignored. * but it can also contain other records that are ignored.
* See /qa-include/app/posts.php for a higher-level function which is easier to use. * See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $content * @param string $content
* @param $format * @param string $format
* @param $text * @param string $text
* @param $notify * @param bool $notify
* @param $email * @param string $email
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $commentsfollows * @param array $commentsfollows
* @param bool $queued * @param bool $queued
* @param $name * @param string|null $name
* @return mixed * @return int
*/ */
function qa_comment_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question, $parent, $commentsfollows, $queued = false, $name = null) function qa_comment_create($userid, $handle, $cookieid, $content, $format, $text, $notify, $email, $question, $parent, $commentsfollows, $queued = false, $name = null)
{ {
......
...@@ -44,18 +44,18 @@ define('QA_POST_STATUS_QUEUED', 2); ...@@ -44,18 +44,18 @@ define('QA_POST_STATUS_QUEUED', 2);
* $userid, $handle and $cookieid. Set $remoderate to true if the question should be requeued for moderation if * $userid, $handle and $cookieid. Set $remoderate to true if the question should be requeued for moderation if
* modified. Set $silent to true to not mark the question as edited. Reports event as appropriate. See /qa-include/app/posts.php * modified. Set $silent to true to not mark the question as edited. Reports event as appropriate. See /qa-include/app/posts.php
* for a higher-level function which is easier to use. * for a higher-level function which is easier to use.
* @param $oldquestion * @param array $oldquestion
* @param $title * @param string $title
* @param $content * @param string $content
* @param $format * @param string $format
* @param $text * @param string $text
* @param $tagstring * @param string $tagstring
* @param $notify * @param bool $notify
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $extravalue * @param string|null $extravalue
* @param $name * @param string|null $name
* @param bool $remoderate * @param bool $remoderate
* @param bool $silent * @param bool $silent
*/ */
...@@ -144,12 +144,12 @@ function qa_question_set_content($oldquestion, $title, $content, $format, $text, ...@@ -144,12 +144,12 @@ function qa_question_set_content($oldquestion, $title, $content, $format, $text,
* in $userid, $handle and $cookieid, and the database records for the selected and deselected answers in $answers. * in $userid, $handle and $cookieid, and the database records for the selected and deselected answers in $answers.
* Handles user points values and notifications. * Handles user points values and notifications.
* See /qa-include/app/posts.php for a higher-level function which is easier to use. * See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $oldquestion * @param array $oldquestion
* @param $selchildid * @param int|null $selchildid
* @param $answers * @param array $answers
*/ */
function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $selchildid, $answers) function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $selchildid, $answers)
{ {
...@@ -209,11 +209,11 @@ function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $ ...@@ -209,11 +209,11 @@ function qa_question_set_selchildid($userid, $handle, $cookieid, $oldquestion, $
* Reopen $oldquestion if it was closed. Pass details of the user doing this in $userid, $handle and $cookieid, and the * Reopen $oldquestion if it was closed. Pass details of the user doing this in $userid, $handle and $cookieid, and the
* $oldclosepost (to match $oldquestion['closedbyid']) if any. * $oldclosepost (to match $oldquestion['closedbyid']) if any.
* See /qa-include/app/posts.php for a higher-level function which is easier to use. * See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion * @param array $oldquestion
* @param $oldclosepost * @param array|null $oldclosepost
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
*/ */
function qa_question_close_clear($oldquestion, $oldclosepost, $userid, $handle, $cookieid) function qa_question_close_clear($oldquestion, $oldclosepost, $userid, $handle, $cookieid)
{ {
...@@ -237,12 +237,12 @@ function qa_question_close_clear($oldquestion, $oldclosepost, $userid, $handle, ...@@ -237,12 +237,12 @@ function qa_question_close_clear($oldquestion, $oldclosepost, $userid, $handle,
* Close $oldquestion as a duplicate of the question with id $originalpostid. Pass details of the user doing this in * Close $oldquestion as a duplicate of the question with id $originalpostid. Pass details of the user doing this in
* $userid, $handle and $cookieid, and the $oldclosepost (to match $oldquestion['closedbyid']) if any. See * $userid, $handle and $cookieid, and the $oldclosepost (to match $oldquestion['closedbyid']) if any. See
* /qa-include/app/posts.php for a higher-level function which is easier to use. * /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion * @param array $oldquestion
* @param $oldclosepost * @param array $oldclosepost
* @param $originalpostid * @param int $originalpostid
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
*/ */
function qa_question_close_duplicate($oldquestion, $oldclosepost, $originalpostid, $userid, $handle, $cookieid) function qa_question_close_duplicate($oldquestion, $oldclosepost, $originalpostid, $userid, $handle, $cookieid)
{ {
...@@ -263,12 +263,12 @@ function qa_question_close_duplicate($oldquestion, $oldclosepost, $originalposti ...@@ -263,12 +263,12 @@ function qa_question_close_duplicate($oldquestion, $oldclosepost, $originalposti
* Close $oldquestion with the reason given in $note. Pass details of the user doing this in $userid, $handle and * Close $oldquestion with the reason given in $note. Pass details of the user doing this in $userid, $handle and
* $cookieid, and the $oldclosepost (to match $oldquestion['closedbyid']) if any. * $cookieid, and the $oldclosepost (to match $oldquestion['closedbyid']) if any.
* See /qa-include/app/posts.php for a higher-level function which is easier to use. * See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion * @param array $oldquestion
* @param $oldclosepost * @param array $oldclosepost
* @param $note * @param string $note
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
*/ */
function qa_question_close_other($oldquestion, $oldclosepost, $note, $userid, $handle, $cookieid) function qa_question_close_other($oldquestion, $oldclosepost, $note, $userid, $handle, $cookieid)
{ {
...@@ -294,16 +294,17 @@ function qa_question_close_other($oldquestion, $oldclosepost, $note, $userid, $h ...@@ -294,16 +294,17 @@ function qa_question_close_other($oldquestion, $oldclosepost, $note, $userid, $h
/** /**
* Set $oldquestion to hidden if $hidden is true, visible/normal if otherwise. All other parameters are as for qa_question_set_status(...) * Set $oldquestion to hidden if $hidden is true, visible/normal if otherwise. All other parameters are as for
* qa_question_set_status(...)
* @deprecated Replaced by qa_question_set_status. * @deprecated Replaced by qa_question_set_status.
* @param $oldquestion * @param array $oldquestion
* @param $hidden * @param bool $hidden
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $answers * @param array $answers
* @param $commentsfollows * @param array $commentsfollows
* @param $closepost * @param int|null $closepost
*/ */
function qa_question_set_hidden($oldquestion, $hidden, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost = null) function qa_question_set_hidden($oldquestion, $hidden, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost = null)
{ {
...@@ -318,14 +319,14 @@ function qa_question_set_hidden($oldquestion, $hidden, $userid, $handle, $cookie ...@@ -318,14 +319,14 @@ function qa_question_set_hidden($oldquestion, $hidden, $userid, $handle, $cookie
* $commentsfollows ($commentsfollows can also contain records for follow-on questions which are ignored), and * $commentsfollows ($commentsfollows can also contain records for follow-on questions which are ignored), and
* $closepost to match $oldquestion['closedbyid'] (if any). Handles indexing, user points, cached counts and event * $closepost to match $oldquestion['closedbyid'] (if any). Handles indexing, user points, cached counts and event
* reports. See /qa-include/app/posts.php for a higher-level function which is easier to use. * reports. See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion * @param array $oldquestion
* @param $status * @param int $status
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $answers * @param array $answers
* @param $commentsfollows * @param array $commentsfollows
* @param $closepost * @param array|null $closepost
*/ */
function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost = null) function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost = null)
{ {
...@@ -472,14 +473,14 @@ function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookie ...@@ -472,14 +473,14 @@ function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookie
* contain records for follow-on questions which are ignored), and $closepost to match $oldquestion['closedbyid'] (if any). * contain records for follow-on questions which are ignored), and $closepost to match $oldquestion['closedbyid'] (if any).
* Set $silent to true to not mark the question as edited. Handles cached counts and event reports and will reset category * Set $silent to true to not mark the question as edited. Handles cached counts and event reports and will reset category
* IDs and paths for all answers and comments. See /qa-include/app/posts.php for a higher-level function which is easier to use. * IDs and paths for all answers and comments. See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion * @param array $oldquestion
* @param $categoryid * @param int $categoryid
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $answers * @param array $answers
* @param $commentsfollows * @param array $commentsfollows
* @param $closepost * @param int|null $closepost
* @param bool $silent * @param bool $silent
*/ */
function qa_question_set_category($oldquestion, $categoryid, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost = null, $silent = false) function qa_question_set_category($oldquestion, $categoryid, $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost = null, $silent = false)
...@@ -531,11 +532,11 @@ function qa_question_set_category($oldquestion, $categoryid, $userid, $handle, $ ...@@ -531,11 +532,11 @@ function qa_question_set_category($oldquestion, $categoryid, $userid, $handle, $
* comments on it. Pass details of the user doing this in $userid, $handle and $cookieid, and $closepost to match * comments on it. Pass details of the user doing this in $userid, $handle and $cookieid, and $closepost to match
* $oldquestion['closedbyid'] (if any). Handles unindexing, votes, points, cached counts and event reports. * $oldquestion['closedbyid'] (if any). Handles unindexing, votes, points, cached counts and event reports.
* See /qa-include/app/posts.php for a higher-level function which is easier to use. * See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldquestion * @param array $oldquestion
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $oldclosepost * @param array|null $oldclosepost
*/ */
function qa_question_delete($oldquestion, $userid, $handle, $cookieid, $oldclosepost = null) function qa_question_delete($oldquestion, $userid, $handle, $cookieid, $oldclosepost = null)
{ {
...@@ -579,10 +580,10 @@ function qa_question_delete($oldquestion, $userid, $handle, $cookieid, $oldclose ...@@ -579,10 +580,10 @@ function qa_question_delete($oldquestion, $userid, $handle, $cookieid, $oldclose
/** /**
* Set the author (application level) of $oldquestion to $userid and also pass $handle and $cookieid * Set the author (application level) of $oldquestion to $userid and also pass $handle and $cookieid
* of user. Updates points and reports events as appropriate. * of user. Updates points and reports events as appropriate.
* @param $oldquestion * @param array $oldquestion
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
*/ */
function qa_question_set_userid($oldquestion, $userid, $handle, $cookieid) function qa_question_set_userid($oldquestion, $userid, $handle, $cookieid)
{ {
...@@ -606,7 +607,7 @@ function qa_question_set_userid($oldquestion, $userid, $handle, $cookieid) ...@@ -606,7 +607,7 @@ function qa_question_set_userid($oldquestion, $userid, $handle, $cookieid)
/** /**
* Remove post $postid from our index and update appropriate word counts. Calls through to all search modules. * Remove post $postid from our index and update appropriate word counts. Calls through to all search modules.
* @param $postid * @param int $postid
*/ */
function qa_post_unindex($postid) function qa_post_unindex($postid)
{ {
...@@ -643,16 +644,16 @@ function qa_question_uncache($questionId) ...@@ -643,16 +644,16 @@ function qa_question_uncache($questionId)
* $handle and $cookieid. Set $remoderate to true if the question should be requeued for moderation if modified. Set * $handle and $cookieid. Set $remoderate to true if the question should be requeued for moderation if modified. Set
* $silent to true to not mark the question as edited. Handle indexing and event reports as appropriate. See * $silent to true to not mark the question as edited. Handle indexing and event reports as appropriate. See
* /qa-include/app/posts.php for a higher-level function which is easier to use. * /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldanswer * @param array $oldanswer
* @param $content * @param string $content
* @param $format * @param string $format
* @param $text * @param string $text
* @param $notify * @param bool $notify
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $question * @param array $question
* @param $name * @param string|null $name
* @param bool $remoderate * @param bool $remoderate
* @param bool $silent * @param bool $silent
*/ */
...@@ -715,13 +716,13 @@ function qa_answer_set_content($oldanswer, $content, $format, $text, $notify, $u ...@@ -715,13 +716,13 @@ function qa_answer_set_content($oldanswer, $content, $format, $text, $notify, $u
/** /**
* Set $oldanswer to hidden if $hidden is true, visible/normal if otherwise. All other parameters are as for qa_answer_set_status(...) * Set $oldanswer to hidden if $hidden is true, visible/normal if otherwise. All other parameters are as for qa_answer_set_status(...)
* @deprecated Replaced by qa_answer_set_status. * @deprecated Replaced by qa_answer_set_status.
* @param $oldanswer * @param array $oldanswer
* @param $hidden * @param bool $hidden
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $question * @param array $question
* @param $commentsfollows * @param array $commentsfollows
*/ */
function qa_answer_set_hidden($oldanswer, $hidden, $userid, $handle, $cookieid, $question, $commentsfollows) function qa_answer_set_hidden($oldanswer, $hidden, $userid, $handle, $cookieid, $question, $commentsfollows)
{ {
...@@ -735,13 +736,13 @@ function qa_answer_set_hidden($oldanswer, $hidden, $userid, $handle, $cookieid, ...@@ -735,13 +736,13 @@ function qa_answer_set_hidden($oldanswer, $hidden, $userid, $handle, $cookieid,
* and the database records for all comments on the answer in $commentsfollows ($commentsfollows can also contain other * and the database records for all comments on the answer in $commentsfollows ($commentsfollows can also contain other
* records which are ignored). Handles indexing, user points, cached counts and event reports. See /qa-include/app/posts.php for * records which are ignored). Handles indexing, user points, cached counts and event reports. See /qa-include/app/posts.php for
* a higher-level function which is easier to use. * a higher-level function which is easier to use.
* @param $oldanswer * @param array $oldanswer
* @param $status * @param int $status
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $question * @param array $question
* @param $commentsfollows * @param array $commentsfollows
*/ */
function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid, $question, $commentsfollows) function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid, $question, $commentsfollows)
{ {
...@@ -860,11 +861,11 @@ function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid, ...@@ -860,11 +861,11 @@ function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid,
* follow-on questions. Pass the database record for the question in $question and details of the user doing this * follow-on questions. Pass the database record for the question in $question and details of the user doing this
* in $userid, $handle and $cookieid. Handles unindexing, votes, points, cached counts and event reports. * in $userid, $handle and $cookieid. Handles unindexing, votes, points, cached counts and event reports.
* See /qa-include/app/posts.php for a higher-level function which is easier to use. * See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldanswer * @param array $oldanswer
* @param $question * @param array $question
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
*/ */
function qa_answer_delete($oldanswer, $question, $userid, $handle, $cookieid) function qa_answer_delete($oldanswer, $question, $userid, $handle, $cookieid)
{ {
...@@ -908,10 +909,10 @@ function qa_answer_delete($oldanswer, $question, $userid, $handle, $cookieid) ...@@ -908,10 +909,10 @@ function qa_answer_delete($oldanswer, $question, $userid, $handle, $cookieid)
/** /**
* Set the author (application level) of $oldanswer to $userid and also pass $handle and $cookieid * Set the author (application level) of $oldanswer to $userid and also pass $handle and $cookieid
* of user. Updates points and reports events as appropriate. * of user. Updates points and reports events as appropriate.
* @param $oldanswer * @param array $oldanswer
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
*/ */
function qa_answer_set_userid($oldanswer, $userid, $handle, $cookieid) function qa_answer_set_userid($oldanswer, $userid, $handle, $cookieid)
{ {
...@@ -942,17 +943,17 @@ function qa_answer_set_userid($oldanswer, $userid, $handle, $cookieid) ...@@ -942,17 +943,17 @@ function qa_answer_set_userid($oldanswer, $userid, $handle, $cookieid)
* otherwise null. Set $remoderate to true if the question should be requeued for moderation if modified. Set $silent * otherwise null. Set $remoderate to true if the question should be requeued for moderation if modified. Set $silent
* to true to not mark the question as edited. Handles unindexing and event reports. See /qa-include/app/posts.php for a * to true to not mark the question as edited. Handles unindexing and event reports. See /qa-include/app/posts.php for a
* higher-level function which is easier to use. * higher-level function which is easier to use.
* @param $oldcomment * @param array $oldcomment
* @param $content * @param string $content
* @param $format * @param string $format
* @param $text * @param string $text
* @param $notify * @param bool $notify
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $name * @param string|null $name
* @param bool $remoderate * @param bool $remoderate
* @param bool $silent * @param bool $silent
*/ */
...@@ -1018,19 +1019,19 @@ function qa_comment_set_content($oldcomment, $content, $format, $text, $notify, ...@@ -1018,19 +1019,19 @@ function qa_comment_set_content($oldcomment, $content, $format, $text, $notify,
* $commentsfollows ($commentsfollows can also contain other records which are ignored). Set $remoderate to true if the * $commentsfollows ($commentsfollows can also contain other records which are ignored). Set $remoderate to true if the
* question should be requeued for moderation if modified. Set $silent to true to not mark the question as edited. * question should be requeued for moderation if modified. Set $silent to true to not mark the question as edited.
* Handles indexing (based on $text), user points, cached counts and event reports. * Handles indexing (based on $text), user points, cached counts and event reports.
* @param $oldanswer * @param array $oldanswer
* @param $parentid * @param int $parentid
* @param $content * @param string $content
* @param $format * @param string $format
* @param $text * @param string $text
* @param $notify * @param bool $notify
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $question * @param array $question
* @param $answers * @param array $answers
* @param $commentsfollows * @param array $commentsfollows
* @param $name * @param string|null $name
* @param bool $remoderate * @param bool $remoderate
* @param bool $silent * @param bool $silent
*/ */
...@@ -1116,13 +1117,13 @@ function qa_answer_to_comment($oldanswer, $parentid, $content, $format, $text, $ ...@@ -1116,13 +1117,13 @@ function qa_answer_to_comment($oldanswer, $parentid, $content, $format, $text, $
/** /**
* Set $oldcomment to hidden if $hidden is true, visible/normal if otherwise. All other parameters are as for qa_comment_set_status(...) * Set $oldcomment to hidden if $hidden is true, visible/normal if otherwise. All other parameters are as for qa_comment_set_status(...)
* @deprecated Replaced by qa_comment_set_status. * @deprecated Replaced by qa_comment_set_status.
* @param $oldcomment * @param array $oldcomment
* @param $hidden * @param bool $hidden
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $question * @param array $question
* @param $parent * @param array $parent
*/ */
function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid, $question, $parent) function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid, $question, $parent)
{ {
...@@ -1135,13 +1136,13 @@ function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid ...@@ -1135,13 +1136,13 @@ function qa_comment_set_hidden($oldcomment, $hidden, $userid, $handle, $cookieid
* antecedent question's record in $question, details of the user doing this in $userid, $handle and $cookieid, and the * antecedent question's record in $question, details of the user doing this in $userid, $handle and $cookieid, and the
* answer's database record in $answer if this is a comment on an answer, otherwise null. Handles indexing, user * answer's database record in $answer if this is a comment on an answer, otherwise null. Handles indexing, user
* points, cached counts and event reports. See /qa-include/app/posts.php for a higher-level function which is easier to use. * points, cached counts and event reports. See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldcomment * @param array $oldcomment
* @param $status * @param int $status
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $question * @param array $question
* @param $parent * @param array $parent
*/ */
function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid, $question, $parent) function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid, $question, $parent)
{ {
...@@ -1261,12 +1262,12 @@ function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid ...@@ -1261,12 +1262,12 @@ function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid
* and the answer's database record in $answer if this is a comment on an answer, otherwise null. Pass details of the user * and the answer's database record in $answer if this is a comment on an answer, otherwise null. Pass details of the user
* doing this in $userid, $handle and $cookieid. Handles unindexing, points, cached counts and event reports. * doing this in $userid, $handle and $cookieid. Handles unindexing, points, cached counts and event reports.
* See /qa-include/app/posts.php for a higher-level function which is easier to use. * See /qa-include/app/posts.php for a higher-level function which is easier to use.
* @param $oldcomment * @param array $oldcomment
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
*/ */
function qa_comment_delete($oldcomment, $question, $parent, $userid, $handle, $cookieid) function qa_comment_delete($oldcomment, $question, $parent, $userid, $handle, $cookieid)
{ {
...@@ -1299,10 +1300,10 @@ function qa_comment_delete($oldcomment, $question, $parent, $userid, $handle, $c ...@@ -1299,10 +1300,10 @@ function qa_comment_delete($oldcomment, $question, $parent, $userid, $handle, $c
/** /**
* Set the author (application level) of $oldcomment to $userid and also pass $handle and $cookieid * Set the author (application level) of $oldcomment to $userid and also pass $handle and $cookieid
* of user. Updates points and reports events as appropriate. * of user. Updates points and reports events as appropriate.
* @param $oldcomment * @param array $oldcomment
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
*/ */
function qa_comment_set_userid($oldcomment, $userid, $handle, $cookieid) function qa_comment_set_userid($oldcomment, $userid, $handle, $cookieid)
{ {
......
...@@ -49,18 +49,18 @@ require_once QA_INCLUDE_DIR . 'util/string.php'; ...@@ -49,18 +49,18 @@ require_once QA_INCLUDE_DIR . 'util/string.php';
* post - either to $email if it is specified and valid, or to the current email address of $userid if $email is '@'. * post - either to $email if it is specified and valid, or to the current email address of $userid if $email is '@'.
* If you're creating a question, the $extravalue parameter will be set as the custom extra field, if not null. For all * If you're creating a question, the $extravalue parameter will be set as the custom extra field, if not null. For all
* post types you can specify the $name of the post's author, which is relevant if the $userid is null. * post types you can specify the $name of the post's author, which is relevant if the $userid is null.
* @param $type * @param string $type
* @param $parentid * @param int|null $parentid
* @param $title * @param string $title
* @param $content * @param string $content
* @param string $format * @param string $format
* @param $categoryid * @param int|null $categoryid
* @param $tags * @param array|null $tags
* @param $userid * @param mixed|null $userid
* @param $notify * @param string|null $notify
* @param $email * @param string|null $email
* @param $extravalue * @param string|null $extravalue
* @param $name * @param string|null $name
* @return mixed * @return mixed
*/ */
function qa_post_create($type, $parentid, $title, $content, $format = '', $categoryid = null, $tags = null, $userid = null, function qa_post_create($type, $parentid, $title, $content, $format = '', $categoryid = null, $tags = null, $userid = null,
...@@ -105,16 +105,16 @@ function qa_post_create($type, $parentid, $title, $content, $format = '', $categ ...@@ -105,16 +105,16 @@ function qa_post_create($type, $parentid, $title, $content, $format = '', $categ
* Change the data stored for post $postid based on any of the $title, $content, $format, $tags, $notify, $email, * Change the data stored for post $postid based on any of the $title, $content, $format, $tags, $notify, $email,
* $extravalue and $name parameters passed which are not null. The meaning of these parameters is the same as for * $extravalue and $name parameters passed which are not null. The meaning of these parameters is the same as for
* qa_post_create() above. Pass the identify of the user making this change in $byuserid (or null for silent). * qa_post_create() above. Pass the identify of the user making this change in $byuserid (or null for silent).
* @param $postid * @param int $postid
* @param $title * @param string|null $title
* @param $content * @param string|null $content
* @param $format * @param string $format
* @param $tags * @param array|null $tags
* @param $notify * @param string|null $notify
* @param $email * @param string|null $email
* @param $byuserid * @param mixed|null $byuserid
* @param $extravalue * @param string|null $extravalue
* @param $name * @param string $name
*/ */
function qa_post_set_content($postid, $title, $content, $format = null, $tags = null, $notify = null, $email = null, $byuserid = null, $extravalue = null, $name = null) function qa_post_set_content($postid, $title, $content, $format = null, $tags = null, $notify = null, $email = null, $byuserid = null, $extravalue = null, $name = null)
{ {
...@@ -166,9 +166,9 @@ function qa_post_set_content($postid, $title, $content, $format = null, $tags = ...@@ -166,9 +166,9 @@ function qa_post_set_content($postid, $title, $content, $format = null, $tags =
* Change the category of $postid to $categoryid. The category of all related posts (shown together on the same * Change the category of $postid to $categoryid. The category of all related posts (shown together on the same
* question page) will also be changed. Pass the identify of the user making this change in $byuserid (or null for an * question page) will also be changed. Pass the identify of the user making this change in $byuserid (or null for an
* anonymous change). * anonymous change).
* @param $postid * @param int $postid
* @param $categoryid * @param int $categoryid
* @param $byuserid * @param mixed|null $byuserid
*/ */
function qa_post_set_category($postid, $categoryid, $byuserid = null) function qa_post_set_category($postid, $categoryid, $byuserid = null)
{ {
...@@ -189,9 +189,9 @@ function qa_post_set_category($postid, $categoryid, $byuserid = null) ...@@ -189,9 +189,9 @@ function qa_post_set_category($postid, $categoryid, $byuserid = null)
/** /**
* Set the selected best answer of $questionid to $answerid (or to none if $answerid is null). Pass the identify of the * Set the selected best answer of $questionid to $answerid (or to none if $answerid is null). Pass the identify of the
* user in $byuserid (or null for an anonymous change). * user in $byuserid (or null for an anonymous change).
* @param $questionid * @param int $questionid
* @param $answerid * @param int|null $answerid
* @param $byuserid * @param mixed|null $byuserid
*/ */
function qa_post_set_selchildid($questionid, $answerid, $byuserid = null) function qa_post_set_selchildid($questionid, $answerid, $byuserid = null)
{ {
...@@ -210,11 +210,11 @@ function qa_post_set_selchildid($questionid, $answerid, $byuserid = null) ...@@ -210,11 +210,11 @@ function qa_post_set_selchildid($questionid, $answerid, $byuserid = null)
* Close $questionid if $closed is true, otherwise reopen it. If $closed is true, pass either the $originalpostid of * Close $questionid if $closed is true, otherwise reopen it. If $closed is true, pass either the $originalpostid of
* the question that it is a duplicate of, or a $note to explain why it's closed. Pass the identifier of the user in * the question that it is a duplicate of, or a $note to explain why it's closed. Pass the identifier of the user in
* $byuserid (or null for an anonymous change). * $byuserid (or null for an anonymous change).
* @param $questionid * @param int $questionid
* @param bool $closed * @param bool $closed
* @param $originalpostid * @param int|null $originalpostid
* @param $note * @param string|null $note
* @param $byuserid * @param mixed|null $byuserid
*/ */
function qa_post_set_closed($questionid, $closed = true, $originalpostid = null, $note = null, $byuserid = null) function qa_post_set_closed($questionid, $closed = true, $originalpostid = null, $note = null, $byuserid = null)
{ {
...@@ -251,9 +251,9 @@ function qa_post_is_closed(array $question) ...@@ -251,9 +251,9 @@ function qa_post_is_closed(array $question)
* Hide $postid if $hidden is true, otherwise show the post. Pass the identify of the user making this change in * Hide $postid if $hidden is true, otherwise show the post. Pass the identify of the user making this change in
* $byuserid (or null for a silent change). * $byuserid (or null for a silent change).
* @deprecated Replaced by qa_post_set_status. * @deprecated Replaced by qa_post_set_status.
* @param $postid * @param int $postid
* @param bool $hidden * @param bool $hidden
* @param $byuserid * @param mixed|null $byuserid
*/ */
function qa_post_set_hidden($postid, $hidden = true, $byuserid = null) function qa_post_set_hidden($postid, $hidden = true, $byuserid = null)
{ {
...@@ -264,9 +264,9 @@ function qa_post_set_hidden($postid, $hidden = true, $byuserid = null) ...@@ -264,9 +264,9 @@ function qa_post_set_hidden($postid, $hidden = true, $byuserid = null)
/** /**
* Change the status of $postid to $status, which should be one of the QA_POST_STATUS_* constants defined in * Change the status of $postid to $status, which should be one of the QA_POST_STATUS_* constants defined in
* /qa-include/app/post-update.php. Pass the identify of the user making this change in $byuserid (or null for a silent change). * /qa-include/app/post-update.php. Pass the identify of the user making this change in $byuserid (or null for a silent change).
* @param $postid * @param int $postid
* @param $status * @param int $status
* @param $byuserid * @param mixed|null $byuserid
*/ */
function qa_post_set_status($postid, $status, $byuserid = null) function qa_post_set_status($postid, $status, $byuserid = null)
{ {
...@@ -298,8 +298,8 @@ function qa_post_set_status($postid, $status, $byuserid = null) ...@@ -298,8 +298,8 @@ function qa_post_set_status($postid, $status, $byuserid = null)
/** /**
* Set the created date of $postid to $created, which is a unix timestamp. * Set the created date of $postid to $created, which is a unix timestamp.
* @param $postid * @param int $postid
* @param $created * @param int $created
*/ */
function qa_post_set_created($postid, $created) function qa_post_set_created($postid, $created)
{ {
...@@ -321,7 +321,7 @@ function qa_post_set_created($postid, $created) ...@@ -321,7 +321,7 @@ function qa_post_set_created($postid, $created)
/** /**
* Delete $postid from the database, hiding it first if appropriate. * Delete $postid from the database, hiding it first if appropriate.
* @param $postid * @param int $postid
*/ */
function qa_post_delete($postid) function qa_post_delete($postid)
{ {
...@@ -365,9 +365,9 @@ function qa_post_delete($postid) ...@@ -365,9 +365,9 @@ function qa_post_delete($postid)
/** /**
* Return the full information from the database for $postid in an array. * Return the full information from the database for $postid in an array.
* @param $postid * @param int $postid
* @param $requiredbasetypes * @param string|null $requiredbasetypes
* @return array|mixed * @return array
*/ */
function qa_post_get_full($postid, $requiredbasetypes = null) function qa_post_get_full($postid, $requiredbasetypes = null)
{ {
...@@ -387,8 +387,8 @@ function qa_post_get_full($postid, $requiredbasetypes = null) ...@@ -387,8 +387,8 @@ function qa_post_get_full($postid, $requiredbasetypes = null)
* Return the handle corresponding to $userid, unless it is null in which case return null. * Return the handle corresponding to $userid, unless it is null in which case return null.
* *
* @deprecated Deprecated from 1.7; use `qa_userid_to_handle($userid)` instead. * @deprecated Deprecated from 1.7; use `qa_userid_to_handle($userid)` instead.
* @param $userid * @param mixed $userid
* @return mixed|null * @return string|null
*/ */
function qa_post_userid_to_handle($userid) function qa_post_userid_to_handle($userid)
{ {
...@@ -398,8 +398,8 @@ function qa_post_userid_to_handle($userid) ...@@ -398,8 +398,8 @@ function qa_post_userid_to_handle($userid)
/** /**
* Return the textual rendition of $content in $format (used for indexing). * Return the textual rendition of $content in $format (used for indexing).
* @param $content * @param string $content
* @param $format * @param string $format
* @return string * @return string
*/ */
function qa_post_content_to_text($content, $format) function qa_post_content_to_text($content, $format)
...@@ -415,8 +415,8 @@ function qa_post_content_to_text($content, $format) ...@@ -415,8 +415,8 @@ function qa_post_content_to_text($content, $format)
/** /**
* Return tagstring to store in the database based on $tags as an array or a comma-separated string. * Return tagstring to store in the database based on $tags as an array or a comma-separated string.
* @param $tags * @param array|string $tags
* @return mixed|string * @return string
*/ */
function qa_post_tags_to_tagstring($tags) function qa_post_tags_to_tagstring($tags)
{ {
...@@ -429,7 +429,7 @@ function qa_post_tags_to_tagstring($tags) ...@@ -429,7 +429,7 @@ function qa_post_tags_to_tagstring($tags)
/** /**
* Return the full database records for all answers to question $questionid * Return the full database records for all answers to question $questionid
* @param $questionid * @param int $questionid
* @return array * @return array
*/ */
function qa_post_get_question_answers($questionid) function qa_post_get_question_answers($questionid)
...@@ -449,7 +449,7 @@ function qa_post_get_question_answers($questionid) ...@@ -449,7 +449,7 @@ function qa_post_get_question_answers($questionid)
/** /**
* Return the full database records for all comments or follow-on questions for question $questionid or its answers * Return the full database records for all comments or follow-on questions for question $questionid or its answers
* @param $questionid * @param int $questionid
* @return array * @return array
*/ */
function qa_post_get_question_commentsfollows($questionid) function qa_post_get_question_commentsfollows($questionid)
...@@ -477,8 +477,8 @@ function qa_post_get_question_commentsfollows($questionid) ...@@ -477,8 +477,8 @@ function qa_post_get_question_commentsfollows($questionid)
/** /**
* Return the full database record for the post which closed $questionid, if there is any * Return the full database record for the post which closed $questionid, if there is any
* @param $questionid * @param int $questionid
* @return array|mixed * @return array|null
*/ */
function qa_post_get_question_closepost($questionid) function qa_post_get_question_closepost($questionid)
{ {
...@@ -488,7 +488,7 @@ function qa_post_get_question_closepost($questionid) ...@@ -488,7 +488,7 @@ function qa_post_get_question_closepost($questionid)
/** /**
* Return the full database records for all comments or follow-on questions for answer $answerid * Return the full database records for all comments or follow-on questions for answer $answerid
* @param $answerid * @param int $answerid
* @return array * @return array
*/ */
function qa_post_get_answer_commentsfollows($answerid) function qa_post_get_answer_commentsfollows($answerid)
...@@ -508,8 +508,8 @@ function qa_post_get_answer_commentsfollows($answerid) ...@@ -508,8 +508,8 @@ function qa_post_get_answer_commentsfollows($answerid)
/** /**
* Return $parent if it's the database record for a question, otherwise return the database record for its parent * Return $parent if it's the database record for a question, otherwise return the database record for its parent
* @param $parent * @param array $parent
* @return array|mixed * @return array
*/ */
function qa_post_parent_to_question($parent) function qa_post_parent_to_question($parent)
{ {
......
...@@ -37,21 +37,21 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -37,21 +37,21 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
* page has an RSS feed whose URL uses that prefix. If there are no links to other pages, $suggest * page has an RSS feed whose URL uses that prefix. If there are no links to other pages, $suggest
* is used to suggest what the user should do. The $pagelinkparams are passed through to * is used to suggest what the user should do. The $pagelinkparams are passed through to
* qa_html_page_links(...) which creates links for page 2, 3, etc.. * qa_html_page_links(...) which creates links for page 2, 3, etc..
* @param $questions * @param array $questions
* @param $pagesize * @param int|null $pagesize
* @param $start * @param int $start
* @param $count * @param int|null $count
* @param $sometitle * @param string $sometitle
* @param $nonetitle * @param string $nonetitle
* @param $navcategories * @param array $navcategories
* @param $categoryid * @param int|null $categoryid
* @param $categoryqcount * @param bool $categoryqcount
* @param $categorypathprefix * @param string|null $categorypathprefix
* @param $feedpathprefix * @param string|null $feedpathprefix
* @param $suggest * @param string $suggest
* @param $pagelinkparams * @param array|null $pagelinkparams
* @param $categoryparams * @param array|null$categoryparams
* @param $dummy * @param null $dummy
* @return array * @return array
*/ */
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle,
...@@ -153,8 +153,8 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl ...@@ -153,8 +153,8 @@ function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitl
/** /**
* Return the sub navigation structure common to question listing pages * Return the sub navigation structure common to question listing pages
* @param $sort * @param string $sort
* @param $categoryslugs * @param array|null $categoryslugs
* @return array * @return array
*/ */
function qa_qs_sub_navigation($sort, $categoryslugs) function qa_qs_sub_navigation($sort, $categoryslugs)
...@@ -210,8 +210,8 @@ function qa_qs_sub_navigation($sort, $categoryslugs) ...@@ -210,8 +210,8 @@ function qa_qs_sub_navigation($sort, $categoryslugs)
/** /**
* Return the sub navigation structure common to unanswered pages * Return the sub navigation structure common to unanswered pages
* @param $by * @param string $by
* @param $categoryslugs * @param array|null $categoryslugs
* @return array * @return array
*/ */
function qa_unanswered_sub_navigation($by, $categoryslugs) function qa_unanswered_sub_navigation($by, $categoryslugs)
......
...@@ -78,7 +78,7 @@ require_once QA_INCLUDE_DIR . 'app/post-update.php'; ...@@ -78,7 +78,7 @@ require_once QA_INCLUDE_DIR . 'app/post-update.php';
/** /**
* Advance the recalculation operation represented by $state by a single step. * Advance the recalculation operation represented by $state by a single step.
* $state can also be the name of a recalculation operation on its own. * $state can also be the name of a recalculation operation on its own.
* @param $state * @param string $state
* @return bool * @return bool
*/ */
function qa_recalc_perform_step(&$state) function qa_recalc_perform_step(&$state)
...@@ -574,8 +574,8 @@ function qa_recalc_perform_step(&$state) ...@@ -574,8 +574,8 @@ function qa_recalc_perform_step(&$state)
/** /**
* Change the $state to represent the beginning of a new $operation * Change the $state to represent the beginning of a new $operation
* @param $state * @param string $state
* @param $operation * @param string $operation
*/ */
function qa_recalc_transition(&$state, $operation) function qa_recalc_transition(&$state, $operation)
{ {
...@@ -589,7 +589,7 @@ function qa_recalc_transition(&$state, $operation) ...@@ -589,7 +589,7 @@ function qa_recalc_transition(&$state, $operation)
/** /**
* Return how many steps there will be in recalculation $operation * Return how many steps there will be in recalculation $operation
* @param $operation * @param string $operation
* @return int * @return int
*/ */
function qa_recalc_stage_length($operation) function qa_recalc_stage_length($operation)
...@@ -664,11 +664,9 @@ function qa_recalc_stage_length($operation) ...@@ -664,11 +664,9 @@ function qa_recalc_stage_length($operation)
/** /**
* Return the translated language ID string replacing the progress and total in it. * Return the translated language ID string replacing the progress and total in it.
* @access private
* @param string $langId Language string ID that contains 2 placeholders (^1 and ^2) * @param string $langId Language string ID that contains 2 placeholders (^1 and ^2)
* @param int $progress Amount of processed elements * @param int $progress Amount of processed elements
* @param int $total Total amount of elements * @param int $total Total amount of elements
*
* @return string Returns the language string ID with their placeholders replaced with * @return string Returns the language string ID with their placeholders replaced with
* the formatted progress and total numbers * the formatted progress and total numbers
*/ */
...@@ -683,7 +681,7 @@ function qa_recalc_progress_lang($langId, $progress, $total) ...@@ -683,7 +681,7 @@ function qa_recalc_progress_lang($langId, $progress, $total)
/** /**
* Return a string which gives a user-viewable version of $state * Return a string which gives a user-viewable version of $state
* @param $state * @param string $state
* @return string * @return string
*/ */
function qa_recalc_get_message($state) function qa_recalc_get_message($state)
......
...@@ -30,13 +30,13 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -30,13 +30,13 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
* to get absolute URLs for the results and $fullcontent if the results should include full post content. This calls * to get absolute URLs for the results and $fullcontent if the results should include full post content. This calls
* through to the chosen search module, and performs all the necessary post-processing to supplement the results for * through to the chosen search module, and performs all the necessary post-processing to supplement the results for
* display online or in an RSS feed. * display online or in an RSS feed.
* @param $query * @param string $query
* @param $start * @param int $start
* @param $count * @param int $count
* @param $userid * @param mixed $userid
* @param $absoluteurls * @param bool $absoluteurls
* @param $fullcontent * @param bool $fullcontent
* @return * @return array
*/ */
function qa_get_search_results($query, $start, $count, $userid, $absoluteurls, $fullcontent) function qa_get_search_results($query, $start, $count, $userid, $absoluteurls, $fullcontent)
{ {
......
...@@ -55,12 +55,12 @@ function qa_get_max_upload_size() ...@@ -55,12 +55,12 @@ function qa_get_max_upload_size()
* 'height' => if an image, the height in pixels of the blob created (after possible scaling) * 'height' => if an image, the height in pixels of the blob created (after possible scaling)
* 'blobid' => the blobid that was created (if there was no error) * 'blobid' => the blobid that was created (if there was no error)
* 'bloburl' => the url that can be used to view/download the created blob (if there was no error) * 'bloburl' => the url that can be used to view/download the created blob (if there was no error)
* @param $localfilename * @param string $localfilename
* @param $sourcefilename * @param string $sourcefilename
* @param $maxfilesize * @param int|null $maxfilesize
* @param bool $onlyimage * @param bool $onlyimage
* @param $imagemaxwidth * @param int|null $imagemaxwidth
* @param $imagemaxheight * @param int|null $imagemaxheight
* @return array * @return array
*/ */
function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $onlyimage = false, $imagemaxwidth = null, $imagemaxheight = null) function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $onlyimage = false, $imagemaxwidth = null, $imagemaxheight = null)
...@@ -197,10 +197,10 @@ function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $o ...@@ -197,10 +197,10 @@ function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $o
/** /**
* In response to a file upload, move the first uploaded file into blob storage. Other parameters are as for qa_upload_file(...) * In response to a file upload, move the first uploaded file into blob storage. Other parameters are as for qa_upload_file(...)
* @param $maxfilesize * @param int|null $maxfilesize
* @param bool $onlyimage * @param bool $onlyimage
* @param $imagemaxwidth * @param int|null $imagemaxwidth
* @param $imagemaxheight * @param int|null $imagemaxheight
* @return array * @return array
*/ */
function qa_upload_file_one($maxfilesize = null, $onlyimage = false, $imagemaxwidth = null, $imagemaxheight = null) function qa_upload_file_one($maxfilesize = null, $onlyimage = false, $imagemaxwidth = null, $imagemaxheight = null)
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
use Q2A\Exceptions\FatalErrorException;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../'); header('Location: ../../');
exit; exit;
...@@ -39,9 +41,9 @@ if (!defined('QA_NEW_PASSWORD_LEN')){ ...@@ -39,9 +41,9 @@ if (!defined('QA_NEW_PASSWORD_LEN')){
/** /**
* Return $errors fields for any invalid aspect of user-entered $handle (username) and $email. Works by calling through * Return $errors fields for any invalid aspect of user-entered $handle (username) and $email. Works by calling through
* to all filter modules and also rejects existing values in database unless they belongs to $olduser (if set). * to all filter modules and also rejects existing values in database unless they belongs to $olduser (if set).
* @param $handle * @param string $handle
* @param $email * @param string $email
* @param $olduser * @param array $olduser
* @return array * @return array
*/ */
function qa_handle_email_filter(&$handle, &$email, $olduser = null) function qa_handle_email_filter(&$handle, &$email, $olduser = null)
...@@ -93,7 +95,7 @@ function qa_handle_email_filter(&$handle, &$email, $olduser = null) ...@@ -93,7 +95,7 @@ function qa_handle_email_filter(&$handle, &$email, $olduser = null)
/** /**
* Make $handle valid and unique in the database - if $allowuserid is set, allow it to match that user only * Make $handle valid and unique in the database - if $allowuserid is set, allow it to match that user only
* @param $handle * @param string $handle
* @return string * @return string
*/ */
function qa_handle_make_valid($handle) function qa_handle_make_valid($handle)
...@@ -139,8 +141,8 @@ function qa_handle_make_valid($handle) ...@@ -139,8 +141,8 @@ function qa_handle_make_valid($handle)
/** /**
* Return an array with a single element (key 'password') if user-entered $password is valid, otherwise an empty array. * Return an array with a single element (key 'password') if user-entered $password is valid, otherwise an empty array.
* Works by calling through to all filter modules. * Works by calling through to all filter modules.
* @param $password * @param string $password
* @param $olduser * @param array $olduser
* @return array * @return array
*/ */
function qa_password_validate($password, $olduser = null) function qa_password_validate($password, $olduser = null)
...@@ -171,9 +173,9 @@ function qa_password_validate($password, $olduser = null) ...@@ -171,9 +173,9 @@ function qa_password_validate($password, $olduser = null)
* Create a new user (application level) with $email, $password, $handle and $level. * Create a new user (application level) with $email, $password, $handle and $level.
* Set $confirmed to true if the email address has been confirmed elsewhere. * Set $confirmed to true if the email address has been confirmed elsewhere.
* Handles user points, notification and optional email confirmation. * Handles user points, notification and optional email confirmation.
* @param $email * @param string $email
* @param $password * @param string|null $password
* @param $handle * @param string $handle
* @param int $level * @param int $level
* @param bool $confirmed * @param bool $confirmed
* @return mixed * @return mixed
...@@ -232,7 +234,7 @@ function qa_create_new_user($email, $password, $handle, $level = QA_USER_LEVEL_B ...@@ -232,7 +234,7 @@ function qa_create_new_user($email, $password, $handle, $level = QA_USER_LEVEL_B
/** /**
* Delete $userid and all their votes and flags. Their posts will become anonymous. * Delete $userid and all their votes and flags. Their posts will become anonymous.
* Handles recalculations of votes and flags for posts this user has affected. * Handles recalculations of votes and flags for posts this user has affected.
* @param $userid * @param mixed $userid
* @return mixed * @return mixed
*/ */
function qa_delete_user($userid) function qa_delete_user($userid)
...@@ -265,7 +267,7 @@ function qa_delete_user($userid) ...@@ -265,7 +267,7 @@ function qa_delete_user($userid)
/** /**
* Set a new email confirmation code for the user and send it out * Set a new email confirmation code for the user and send it out
* @param $userid * @param mixed $userid
* @return mixed * @return mixed
*/ */
function qa_send_new_confirm($userid) function qa_send_new_confirm($userid)
...@@ -292,10 +294,10 @@ function qa_send_new_confirm($userid) ...@@ -292,10 +294,10 @@ function qa_send_new_confirm($userid)
/** /**
* Set a new email confirmation code for the user and return the corresponding link. If the email code is also sent then that value * Set a new email confirmation code for the user and return the corresponding link. If the email code is also sent then that value
* is used. Otherwise, a new email code is generated * is used. Otherwise, a new email code is generated
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $emailcode * @param string $emailcode
* @return mixed|string * @return string
*/ */
function qa_get_new_confirm_url($userid, $handle, $emailcode = null) function qa_get_new_confirm_url($userid, $handle, $emailcode = null)
{ {
...@@ -314,9 +316,9 @@ function qa_get_new_confirm_url($userid, $handle, $emailcode = null) ...@@ -314,9 +316,9 @@ function qa_get_new_confirm_url($userid, $handle, $emailcode = null)
/** /**
* Complete the email confirmation process for the user * Complete the email confirmation process for the user
* @param $userid * @param mixed $userid
* @param $email * @param string $email
* @param $handle * @param string $handle
* @return mixed * @return mixed
*/ */
function qa_complete_confirm($userid, $email, $handle) function qa_complete_confirm($userid, $email, $handle)
...@@ -339,10 +341,10 @@ function qa_complete_confirm($userid, $email, $handle) ...@@ -339,10 +341,10 @@ function qa_complete_confirm($userid, $email, $handle)
/** /**
* Set the user level of user $userid with $handle to $level (one of the QA_USER_LEVEL_* constraints in /qa-include/app/users.php) * Set the user level of user $userid with $handle to $level (one of the QA_USER_LEVEL_* constraints in /qa-include/app/users.php)
* Pass the previous user level in $oldlevel. Reports the appropriate event, assumes change performed by the logged in user. * Pass the previous user level in $oldlevel. Reports the appropriate event, assumes change performed by the logged in user.
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $level * @param int $level
* @param $oldlevel * @param int $oldlevel
*/ */
function qa_set_user_level($userid, $handle, $level, $oldlevel) function qa_set_user_level($userid, $handle, $level, $oldlevel)
{ {
...@@ -368,9 +370,9 @@ function qa_set_user_level($userid, $handle, $level, $oldlevel) ...@@ -368,9 +370,9 @@ function qa_set_user_level($userid, $handle, $level, $oldlevel)
/** /**
* Set the status of user $userid with $handle to blocked if $blocked is true, otherwise to unblocked. Reports the appropriate * Set the status of user $userid with $handle to blocked if $blocked is true, otherwise to unblocked. Reports the appropriate
* event, assumes change performed by the logged in user. * event, assumes change performed by the logged in user.
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $blocked * @param string $blocked
*/ */
function qa_set_user_blocked($userid, $handle, $blocked) function qa_set_user_blocked($userid, $handle, $blocked)
{ {
...@@ -388,7 +390,7 @@ function qa_set_user_blocked($userid, $handle, $blocked) ...@@ -388,7 +390,7 @@ function qa_set_user_blocked($userid, $handle, $blocked)
/** /**
* Start the 'I forgot my password' process for $userid, sending reset code * Start the 'I forgot my password' process for $userid, sending reset code
* @param $userid * @param mixed $userid
* @return mixed * @return mixed
*/ */
function qa_start_reset_user($userid) function qa_start_reset_user($userid)
...@@ -415,9 +417,8 @@ function qa_start_reset_user($userid) ...@@ -415,9 +417,8 @@ function qa_start_reset_user($userid)
/** /**
* Successfully finish the 'I forgot my password' process for $userid, sending new password * Successfully finish the 'I forgot my password' process for $userid, sending new password
*
* @deprecated This function has been replaced by qa_finish_reset_user since Q2A 1.8 * @deprecated This function has been replaced by qa_finish_reset_user since Q2A 1.8
* @param $userid * @param mixed $userid
* @return mixed * @return mixed
*/ */
function qa_complete_reset_user($userid) function qa_complete_reset_user($userid)
...@@ -454,7 +455,7 @@ function qa_complete_reset_user($userid) ...@@ -454,7 +455,7 @@ function qa_complete_reset_user($userid)
* Successfully finish the 'I forgot my password' process for $userid, cleaning the emailcode field and logging in the user * Successfully finish the 'I forgot my password' process for $userid, cleaning the emailcode field and logging in the user
* @param mixed $userId The userid identifiying the user who will have the password reset * @param mixed $userId The userid identifiying the user who will have the password reset
* @param string $newPassword The new password for the user * @param string $newPassword The new password for the user
* @return void * @return mixed
*/ */
function qa_finish_reset_user($userId, $newPassword) function qa_finish_reset_user($userId, $newPassword)
{ {
...@@ -501,9 +502,9 @@ function qa_logged_in_user_flush() ...@@ -501,9 +502,9 @@ function qa_logged_in_user_flush()
/** /**
* Set the avatar of $userid to the image in $imagedata, and remove $oldblobid from the database if not null * Set the avatar of $userid to the image in $imagedata, and remove $oldblobid from the database if not null
* @param $userid * @param mixed $userid
* @param $imagedata * @param string $imagedata
* @param $oldblobid * @param string $oldblobid
* @return bool * @return bool
*/ */
function qa_set_user_avatar($userid, $imagedata, $oldblobid = null) function qa_set_user_avatar($userid, $imagedata, $oldblobid = null)
......
...@@ -92,8 +92,8 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -92,8 +92,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Return $field of the currently logged in user, or null if not available * Return $field of the currently logged in user, or null if not available
* @param $field * @param string $field
* @return null * @return string|null
*/ */
function qa_get_logged_in_user_field($field) function qa_get_logged_in_user_field($field)
{ {
...@@ -131,10 +131,10 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -131,10 +131,10 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Return HTML to display for the avatar of $userid, constrained to $size pixels, with optional $padding to that size * Return HTML to display for the avatar of $userid, constrained to $size pixels, with optional $padding to that size
* @param $userid * @param mixed $userid
* @param $size * @param int|null $size
* @param bool $padding * @param bool $padding
* @return mixed|null|string * @return string|null
*/ */
function qa_get_external_avatar_html($userid, $size, $padding = false) function qa_get_external_avatar_html($userid, $size, $padding = false)
{ {
...@@ -183,8 +183,8 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -183,8 +183,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Returns a verification code used to ensure that a user session can't be generated by another PHP script running on the same server * Returns a verification code used to ensure that a user session can't be generated by another PHP script running on the same server
* @param $userid * @param int $userid
* @return mixed|string * @return string
*/ */
function qa_session_verify_code($userid) function qa_session_verify_code($userid)
{ {
...@@ -197,9 +197,9 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -197,9 +197,9 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Set cookie in browser for username $handle with $sessioncode (in database). * Set cookie in browser for username $handle with $sessioncode (in database).
* Pass true if user checked 'Remember me' (either now or previously, as learned from cookie). * Pass true if user checked 'Remember me' (either now or previously, as learned from cookie).
* @param $handle * @param string $handle
* @param $sessioncode * @param string $sessioncode
* @param $remember * @param bool $remember
* @return mixed * @return mixed
*/ */
function qa_set_session_cookie($handle, $sessioncode, $remember) function qa_set_session_cookie($handle, $sessioncode, $remember)
...@@ -224,8 +224,8 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -224,8 +224,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Set the session variables to indicate that $userid is logged in from $source * Set the session variables to indicate that $userid is logged in from $source
* @param $userid * @param int $userid
* @param $source * @param string|null $source
* @return mixed * @return mixed
*/ */
function qa_set_session_user($userid, $source) function qa_set_session_user($userid, $source)
...@@ -259,10 +259,10 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -259,10 +259,10 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Call for successful log in by $userid and $handle or successful log out with $userid=null. * Call for successful log in by $userid and $handle or successful log out with $userid=null.
* $remember states if 'Remember me' was checked in the login form. * $remember states if 'Remember me' was checked in the login form.
* @param $userid * @param int|null $userid
* @param string $handle * @param string $handle
* @param bool $remember * @param bool $remember
* @param $source * @param string|null $source
* @return mixed * @return mixed
*/ */
function qa_set_logged_in_user($userid, $handle = '', $remember = false, $source = null) function qa_set_logged_in_user($userid, $handle = '', $remember = false, $source = null)
...@@ -316,9 +316,9 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -316,9 +316,9 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Call to log in a user based on an external identity provider $source with external $identifier * Call to log in a user based on an external identity provider $source with external $identifier
* A new user is created based on $fields if it's a new combination of $source and $identifier * A new user is created based on $fields if it's a new combination of $source and $identifier
* @param $source * @param string $source
* @param $identifier * @param string $identifier
* @param $fields * @param array $fields
* @return mixed * @return mixed
*/ */
function qa_log_in_external_user($source, $identifier, $fields) function qa_log_in_external_user($source, $identifier, $fields)
...@@ -483,8 +483,8 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -483,8 +483,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Return $field of the currently logged in user * Return $field of the currently logged in user
* @param $field * @param string $field
* @return mixed|null * @return string|null
*/ */
function qa_get_logged_in_user_field($field) function qa_get_logged_in_user_field($field)
{ {
...@@ -533,7 +533,7 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -533,7 +533,7 @@ if (QA_FINAL_EXTERNAL_USERS) {
require_once QA_INCLUDE_DIR . 'util/image.php'; require_once QA_INCLUDE_DIR . 'util/image.php';
if (strlen($blobId) == 0 || (isset($size) && (int)$size <= 0)) { if (strlen($blobId) == 0 || (isset($size) && $size <= 0)) {
return null; return null;
} }
...@@ -550,7 +550,6 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -550,7 +550,6 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Get HTML to display a username, linked to their user page. * Get HTML to display a username, linked to their user page.
*
* @param string $handle The username. * @param string $handle The username.
* @param bool $microdata Whether to include microdata. * @param bool $microdata Whether to include microdata.
* @param bool $favorited Show the user as favorited. * @param bool $favorited Show the user as favorited.
...@@ -609,13 +608,12 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -609,13 +608,12 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Return the avatar URL, either Gravatar or from a blob ID, constrained to $size pixels. * Return the avatar URL, either Gravatar or from a blob ID, constrained to $size pixels.
*
* @param int $flags The user's flags * @param int $flags The user's flags
* @param string $email The user's email. Only needed to return the Gravatar link * @param string $email The user's email. Only needed to return the Gravatar link
* @param string $blobId The blob ID. Only needed to return the locally stored avatar * @param string $blobId The blob ID. Only needed to return the locally stored avatar
* @param int $size The size to constrain the final image * @param int|null $size The size to constrain the final image
* @param bool $absolute Whether the link returned should be absolute or relative * @param bool $absolute Whether the link returned should be absolute or relative
* @return null|string The URL to the user's avatar or null if none could be found (not even as a default site avatar) * @return string|null The URL to the user's avatar or null if none could be found (not even as a default site avatar)
*/ */
function qa_get_user_avatar_url($flags, $email, $blobId, $size = null, $absolute = false) function qa_get_user_avatar_url($flags, $email, $blobId, $size = null, $absolute = false)
{ {
...@@ -638,7 +636,6 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -638,7 +636,6 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Return HTML to display for the user's avatar, constrained to $size pixels, with optional $padding to that size * Return HTML to display for the user's avatar, constrained to $size pixels, with optional $padding to that size
*
* @param int $flags The user's flags * @param int $flags The user's flags
* @param string $email The user's email. Only needed to return the Gravatar HTML * @param string $email The user's email. Only needed to return the Gravatar HTML
* @param string $blobId The blob ID. Only needed to return the locally stored avatar HTML * @param string $blobId The blob ID. Only needed to return the locally stored avatar HTML
...@@ -680,7 +677,7 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -680,7 +677,7 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Return email address for user $userid (if not using single sign-on integration) * Return email address for user $userid (if not using single sign-on integration)
* @param $userid * @param int $userid
* @return string * @return string
*/ */
function qa_get_user_email($userid) function qa_get_user_email($userid)
...@@ -693,8 +690,8 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -693,8 +690,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Called after a database write $action performed by a user $userid * Called after a database write $action performed by a user $userid
* @param $userid * @param int $userid
* @param $action * @param string $action
* @return mixed * @return mixed
*/ */
function qa_user_report_action($userid, $action) function qa_user_report_action($userid, $action)
...@@ -709,8 +706,8 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -709,8 +706,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Return textual representation of the user $level * Return textual representation of the user $level
* @param $level * @param int $level
* @return mixed|string * @return string
*/ */
function qa_user_level_string($level) function qa_user_level_string($level)
{ {
...@@ -737,8 +734,8 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -737,8 +734,8 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Return an array of links to login, register, email confirm and logout pages (if not using single sign-on integration) * Return an array of links to login, register, email confirm and logout pages (if not using single sign-on integration)
* @param $rooturl * @param string $rooturl
* @param $tourl * @param string|null $tourl
* @return array * @return array
*/ */
function qa_get_login_links($rooturl, $tourl) function qa_get_login_links($rooturl, $tourl)
...@@ -756,6 +753,7 @@ if (QA_FINAL_EXTERNAL_USERS) { ...@@ -756,6 +753,7 @@ if (QA_FINAL_EXTERNAL_USERS) {
/** /**
* Return whether someone is logged in at the moment * Return whether someone is logged in at the moment
* @return bool
*/ */
function qa_is_logged_in() function qa_is_logged_in()
{ {
...@@ -766,6 +764,7 @@ function qa_is_logged_in() ...@@ -766,6 +764,7 @@ function qa_is_logged_in()
/** /**
* Return displayable handle/username of currently logged in user, or null if none * Return displayable handle/username of currently logged in user, or null if none
* @return string
*/ */
function qa_get_logged_in_handle() function qa_get_logged_in_handle()
{ {
...@@ -775,6 +774,7 @@ function qa_get_logged_in_handle() ...@@ -775,6 +774,7 @@ function qa_get_logged_in_handle()
/** /**
* Return email of currently logged in user, or null if none * Return email of currently logged in user, or null if none
* @return string
*/ */
function qa_get_logged_in_email() function qa_get_logged_in_email()
{ {
...@@ -784,6 +784,7 @@ function qa_get_logged_in_email() ...@@ -784,6 +784,7 @@ function qa_get_logged_in_email()
/** /**
* Return level of currently logged in user, or null if none * Return level of currently logged in user, or null if none
* @return string
*/ */
function qa_get_logged_in_level() function qa_get_logged_in_level()
{ {
...@@ -793,6 +794,7 @@ function qa_get_logged_in_level() ...@@ -793,6 +794,7 @@ function qa_get_logged_in_level()
/** /**
* Return flags (see QA_USER_FLAGS_*) of currently logged in user, or null if none * Return flags (see QA_USER_FLAGS_*) of currently logged in user, or null if none
* @return string
*/ */
function qa_get_logged_in_flags() function qa_get_logged_in_flags()
{ {
...@@ -805,6 +807,7 @@ function qa_get_logged_in_flags() ...@@ -805,6 +807,7 @@ function qa_get_logged_in_flags()
/** /**
* Return an array of all the specific (e.g. per category) level privileges for the logged in user, retrieving from the database if necessary * Return an array of all the specific (e.g. per category) level privileges for the logged in user, retrieving from the database if necessary
* @return array
*/ */
function qa_get_logged_in_levels() function qa_get_logged_in_levels()
{ {
...@@ -816,7 +819,7 @@ function qa_get_logged_in_levels() ...@@ -816,7 +819,7 @@ function qa_get_logged_in_levels()
/** /**
* Return an array mapping each userid in $userids to that user's handle (public username), or to null if not found * Return an array mapping each userid in $userids to that user's handle (public username), or to null if not found
* @param $userids * @param array $userids
* @return array * @return array
*/ */
function qa_userids_to_handles($userids) function qa_userids_to_handles($userids)
...@@ -839,7 +842,7 @@ function qa_userids_to_handles($userids) ...@@ -839,7 +842,7 @@ function qa_userids_to_handles($userids)
/** /**
* Return an string mapping the received userid to that user's handle (public username), or to null if not found * Return an string mapping the received userid to that user's handle (public username), or to null if not found
* @param $userid * @param array $userid
* @return mixed|null * @return mixed|null
*/ */
function qa_userid_to_handle($userid) function qa_userid_to_handle($userid)
...@@ -853,7 +856,7 @@ function qa_userid_to_handle($userid) ...@@ -853,7 +856,7 @@ function qa_userid_to_handle($userid)
* Return an array mapping each handle in $handles the user's userid, or null if not found. If $exactonly is true then * Return an array mapping each handle in $handles the user's userid, or null if not found. If $exactonly is true then
* $handles must have the correct case and accents. Otherwise, handles are case- and accent-insensitive, and the keys * $handles must have the correct case and accents. Otherwise, handles are case- and accent-insensitive, and the keys
* of the returned array will match the $handles provided, not necessary those in the DB. * of the returned array will match the $handles provided, not necessary those in the DB.
* @param $handles * @param array $handles
* @param bool $exactonly * @param bool $exactonly
* @return array * @return array
*/ */
...@@ -890,7 +893,7 @@ function qa_handles_to_userids($handles, $exactonly = false) ...@@ -890,7 +893,7 @@ function qa_handles_to_userids($handles, $exactonly = false)
/** /**
* Return the userid corresponding to $handle (not case- or accent-sensitive) * Return the userid corresponding to $handle (not case- or accent-sensitive)
* @param $handle * @param string $handle
* @return mixed|null * @return mixed|null
*/ */
function qa_handle_to_userid($handle) function qa_handle_to_userid($handle)
...@@ -912,7 +915,7 @@ function qa_handle_to_userid($handle) ...@@ -912,7 +915,7 @@ function qa_handle_to_userid($handle)
/** /**
* Return the level of the logged in user for a post with $categoryids (expressing the full hierarchy to the final category) * Return the level of the logged in user for a post with $categoryids (expressing the full hierarchy to the final category)
* @param $categoryids * @param array $categoryids
* @return mixed|null * @return mixed|null
*/ */
function qa_user_level_for_categories($categoryids) function qa_user_level_for_categories($categoryids)
...@@ -943,8 +946,8 @@ function qa_user_level_for_categories($categoryids) ...@@ -943,8 +946,8 @@ function qa_user_level_for_categories($categoryids)
/** /**
* Return the level of the logged in user for $post, as retrieved from the database * Return the level of the logged in user for $post, as retrieved from the database
* @param $post * @param array $post
* @return mixed|null * @return int|null
*/ */
function qa_user_level_for_post($post) function qa_user_level_for_post($post)
{ {
...@@ -959,6 +962,7 @@ function qa_user_level_for_post($post) ...@@ -959,6 +962,7 @@ function qa_user_level_for_post($post)
/** /**
* Return the maximum possible level of the logged in user in any context (i.e. for any category) * Return the maximum possible level of the logged in user in any context (i.e. for any category)
* @return int
*/ */
function qa_user_level_maximum() function qa_user_level_maximum()
{ {
...@@ -978,9 +982,9 @@ function qa_user_level_maximum() ...@@ -978,9 +982,9 @@ function qa_user_level_maximum()
/** /**
* Check whether the logged in user has permission to perform $permitoption on post $post (from the database) * Check whether the logged in user has permission to perform $permitoption on post $post (from the database)
* Other parameters and the return value are as for qa_user_permit_error(...) * Other parameters and the return value are as for qa_user_permit_error(...)
* @param $permitoption * @param string $permitoption
* @param $post * @param array $post
* @param $limitaction * @param string|null $limitaction
* @param bool $checkblocks * @param bool $checkblocks
* @return bool|string * @return bool|string
*/ */
...@@ -993,8 +997,8 @@ function qa_user_post_permit_error($permitoption, $post, $limitaction = null, $c ...@@ -993,8 +997,8 @@ function qa_user_post_permit_error($permitoption, $post, $limitaction = null, $c
/** /**
* Check whether the logged in user would have permittion to perform $permitoption in any context (i.e. for any category) * Check whether the logged in user would have permittion to perform $permitoption in any context (i.e. for any category)
* Other parameters and the return value are as for qa_user_permit_error(...) * Other parameters and the return value are as for qa_user_permit_error(...)
* @param $permitoption * @param string $permitoption
* @param $limitaction * @param string|null $limitaction
* @param bool $checkblocks * @param bool $checkblocks
* @return bool|string * @return bool|string
*/ */
...@@ -1006,14 +1010,12 @@ function qa_user_maximum_permit_error($permitoption, $limitaction = null, $check ...@@ -1006,14 +1010,12 @@ function qa_user_maximum_permit_error($permitoption, $limitaction = null, $check
/** /**
* Check whether the logged in user has permission to perform an action. * Check whether the logged in user has permission to perform an action.
* * @param string|null $permitoption The permission to check (if null, this simply checks whether the user is blocked).
* @param string $permitoption The permission to check (if null, this simply checks whether the user is blocked). * @param string|null $limitaction Constant from /qa-include/app/limits.php to check against user or IP rate limits.
* @param string $limitaction Constant from /qa-include/app/limits.php to check against user or IP rate limits. * @param int|null $userlevel A QA_USER_LEVEL_* constant to consider the user at a different level to usual (e.g. if
* @param int $userlevel A QA_USER_LEVEL_* constant to consider the user at a different level to usual (e.g. if
* they are performing this action in a category for which they have elevated privileges). * they are performing this action in a category for which they have elevated privileges).
* @param bool $checkblocks Whether to check the user's blocked status. * @param bool $checkblocks Whether to check the user's blocked status.
* @param array $userfields Cache for logged in user, containing keys 'userid', 'level' (optional), 'flags'. * @param array|null $userfields Cache for logged in user, containing keys 'userid', 'level' (optional), 'flags'.
*
* @return bool|string The permission error, or false if no error. Possible errors, in order of priority: * @return bool|string The permission error, or false if no error. Possible errors, in order of priority:
* 'login' => the user should login or register * 'login' => the user should login or register
* 'level' => a special privilege level (e.g. expert) or minimum number of points is required * 'level' => a special privilege level (e.g. expert) or minimum number of points is required
...@@ -1061,13 +1063,11 @@ function qa_user_permit_error($permitoption = null, $limitaction = null, $userle ...@@ -1061,13 +1063,11 @@ function qa_user_permit_error($permitoption = null, $limitaction = null, $userle
/** /**
* Check whether user can perform $permitoption. Result as for qa_user_permit_error(...). * Check whether user can perform $permitoption. Result as for qa_user_permit_error(...).
* * @param string|null $permitoption Permission option name (from database) for action.
* @param string $permitoption Permission option name (from database) for action. * @param int|null $userid ID of user (null for no user).
* @param int $userid ID of user (null for no user). * @param int|null $userlevel Level to check against.
* @param int $userlevel Level to check against. * @param int|null $userflags Flags for this user.
* @param int $userflags Flags for this user. * @param int|null $userpoints User's points: if $userid is currently logged in, you can set $userpoints=null to retrieve them only if necessary.
* @param int $userpoints User's points: if $userid is currently logged in, you can set $userpoints=null to retrieve them only if necessary.
*
* @return string|bool Reason the user is not permitted, or false if the operation can go ahead. * @return string|bool Reason the user is not permitted, or false if the operation can go ahead.
*/ */
function qa_permit_error($permitoption, $userid, $userlevel, $userflags, $userpoints = null) function qa_permit_error($permitoption, $userid, $userlevel, $userflags, $userpoints = null)
...@@ -1096,12 +1096,10 @@ function qa_permit_error($permitoption, $userid, $userlevel, $userflags, $userpo ...@@ -1096,12 +1096,10 @@ function qa_permit_error($permitoption, $userid, $userlevel, $userflags, $userpo
/** /**
* Check whether user can reach the permission level. Result as for qa_user_permit_error(...). * Check whether user can reach the permission level. Result as for qa_user_permit_error(...).
*
* @param int $permit Permission constant. * @param int $permit Permission constant.
* @param int $userid ID of user (null for no user). * @param int|null $userid ID of user (null for no user).
* @param int $userlevel Level to check against. * @param int|null $userlevel Level to check against.
* @param int $userflags Flags for this user. * @param int|null $userflags Flags for this user.
*
* @return string|bool Reason the user is not permitted, or false if the operation can go ahead * @return string|bool Reason the user is not permitted, or false if the operation can go ahead
*/ */
function qa_permit_value_error($permit, $userid, $userlevel, $userflags) function qa_permit_value_error($permit, $userid, $userlevel, $userflags)
...@@ -1154,8 +1152,8 @@ function qa_permit_value_error($permit, $userid, $userlevel, $userflags) ...@@ -1154,8 +1152,8 @@ function qa_permit_value_error($permit, $userid, $userlevel, $userflags)
* 'approve' => captcha required because the user has not been approved * 'approve' => captcha required because the user has not been approved
* 'confirm' => captcha required because the user has not confirmed their email address * 'confirm' => captcha required because the user has not confirmed their email address
* false => captcha is not required * false => captcha is not required
* @param $userlevel * @param int|null $userlevel
* @return bool|mixed|string * @return bool|string
*/ */
function qa_user_captcha_reason($userlevel = null) function qa_user_captcha_reason($userlevel = null)
{ {
...@@ -1183,8 +1181,8 @@ function qa_user_captcha_reason($userlevel = null) ...@@ -1183,8 +1181,8 @@ function qa_user_captcha_reason($userlevel = null)
/** /**
* Return whether a captcha should be presented to the logged in user for writing posts. You can pass in a * Return whether a captcha should be presented to the logged in user for writing posts. You can pass in a
* QA_USER_LEVEL_* constant in $userlevel to consider the user at a different level to usual. * QA_USER_LEVEL_* constant in $userlevel to consider the user at a different level to usual.
* @param $userlevel * @param int|null $userlevel
* @return bool|mixed * @return bool|string
*/ */
function qa_user_use_captcha($userlevel = null) function qa_user_use_captcha($userlevel = null)
{ {
...@@ -1205,7 +1203,7 @@ function qa_user_use_captcha($userlevel = null) ...@@ -1205,7 +1203,7 @@ function qa_user_use_captcha($userlevel = null)
* 'confirm' => moderation required because the user has not confirmed their email address * 'confirm' => moderation required because the user has not confirmed their email address
* 'points' => moderation required because the user has insufficient points * 'points' => moderation required because the user has insufficient points
* false => moderation is not required * false => moderation is not required
* @param $userlevel * @param int|null $userlevel
* @return bool|string * @return bool|string
*/ */
function qa_user_moderation_reason($userlevel = null) function qa_user_moderation_reason($userlevel = null)
...@@ -1238,7 +1236,7 @@ function qa_user_moderation_reason($userlevel = null) ...@@ -1238,7 +1236,7 @@ function qa_user_moderation_reason($userlevel = null)
/** /**
* Return the label to display for $userfield as retrieved from the database, using default if no name set * Return the label to display for $userfield as retrieved from the database, using default if no name set
* @param $userfield * @param array $userfield
* @return string * @return string
*/ */
function qa_user_userfield_label($userfield) function qa_user_userfield_label($userfield)
...@@ -1264,6 +1262,7 @@ function qa_user_userfield_label($userfield) ...@@ -1264,6 +1262,7 @@ function qa_user_userfield_label($userfield)
/** /**
* Set or extend the cookie in browser of non logged-in users which identifies them for the purposes of form security (anti-CSRF protection) * Set or extend the cookie in browser of non logged-in users which identifies them for the purposes of form security (anti-CSRF protection)
* @return mixed
*/ */
function qa_set_form_security_key() function qa_set_form_security_key()
{ {
...@@ -1287,9 +1286,9 @@ function qa_set_form_security_key() ...@@ -1287,9 +1286,9 @@ function qa_set_form_security_key()
/** /**
* Return the form security (anti-CSRF protection) hash for an $action (any string), that can be performed within * Return the form security (anti-CSRF protection) hash for an $action (any string), that can be performed within
* QA_FORM_EXPIRY_SECS of $timestamp (in unix seconds) by the current user. * QA_FORM_EXPIRY_SECS of $timestamp (in unix seconds) by the current user.
* @param $action * @param string $action
* @param $timestamp * @param int $timestamp
* @return mixed|string * @return string
*/ */
function qa_calc_form_security_hash($action, $timestamp) function qa_calc_form_security_hash($action, $timestamp)
{ {
...@@ -1307,8 +1306,8 @@ function qa_calc_form_security_hash($action, $timestamp) ...@@ -1307,8 +1306,8 @@ function qa_calc_form_security_hash($action, $timestamp)
/** /**
* Return the full form security (anti-CSRF protection) code for an $action (any string) performed within * Return the full form security (anti-CSRF protection) code for an $action (any string) performed within
* QA_FORM_EXPIRY_SECS of now by the current user. * QA_FORM_EXPIRY_SECS of now by the current user.
* @param $action * @param string $action
* @return mixed|string * @return string
*/ */
function qa_get_form_security_code($action) function qa_get_form_security_code($action)
{ {
...@@ -1325,8 +1324,8 @@ function qa_get_form_security_code($action) ...@@ -1325,8 +1324,8 @@ function qa_get_form_security_code($action)
/** /**
* Return whether $value matches the expected form security (anti-CSRF protection) code for $action (any string) and * Return whether $value matches the expected form security (anti-CSRF protection) code for $action (any string) and
* that the code has not expired (if more than QA_FORM_EXPIRY_SECS have passed). Logs causes for suspicion. * that the code has not expired (if more than QA_FORM_EXPIRY_SECS have passed). Logs causes for suspicion.
* @param $action * @param string $action
* @param $value * @param string|null $value
* @return bool * @return bool
*/ */
function qa_check_form_security_code($action, $value) function qa_check_form_security_code($action, $value)
......
...@@ -28,11 +28,11 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -28,11 +28,11 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Check if $userid can vote on $post, on the page $topage. * Check if $userid can vote on $post, on the page $topage.
* Return an HTML error to display if there was a problem, or false if it's OK. * Return an HTML error to display if there was a problem, or false if it's OK.
* @param $post * @param array $post
* @param $vote * @param int $vote
* @param $userid * @param mixed $userid
* @param $topage * @param string $topage
* @return bool|mixed|string * @return bool|string
*/ */
function qa_vote_error_html($post, $vote, $userid, $topage) function qa_vote_error_html($post, $vote, $userid, $topage)
{ {
...@@ -106,12 +106,12 @@ function qa_vote_error_html($post, $vote, $userid, $topage) ...@@ -106,12 +106,12 @@ function qa_vote_error_html($post, $vote, $userid, $topage)
/** /**
* Actually set (application level) the $vote (-1/0/1) by $userid (with $handle and $cookieid) on $postid. * Actually set (application level) the $vote (-1/0/1) by $userid (with $handle and $cookieid) on $postid.
* Handles user points, recounting and event reports as appropriate. * Handles user points, recounting and event reports as appropriate.
* @param $post * @param array $post
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $vote * @param int $vote
* @return void * @return mixed
*/ */
function qa_vote_set($post, $userid, $handle, $cookieid, $vote) function qa_vote_set($post, $userid, $handle, $cookieid, $vote)
{ {
...@@ -178,10 +178,10 @@ function qa_vote_set($post, $userid, $handle, $cookieid, $vote) ...@@ -178,10 +178,10 @@ function qa_vote_set($post, $userid, $handle, $cookieid, $vote)
/** /**
* Check if $userid can flag $post, on the page $topage. * Check if $userid can flag $post, on the page $topage.
* Return an HTML error to display if there was a problem, or false if it's OK. * Return an HTML error to display if there was a problem, or false if it's OK.
* @param $post * @param array $post
* @param $userid * @param mixed $userid
* @param $topage * @param string $topage
* @return bool|mixed|string * @return bool|string|array
*/ */
function qa_flag_error_html($post, $userid, $topage) function qa_flag_error_html($post, $userid, $topage)
{ {
...@@ -228,11 +228,11 @@ function qa_flag_error_html($post, $userid, $topage) ...@@ -228,11 +228,11 @@ function qa_flag_error_html($post, $userid, $topage)
* Set (application level) a flag by $userid (with $handle and $cookieid) on $oldpost which belongs to $question. * Set (application level) a flag by $userid (with $handle and $cookieid) on $oldpost which belongs to $question.
* Handles recounting, admin notifications and event reports as appropriate. * Handles recounting, admin notifications and event reports as appropriate.
* Returns true if the post should now be hidden because it has accumulated enough flags. * Returns true if the post should now be hidden because it has accumulated enough flags.
* @param $oldpost * @param array $oldpost
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param $question * @param array $question
* @return bool * @return bool
*/ */
function qa_flag_set_tohide($oldpost, $userid, $handle, $cookieid, $question) function qa_flag_set_tohide($oldpost, $userid, $handle, $cookieid, $question)
...@@ -278,10 +278,10 @@ function qa_flag_set_tohide($oldpost, $userid, $handle, $cookieid, $question) ...@@ -278,10 +278,10 @@ function qa_flag_set_tohide($oldpost, $userid, $handle, $cookieid, $question)
/** /**
* Clear (application level) a flag on $oldpost by $userid (with $handle and $cookieid). * Clear (application level) a flag on $oldpost by $userid (with $handle and $cookieid).
* Handles recounting and event reports as appropriate. * Handles recounting and event reports as appropriate.
* @param $oldpost * @param array $oldpost
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @return mixed * @return mixed
*/ */
function qa_flag_clear($oldpost, $userid, $handle, $cookieid) function qa_flag_clear($oldpost, $userid, $handle, $cookieid)
...@@ -320,10 +320,10 @@ function qa_flag_clear($oldpost, $userid, $handle, $cookieid) ...@@ -320,10 +320,10 @@ function qa_flag_clear($oldpost, $userid, $handle, $cookieid)
/** /**
* Clear (application level) all flags on $oldpost by $userid (with $handle and $cookieid). * Clear (application level) all flags on $oldpost by $userid (with $handle and $cookieid).
* Handles recounting and event reports as appropriate. * Handles recounting and event reports as appropriate.
* @param $oldpost * @param array $oldpost
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @return mixed * @return mixed
*/ */
function qa_flags_clear_all($oldpost, $userid, $handle, $cookieid) function qa_flags_clear_all($oldpost, $userid, $handle, $cookieid)
......
...@@ -27,6 +27,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,6 +27,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Return the current version of MySQL * Return the current version of MySQL
* @return string
*/ */
function qa_db_mysql_version() function qa_db_mysql_version()
{ {
...@@ -36,6 +37,7 @@ function qa_db_mysql_version() ...@@ -36,6 +37,7 @@ function qa_db_mysql_version()
/** /**
* Return the total size in bytes of all relevant tables in the Q2A database * Return the total size in bytes of all relevant tables in the Q2A database
* @return float
*/ */
function qa_db_table_size() function qa_db_table_size()
{ {
...@@ -67,9 +69,9 @@ function qa_db_table_size() ...@@ -67,9 +69,9 @@ function qa_db_table_size()
/** /**
* Return a count of the number of posts of $type in database. * Return a count of the number of posts of $type in database.
* Set $fromuser to true to only count non-anonymous posts, false to only count anonymous posts * Set $fromuser to true to only count non-anonymous posts, false to only count anonymous posts
* @param $type * @param string|null $type
* @param $fromuser * @param mixed|null $fromuser
* @return mixed|null * @return string
*/ */
function qa_db_count_posts($type = null, $fromuser = null) function qa_db_count_posts($type = null, $fromuser = null)
{ {
...@@ -89,6 +91,7 @@ function qa_db_count_posts($type = null, $fromuser = null) ...@@ -89,6 +91,7 @@ function qa_db_count_posts($type = null, $fromuser = null)
/** /**
* Return number of registered users in database. * Return number of registered users in database.
* @return string
*/ */
function qa_db_count_users() function qa_db_count_users()
{ {
...@@ -100,8 +103,8 @@ function qa_db_count_users() ...@@ -100,8 +103,8 @@ function qa_db_count_users()
/** /**
* Return number of active users in database $table * Return number of active users in database $table
* @param $table * @param string $table
* @return mixed|null * @return string
*/ */
function qa_db_count_active_users($table) function qa_db_count_active_users($table)
{ {
...@@ -124,6 +127,7 @@ function qa_db_count_active_users($table) ...@@ -124,6 +127,7 @@ function qa_db_count_active_users($table)
/** /**
* Return number of categories in the database * Return number of categories in the database
* @return string
*/ */
function qa_db_count_categories() function qa_db_count_categories()
{ {
...@@ -135,8 +139,8 @@ function qa_db_count_categories() ...@@ -135,8 +139,8 @@ function qa_db_count_categories()
/** /**
* Return number of questions in the database in $categoryid exactly, and not one of its subcategories * Return number of questions in the database in $categoryid exactly, and not one of its subcategories
* @param $categoryid * @param int $categoryid
* @return mixed|null * @return string
*/ */
function qa_db_count_categoryid_qs($categoryid) function qa_db_count_categoryid_qs($categoryid)
{ {
...@@ -149,7 +153,7 @@ function qa_db_count_categoryid_qs($categoryid) ...@@ -149,7 +153,7 @@ function qa_db_count_categoryid_qs($categoryid)
/** /**
* Return list of postids of visible or queued posts by $userid * Return list of postids of visible or queued posts by $userid
* @param $userid * @param mixed $userid
* @return array * @return array
*/ */
function qa_db_get_user_visible_postids($userid) function qa_db_get_user_visible_postids($userid)
...@@ -163,7 +167,7 @@ function qa_db_get_user_visible_postids($userid) ...@@ -163,7 +167,7 @@ function qa_db_get_user_visible_postids($userid)
/** /**
* Return list of postids of visible or queued posts from $ip address * Return list of postids of visible or queued posts from $ip address
* @param $ip * @param string $ip
* @return array * @return array
*/ */
function qa_db_get_ip_visible_postids($ip) function qa_db_get_ip_visible_postids($ip)
...@@ -177,12 +181,12 @@ function qa_db_get_ip_visible_postids($ip) ...@@ -177,12 +181,12 @@ function qa_db_get_ip_visible_postids($ip)
/** /**
* Return an array whose keys contain the $postids which exist, and whose elements contain the number of other posts depending on each one * Return an array whose keys contain the $postids which exist, and whose elements contain the number of other posts depending on each one
* @param $postids * @param array $postids
* @return array * @return array
*/ */
function qa_db_postids_count_dependents($postids) function qa_db_postids_count_dependents($postids)
{ {
if (count($postids)) if (!empty($postids))
return qa_db_read_all_assoc(qa_db_query_sub( return qa_db_read_all_assoc(qa_db_query_sub(
"SELECT postid, COALESCE(childcount, 0) AS count FROM ^posts LEFT JOIN (SELECT parentid, COUNT(*) AS childcount FROM ^posts WHERE parentid IN (#) AND LEFT(type, 1) IN ('A', 'C') GROUP BY parentid) x ON postid=x.parentid WHERE postid IN (#)", "SELECT postid, COALESCE(childcount, 0) AS count FROM ^posts LEFT JOIN (SELECT parentid, COUNT(*) AS childcount FROM ^posts WHERE parentid IN (#) AND LEFT(type, 1) IN ('A', 'C') GROUP BY parentid) x ON postid=x.parentid WHERE postid IN (#)",
$postids, $postids $postids, $postids
...@@ -195,7 +199,7 @@ function qa_db_postids_count_dependents($postids) ...@@ -195,7 +199,7 @@ function qa_db_postids_count_dependents($postids)
/** /**
* Return an array of the (up to) $count most recently created users who are awaiting approval and have not been blocked. * Return an array of the (up to) $count most recently created users who are awaiting approval and have not been blocked.
* The array element for each user includes a 'profile' key whose value is an array of non-empty profile fields of the user. * The array element for each user includes a 'profile' key whose value is an array of non-empty profile fields of the user.
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_get_unapproved_users($count) function qa_db_get_unapproved_users($count)
...@@ -227,6 +231,7 @@ function qa_db_get_unapproved_users($count) ...@@ -227,6 +231,7 @@ function qa_db_get_unapproved_users($count)
/** /**
* Return whether there are any blobs whose content has been stored as a file on disk * Return whether there are any blobs whose content has been stored as a file on disk
* @return bool
*/ */
function qa_db_has_blobs_on_disk() function qa_db_has_blobs_on_disk()
{ {
...@@ -236,6 +241,7 @@ function qa_db_has_blobs_on_disk() ...@@ -236,6 +241,7 @@ function qa_db_has_blobs_on_disk()
/** /**
* Return whether there are any blobs whose content has been stored in the database * Return whether there are any blobs whose content has been stored in the database
* @return bool
*/ */
function qa_db_has_blobs_in_db() function qa_db_has_blobs_in_db()
{ {
...@@ -245,8 +251,8 @@ function qa_db_has_blobs_in_db() ...@@ -245,8 +251,8 @@ function qa_db_has_blobs_in_db()
/** /**
* Return the maximum position of the categories with $parentid * Return the maximum position of the categories with $parentid
* @param $parentid * @param int $parentid
* @return mixed|null * @return string
*/ */
function qa_db_category_last_pos($parentid) function qa_db_category_last_pos($parentid)
{ {
...@@ -259,7 +265,7 @@ function qa_db_category_last_pos($parentid) ...@@ -259,7 +265,7 @@ function qa_db_category_last_pos($parentid)
/** /**
* Return how many levels of subcategory there are below $categoryid * Return how many levels of subcategory there are below $categoryid
* @param $categoryid * @param int $categoryid
* @return int * @return int
*/ */
function qa_db_category_child_depth($categoryid) function qa_db_category_child_depth($categoryid)
...@@ -283,18 +289,18 @@ function qa_db_category_child_depth($categoryid) ...@@ -283,18 +289,18 @@ function qa_db_category_child_depth($categoryid)
/** /**
* Create a new category with $parentid, $title (=name) and $tags (=slug) in the database * Create a new category with $parentid, $title (=name) and $tags (=slug) in the database
* @param $parentid * @param int $parentid
* @param $title * @param string $title
* @param $tags * @param string $tags
* @return mixed * @return int
*/ */
function qa_db_category_create($parentid, $title, $tags) function qa_db_category_create($parentid, $title, $tags)
{ {
$lastpos = qa_db_category_last_pos($parentid); $lastpos = (int)qa_db_category_last_pos($parentid);
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^categories (parentid, title, tags, position) VALUES (#, $, $, #)', 'INSERT INTO ^categories (parentid, title, tags, position) VALUES (#, $, $, #)',
$parentid, $title, $tags, 1 + $lastpos $parentid, $title, $tags, $lastpos + 1
); );
$categoryid = qa_db_last_insert_id(); $categoryid = qa_db_last_insert_id();
...@@ -307,8 +313,8 @@ function qa_db_category_create($parentid, $title, $tags) ...@@ -307,8 +313,8 @@ function qa_db_category_create($parentid, $title, $tags)
/** /**
* Recalculate the backpath columns for all categories from $firstcategoryid to $lastcategoryid (if specified) * Recalculate the backpath columns for all categories from $firstcategoryid to $lastcategoryid (if specified)
* @param $firstcategoryid * @param int $firstcategoryid
* @param $lastcategoryid * @param int|null $lastcategoryid
*/ */
function qa_db_categories_recalc_backpaths($firstcategoryid, $lastcategoryid = null) function qa_db_categories_recalc_backpaths($firstcategoryid, $lastcategoryid = null)
{ {
...@@ -324,9 +330,9 @@ function qa_db_categories_recalc_backpaths($firstcategoryid, $lastcategoryid = n ...@@ -324,9 +330,9 @@ function qa_db_categories_recalc_backpaths($firstcategoryid, $lastcategoryid = n
/** /**
* Set the name of $categoryid to $title and its slug to $tags in the database * Set the name of $categoryid to $title and its slug to $tags in the database
* @param $categoryid * @param int $categoryid
* @param $title * @param string $title
* @param $tags * @param string $tags
*/ */
function qa_db_category_rename($categoryid, $title, $tags) function qa_db_category_rename($categoryid, $title, $tags)
{ {
...@@ -341,8 +347,8 @@ function qa_db_category_rename($categoryid, $title, $tags) ...@@ -341,8 +347,8 @@ function qa_db_category_rename($categoryid, $title, $tags)
/** /**
* Set the content (=description) of $categoryid to $content * Set the content (=description) of $categoryid to $content
* @param $categoryid * @param int $categoryid
* @param $content * @param string $content
*/ */
function qa_db_category_set_content($categoryid, $content) function qa_db_category_set_content($categoryid, $content)
{ {
...@@ -355,8 +361,8 @@ function qa_db_category_set_content($categoryid, $content) ...@@ -355,8 +361,8 @@ function qa_db_category_set_content($categoryid, $content)
/** /**
* Return the parentid of $categoryid * Return the parentid of $categoryid
* @param $categoryid * @param int $categoryid
* @return mixed|null * @return string
*/ */
function qa_db_category_get_parent($categoryid) function qa_db_category_get_parent($categoryid)
{ {
...@@ -369,8 +375,8 @@ function qa_db_category_get_parent($categoryid) ...@@ -369,8 +375,8 @@ function qa_db_category_get_parent($categoryid)
/** /**
* Move the category $categoryid into position $newposition under its parent * Move the category $categoryid into position $newposition under its parent
* @param $categoryid * @param int $categoryid
* @param $newposition * @param int $newposition
*/ */
function qa_db_category_set_position($categoryid, $newposition) function qa_db_category_set_position($categoryid, $newposition)
{ {
...@@ -381,8 +387,8 @@ function qa_db_category_set_position($categoryid, $newposition) ...@@ -381,8 +387,8 @@ function qa_db_category_set_position($categoryid, $newposition)
/** /**
* Set the parent of $categoryid to $newparentid, placing it in last position (doesn't do necessary recalculations) * Set the parent of $categoryid to $newparentid, placing it in last position (doesn't do necessary recalculations)
* @param $categoryid * @param int $categoryid
* @param $newparentid * @param string $newparentid
*/ */
function qa_db_category_set_parent($categoryid, $newparentid) function qa_db_category_set_parent($categoryid, $newparentid)
{ {
...@@ -393,11 +399,11 @@ function qa_db_category_set_parent($categoryid, $newparentid) ...@@ -393,11 +399,11 @@ function qa_db_category_set_parent($categoryid, $newparentid)
qa_db_ordered_move('categories', 'categoryid', $categoryid, $lastpos, qa_db_apply_sub('parentid<=>#', array($oldparentid))); qa_db_ordered_move('categories', 'categoryid', $categoryid, $lastpos, qa_db_apply_sub('parentid<=>#', array($oldparentid)));
$lastpos = qa_db_category_last_pos($newparentid); $lastpos = (int)qa_db_category_last_pos($newparentid);
qa_db_query_sub( qa_db_query_sub(
'UPDATE ^categories SET parentid=#, position=# WHERE categoryid=#', 'UPDATE ^categories SET parentid=#, position=# WHERE categoryid=#',
$newparentid, 1 + $lastpos, $categoryid $newparentid, $lastpos + 1, $categoryid
); );
} }
} }
...@@ -405,8 +411,8 @@ function qa_db_category_set_parent($categoryid, $newparentid) ...@@ -405,8 +411,8 @@ function qa_db_category_set_parent($categoryid, $newparentid)
/** /**
* Change the categoryid of any posts with (exact) $categoryid to $reassignid * Change the categoryid of any posts with (exact) $categoryid to $reassignid
* @param $categoryid * @param int $categoryid
* @param $reassignid * @param int $reassignid
*/ */
function qa_db_category_reassign($categoryid, $reassignid) function qa_db_category_reassign($categoryid, $reassignid)
{ {
...@@ -416,7 +422,7 @@ function qa_db_category_reassign($categoryid, $reassignid) ...@@ -416,7 +422,7 @@ function qa_db_category_reassign($categoryid, $reassignid)
/** /**
* Delete the category $categoryid in the database * Delete the category $categoryid in the database
* @param $categoryid * @param int $categoryid
*/ */
function qa_db_category_delete($categoryid) function qa_db_category_delete($categoryid)
{ {
...@@ -427,9 +433,9 @@ function qa_db_category_delete($categoryid) ...@@ -427,9 +433,9 @@ function qa_db_category_delete($categoryid)
/** /**
* Return the categoryid for the category with parent $parentid and $slug * Return the categoryid for the category with parent $parentid and $slug
* @param $parentid * @param int $parentid
* @param $slug * @param string $slug
* @return mixed|null * @return string|null
*/ */
function qa_db_category_slug_to_id($parentid, $slug) function qa_db_category_slug_to_id($parentid, $slug)
{ {
...@@ -442,13 +448,13 @@ function qa_db_category_slug_to_id($parentid, $slug) ...@@ -442,13 +448,13 @@ function qa_db_category_slug_to_id($parentid, $slug)
/** /**
* Create a new custom page (or link) in the database * Create a new custom page (or link) in the database
* @param $title * @param string $title
* @param $flags * @param int $flags
* @param $tags * @param string $tags
* @param $heading * @param string $heading
* @param $content * @param string $content
* @param $permit * @param int|null $permit
* @return mixed * @return string
*/ */
function qa_db_page_create($title, $flags, $tags, $heading, $content, $permit = null) function qa_db_page_create($title, $flags, $tags, $heading, $content, $permit = null)
{ {
...@@ -465,13 +471,13 @@ function qa_db_page_create($title, $flags, $tags, $heading, $content, $permit = ...@@ -465,13 +471,13 @@ function qa_db_page_create($title, $flags, $tags, $heading, $content, $permit =
/** /**
* Set the fields of $pageid to the values provided in the database * Set the fields of $pageid to the values provided in the database
* @param $pageid * @param int $pageid
* @param $title * @param string $title
* @param $flags * @param int $flags
* @param $tags * @param string $tags
* @param $heading * @param string $heading
* @param $content * @param string $content
* @param $permit * @param int|null $permit
*/ */
function qa_db_page_set_fields($pageid, $title, $flags, $tags, $heading, $content, $permit = null) function qa_db_page_set_fields($pageid, $title, $flags, $tags, $heading, $content, $permit = null)
{ {
...@@ -484,9 +490,9 @@ function qa_db_page_set_fields($pageid, $title, $flags, $tags, $heading, $conten ...@@ -484,9 +490,9 @@ function qa_db_page_set_fields($pageid, $title, $flags, $tags, $heading, $conten
/** /**
* Move the page $pageid into navigation menu $nav and position $newposition in the database * Move the page $pageid into navigation menu $nav and position $newposition in the database
* @param $pageid * @param int $pageid
* @param $nav * @param string $nav
* @param $newposition * @param int $newposition
*/ */
function qa_db_page_move($pageid, $nav, $newposition) function qa_db_page_move($pageid, $nav, $newposition)
{ {
...@@ -501,7 +507,7 @@ function qa_db_page_move($pageid, $nav, $newposition) ...@@ -501,7 +507,7 @@ function qa_db_page_move($pageid, $nav, $newposition)
/** /**
* Delete the page $pageid in the database * Delete the page $pageid in the database
* @param $pageid * @param int $pageid
*/ */
function qa_db_page_delete($pageid) function qa_db_page_delete($pageid)
{ {
...@@ -511,11 +517,11 @@ function qa_db_page_delete($pageid) ...@@ -511,11 +517,11 @@ function qa_db_page_delete($pageid)
/** /**
* Move the entity identified by $idcolumn=$id into position $newposition (within optional $conditionsql) in $table in the database * Move the entity identified by $idcolumn=$id into position $newposition (within optional $conditionsql) in $table in the database
* @param $table * @param string $table
* @param $idcolumn * @param string $idcolumn
* @param $id * @param string $id
* @param $newposition * @param int $newposition
* @param $conditionsql * @param string|null $conditionsql
*/ */
function qa_db_ordered_move($table, $idcolumn, $id, $newposition, $conditionsql = null) function qa_db_ordered_move($table, $idcolumn, $id, $newposition, $conditionsql = null)
{ {
...@@ -547,10 +553,10 @@ function qa_db_ordered_move($table, $idcolumn, $id, $newposition, $conditionsql ...@@ -547,10 +553,10 @@ function qa_db_ordered_move($table, $idcolumn, $id, $newposition, $conditionsql
/** /**
* Delete the entity identified by $idcolumn=$id (and optional $conditionsql) in $table in the database * Delete the entity identified by $idcolumn=$id (and optional $conditionsql) in $table in the database
* @param $table * @param string $table
* @param $idcolumn * @param string $idcolumn
* @param $id * @param string $id
* @param $conditionsql * @param string|null $conditionsql
*/ */
function qa_db_ordered_delete($table, $idcolumn, $id, $conditionsql = null) function qa_db_ordered_delete($table, $idcolumn, $id, $conditionsql = null)
{ {
...@@ -570,11 +576,11 @@ function qa_db_ordered_delete($table, $idcolumn, $id, $conditionsql = null) ...@@ -570,11 +576,11 @@ function qa_db_ordered_delete($table, $idcolumn, $id, $conditionsql = null)
/** /**
* Create a new user field with (internal) tag $title, label $content, $flags and $permit in the database. * Create a new user field with (internal) tag $title, label $content, $flags and $permit in the database.
* @param $title * @param string $title
* @param $content * @param string $content
* @param $flags * @param int $flags
* @param $permit * @param int|null $permit
* @return mixed * @return string
*/ */
function qa_db_userfield_create($title, $content, $flags, $permit = null) function qa_db_userfield_create($title, $content, $flags, $permit = null)
{ {
...@@ -591,10 +597,10 @@ function qa_db_userfield_create($title, $content, $flags, $permit = null) ...@@ -591,10 +597,10 @@ function qa_db_userfield_create($title, $content, $flags, $permit = null)
/** /**
* Change the user field $fieldid to have label $content, $flags and $permit in the database (the title column cannot be changed once set) * Change the user field $fieldid to have label $content, $flags and $permit in the database (the title column cannot be changed once set)
* @param $fieldid * @param string $fieldid
* @param $content * @param string $content
* @param $flags * @param int $flags
* @param $permit * @param int|null $permit
*/ */
function qa_db_userfield_set_fields($fieldid, $content, $flags, $permit = null) function qa_db_userfield_set_fields($fieldid, $content, $flags, $permit = null)
{ {
...@@ -607,8 +613,8 @@ function qa_db_userfield_set_fields($fieldid, $content, $flags, $permit = null) ...@@ -607,8 +613,8 @@ function qa_db_userfield_set_fields($fieldid, $content, $flags, $permit = null)
/** /**
* Move the user field $fieldid into position $newposition in the database * Move the user field $fieldid into position $newposition in the database
* @param $fieldid * @param string $fieldid
* @param $newposition * @param int $newposition
*/ */
function qa_db_userfield_move($fieldid, $newposition) function qa_db_userfield_move($fieldid, $newposition)
{ {
...@@ -618,7 +624,7 @@ function qa_db_userfield_move($fieldid, $newposition) ...@@ -618,7 +624,7 @@ function qa_db_userfield_move($fieldid, $newposition)
/** /**
* Delete the user field $fieldid in the database * Delete the user field $fieldid in the database
* @param $fieldid * @param string $fieldid
*/ */
function qa_db_userfield_delete($fieldid) function qa_db_userfield_delete($fieldid)
{ {
...@@ -628,9 +634,9 @@ function qa_db_userfield_delete($fieldid) ...@@ -628,9 +634,9 @@ function qa_db_userfield_delete($fieldid)
/** /**
* Return the ID of a new widget, to be displayed by the widget module named $title on templates within $tags (comma-separated list) * Return the ID of a new widget, to be displayed by the widget module named $title on templates within $tags (comma-separated list)
* @param $title * @param string $title
* @param $tags * @param string $tags
* @return mixed * @return string
*/ */
function qa_db_widget_create($title, $tags) function qa_db_widget_create($title, $tags)
{ {
...@@ -647,8 +653,8 @@ function qa_db_widget_create($title, $tags) ...@@ -647,8 +653,8 @@ function qa_db_widget_create($title, $tags)
/** /**
* Set the comma-separated list of templates for $widgetid to $tags * Set the comma-separated list of templates for $widgetid to $tags
* @param $widgetid * @param int $widgetid
* @param $tags * @param string $tags
*/ */
function qa_db_widget_set_fields($widgetid, $tags) function qa_db_widget_set_fields($widgetid, $tags)
{ {
...@@ -661,9 +667,9 @@ function qa_db_widget_set_fields($widgetid, $tags) ...@@ -661,9 +667,9 @@ function qa_db_widget_set_fields($widgetid, $tags)
/** /**
* Move the widget $widgetit into position $position in the database's order, and show it in $place on the page * Move the widget $widgetit into position $position in the database's order, and show it in $place on the page
* @param $widgetid * @param int $widgetid
* @param $place * @param string $place
* @param $newposition * @param int $newposition
*/ */
function qa_db_widget_move($widgetid, $place, $newposition) function qa_db_widget_move($widgetid, $place, $newposition)
{ {
...@@ -678,7 +684,7 @@ function qa_db_widget_move($widgetid, $place, $newposition) ...@@ -678,7 +684,7 @@ function qa_db_widget_move($widgetid, $place, $newposition)
/** /**
* Delete the widget $widgetid in the database * Delete the widget $widgetid in the database
* @param $widgetid * @param int $widgetid
*/ */
function qa_db_widget_delete($widgetid) function qa_db_widget_delete($widgetid)
{ {
......
...@@ -27,13 +27,13 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,13 +27,13 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Create a new blob in the database with $content and $format, other fields as provided * Create a new blob in the database with $content and $format, other fields as provided
* @param $content * @param string $content
* @param $format * @param string $format
* @param $sourcefilename * @param string|null $sourcefilename
* @param $userid * @param mixed|null $userid
* @param $cookieid * @param string|null $cookieid
* @param $ip * @param string|null $ip
* @return mixed|null|string * @return mixed|string|null
*/ */
function qa_db_blob_create($content, $format, $sourcefilename = null, $userid = null, $cookieid = null, $ip = null) function qa_db_blob_create($content, $format, $sourcefilename = null, $userid = null, $cookieid = null, $ip = null)
{ {
...@@ -59,8 +59,8 @@ function qa_db_blob_create($content, $format, $sourcefilename = null, $userid = ...@@ -59,8 +59,8 @@ function qa_db_blob_create($content, $format, $sourcefilename = null, $userid =
/** /**
* Get the information about blob $blobid from the database * Get the information about blob $blobid from the database
* @param $blobid * @param string $blobid
* @return array|mixed|null * @return array|null
*/ */
function qa_db_blob_read($blobid) function qa_db_blob_read($blobid)
{ {
...@@ -75,8 +75,8 @@ function qa_db_blob_read($blobid) ...@@ -75,8 +75,8 @@ function qa_db_blob_read($blobid)
/** /**
* Change the content of blob $blobid in the database to $content (can also be null) * Change the content of blob $blobid in the database to $content (can also be null)
* @param $blobid * @param string $blobid
* @param $content * @param string $content
*/ */
function qa_db_blob_set_content($blobid, $content) function qa_db_blob_set_content($blobid, $content)
{ {
...@@ -89,7 +89,7 @@ function qa_db_blob_set_content($blobid, $content) ...@@ -89,7 +89,7 @@ function qa_db_blob_set_content($blobid, $content)
/** /**
* Delete blob $blobid in the database * Delete blob $blobid in the database
* @param $blobid * @param string $blobid
* @return mixed * @return mixed
*/ */
function qa_db_blob_delete($blobid) function qa_db_blob_delete($blobid)
...@@ -105,8 +105,8 @@ function qa_db_blob_delete($blobid) ...@@ -105,8 +105,8 @@ function qa_db_blob_delete($blobid)
/** /**
* Check if blob $blobid exists in the database * Check if blob $blobid exists in the database
* @param $blobid * @param string $blobid
* @return bool|mixed * @return bool
*/ */
function qa_db_blob_exists($blobid) function qa_db_blob_exists($blobid)
{ {
......
...@@ -29,9 +29,9 @@ require_once QA_INCLUDE_DIR . 'db/maxima.php'; ...@@ -29,9 +29,9 @@ require_once QA_INCLUDE_DIR . 'db/maxima.php';
/** /**
* Create (or replace) the item ($type, $cacheid) in the database cache table with $content * Create (or replace) the item ($type, $cacheid) in the database cache table with $content
* @param $type * @param string $type
* @param $cacheid * @param string $cacheid
* @param $content * @param string $content
* @return mixed * @return mixed
*/ */
function qa_db_cache_set($type, $cacheid, $content) function qa_db_cache_set($type, $cacheid, $content)
...@@ -53,8 +53,8 @@ function qa_db_cache_set($type, $cacheid, $content) ...@@ -53,8 +53,8 @@ function qa_db_cache_set($type, $cacheid, $content)
/** /**
* Retrieve the item ($type, $cacheid) from the database cache table * Retrieve the item ($type, $cacheid) from the database cache table
* @param $type * @param string $type
* @param $cacheid * @param string $cacheid
* @return mixed|null * @return mixed|null
*/ */
function qa_db_cache_get($type, $cacheid) function qa_db_cache_get($type, $cacheid)
......
...@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Create a new random cookie for $ipaddress and insert into database, returning it * Create a new random cookie for $ipaddress and insert into database, returning it
* @param $ipaddress * @param string $ipaddress
* @return null|string * @return string|null
*/ */
function qa_db_cookie_create($ipaddress) function qa_db_cookie_create($ipaddress)
{ {
...@@ -53,8 +53,8 @@ function qa_db_cookie_create($ipaddress) ...@@ -53,8 +53,8 @@ function qa_db_cookie_create($ipaddress)
/** /**
* Note in database that a write operation has been done by user identified by $cookieid and from $ipaddress * Note in database that a write operation has been done by user identified by $cookieid and from $ipaddress
* @param $cookieid * @param string $cookieid
* @param $ipaddress * @param string $ipaddress
*/ */
function qa_db_cookie_written($cookieid, $ipaddress) function qa_db_cookie_written($cookieid, $ipaddress)
{ {
...@@ -67,7 +67,7 @@ function qa_db_cookie_written($cookieid, $ipaddress) ...@@ -67,7 +67,7 @@ function qa_db_cookie_written($cookieid, $ipaddress)
/** /**
* Return whether $cookieid exists in database * Return whether $cookieid exists in database
* @param $cookieid * @param string $cookieid
* @return bool * @return bool
*/ */
function qa_db_cookie_exists($cookieid) function qa_db_cookie_exists($cookieid)
......
...@@ -31,13 +31,13 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -31,13 +31,13 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
* event time or leave as null to use now. This will add the event both to the entity's shared stream, and the * event time or leave as null to use now. This will add the event both to the entity's shared stream, and the
* individual user streams for any users following the entity not via its shared stream (See long comment in * individual user streams for any users following the entity not via its shared stream (See long comment in
* /qa-include/db/favorites.php). Also handles truncation. * /qa-include/db/favorites.php). Also handles truncation.
* @param $entitytype * @param string $entitytype
* @param $entityid * @param int $entityid
* @param $questionid * @param int $questionid
* @param $lastpostid * @param int $lastpostid
* @param $updatetype * @param string $updatetype
* @param $lastuserid * @param mixed $lastuserid
* @param $timestamp * @param int|null $timestamp
*/ */
function qa_db_event_create_for_entity($entitytype, $entityid, $questionid, $lastpostid, $updatetype, $lastuserid, $timestamp = null) function qa_db_event_create_for_entity($entitytype, $entityid, $questionid, $lastpostid, $updatetype, $lastuserid, $timestamp = null)
{ {
...@@ -116,12 +116,12 @@ function qa_db_event_create_for_entity($entitytype, $entityid, $questionid, $las ...@@ -116,12 +116,12 @@ function qa_db_event_create_for_entity($entitytype, $entityid, $questionid, $las
* notification which is relevant for them, e.g. if someone answers their question). The event of type $updatetype * notification which is relevant for them, e.g. if someone answers their question). The event of type $updatetype
* relates to $lastpostid whose antecedent question is $questionid, and was caused by $lastuserid. Pass a unix * relates to $lastpostid whose antecedent question is $questionid, and was caused by $lastuserid. Pass a unix
* $timestamp for the event time or leave as null to use now. Also handles truncation of event streams. * $timestamp for the event time or leave as null to use now. Also handles truncation of event streams.
* @param $userid * @param mixed $userid
* @param $questionid * @param int $questionid
* @param $lastpostid * @param int $lastpostid
* @param $updatetype * @param string $updatetype
* @param $lastuserid * @param mixed $lastuserid
* @param $timestamp * @param int|null $timestamp
*/ */
function qa_db_event_create_not_entity($userid, $questionid, $lastpostid, $updatetype, $lastuserid, $timestamp = null) function qa_db_event_create_not_entity($userid, $questionid, $lastpostid, $updatetype, $lastuserid, $timestamp = null)
{ {
...@@ -142,8 +142,8 @@ function qa_db_event_create_not_entity($userid, $questionid, $lastpostid, $updat ...@@ -142,8 +142,8 @@ function qa_db_event_create_not_entity($userid, $questionid, $lastpostid, $updat
/** /**
* Trim the number of events in the event stream for $userid. If an event was just added for a particular question, * Trim the number of events in the event stream for $userid. If an event was just added for a particular question,
* pass the question's id in $questionid (to help focus the truncation). * pass the question's id in $questionid (to help focus the truncation).
* @param $userid * @param mixed $userid
* @param $questionid * @param int|null $questionid
*/ */
function qa_db_user_events_truncate($userid, $questionid = null) function qa_db_user_events_truncate($userid, $questionid = null)
{ {
......
...@@ -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)
{ {
......
...@@ -46,9 +46,9 @@ function qa_db_increment_views($postid) ...@@ -46,9 +46,9 @@ function qa_db_increment_views($postid)
* *
* @param int $firstpostid First post to recalculate (or only post if $lastpostid is null). * @param int $firstpostid First post to recalculate (or only post if $lastpostid is null).
* @param int $lastpostid Last post in the range to recalculate. * @param int $lastpostid Last post in the range to recalculate.
* @param bool $viewincrement Deprecated - view counter is now incremented separately. Previously, would increment the post's * @param bool $viewincrement Deprecated - view counter is now incremented separately. Previously, would increment the
* views and include that in the hotness calculation. * post's views and include that in the hotness calculation.
* @return void * @return mixed
*/ */
function qa_db_hotness_update($firstpostid, $lastpostid = null, $viewincrement = false) function qa_db_hotness_update($firstpostid, $lastpostid = null, $viewincrement = false)
{ {
......
...@@ -29,6 +29,7 @@ define('QA_DB_VERSION_CURRENT', 67); ...@@ -29,6 +29,7 @@ define('QA_DB_VERSION_CURRENT', 67);
/** /**
* Return the column type for user ids after verifying it is one of the legal options * Return the column type for user ids after verifying it is one of the legal options
* @return string
*/ */
function qa_db_user_column_type_verify() function qa_db_user_column_type_verify()
{ {
...@@ -59,6 +60,7 @@ function qa_db_user_column_type_verify() ...@@ -59,6 +60,7 @@ function qa_db_user_column_type_verify()
/** /**
* Return an array of table definitions. For each element of the array, the key is the table name (without prefix) * Return an array of table definitions. For each element of the array, the key is the table name (without prefix)
* and the value is an array of column definitions, [column name] => [definition]. The column name is omitted for indexes. * and the value is an array of column definitions, [column name] => [definition]. The column name is omitted for indexes.
* @return array
*/ */
function qa_db_table_definitions() function qa_db_table_definitions()
{ {
...@@ -539,7 +541,7 @@ function qa_db_table_definitions() ...@@ -539,7 +541,7 @@ function qa_db_table_definitions()
/** /**
* Return array with all values from $array as keys * Return array with all values from $array as keys
* @param $array * @param array $array
* @return array * @return array
*/ */
function qa_array_to_keys($array) function qa_array_to_keys($array)
...@@ -550,7 +552,7 @@ function qa_array_to_keys($array) ...@@ -550,7 +552,7 @@ function qa_array_to_keys($array)
/** /**
* Return a list of tables missing from the database, [table name] => [column/index definitions] * Return a list of tables missing from the database, [table name] => [column/index definitions]
* @param $definitions * @param array $definitions
* @return array * @return array
*/ */
function qa_db_missing_tables($definitions) function qa_db_missing_tables($definitions)
...@@ -569,8 +571,8 @@ function qa_db_missing_tables($definitions) ...@@ -569,8 +571,8 @@ function qa_db_missing_tables($definitions)
/** /**
* Return a list of columns missing from $table in the database, given the full definition set in $definition * Return a list of columns missing from $table in the database, given the full definition set in $definition
* @param $table * @param string $table
* @param $definition * @param array $definition
* @return array * @return array
*/ */
function qa_db_missing_columns($table, $definition) function qa_db_missing_columns($table, $definition)
...@@ -589,6 +591,7 @@ function qa_db_missing_columns($table, $definition) ...@@ -589,6 +591,7 @@ function qa_db_missing_columns($table, $definition)
/** /**
* Return the current version of the Q2A database, to determine need for DB upgrades * Return the current version of the Q2A database, to determine need for DB upgrades
* @return int|null
*/ */
function qa_db_get_db_version() function qa_db_get_db_version()
{ {
...@@ -607,7 +610,7 @@ function qa_db_get_db_version() ...@@ -607,7 +610,7 @@ function qa_db_get_db_version()
/** /**
* Set the current version in the database * Set the current version in the database
* @param $version * @param int $version
*/ */
function qa_db_set_db_version($version) function qa_db_set_db_version($version)
{ {
...@@ -619,6 +622,7 @@ function qa_db_set_db_version($version) ...@@ -619,6 +622,7 @@ function qa_db_set_db_version($version)
/** /**
* Return a string describing what is wrong with the database, or false if everything is just fine * Return a string describing what is wrong with the database, or false if everything is just fine
* @return false|string
*/ */
function qa_db_check_tables() function qa_db_check_tables()
{ {
...@@ -703,8 +707,8 @@ function qa_db_install_tables() ...@@ -703,8 +707,8 @@ function qa_db_install_tables()
/** /**
* Return the SQL command to create a table with $rawname and $definition obtained from qa_db_table_definitions() * Return the SQL command to create a table with $rawname and $definition obtained from qa_db_table_definitions()
* @param $rawname * @param string $rawname
* @param $definition * @param array $definition
* @return string * @return string
*/ */
function qa_db_create_table_sql($rawname, $definition) function qa_db_create_table_sql($rawname, $definition)
...@@ -720,6 +724,7 @@ function qa_db_create_table_sql($rawname, $definition) ...@@ -720,6 +724,7 @@ function qa_db_create_table_sql($rawname, $definition)
/** /**
* Return the SQL to create the default entries in the userfields table (before 1.3 these were hard-coded in PHP) * Return the SQL to create the default entries in the userfields table (before 1.3 these were hard-coded in PHP)
* @return string
*/ */
function qa_db_default_userfields_sql() function qa_db_default_userfields_sql()
{ {
...@@ -1629,9 +1634,9 @@ function qa_db_upgrade_tables() ...@@ -1629,9 +1634,9 @@ function qa_db_upgrade_tables()
/** /**
* Reset the definitions of $columns in $table according to the $definitions array * Reset the definitions of $columns in $table according to the $definitions array
* @param $definitions * @param array $definitions
* @param $table * @param string $table
* @param $columns * @param array $columns
*/ */
function qa_db_upgrade_table_columns($definitions, $table, $columns) function qa_db_upgrade_table_columns($definitions, $table, $columns)
{ {
...@@ -1646,7 +1651,7 @@ function qa_db_upgrade_table_columns($definitions, $table, $columns) ...@@ -1646,7 +1651,7 @@ function qa_db_upgrade_table_columns($definitions, $table, $columns)
/** /**
* Perform upgrade $query and output progress to the browser * Perform upgrade $query and output progress to the browser
* @param $query * @param string $query
*/ */
function qa_db_upgrade_query($query) function qa_db_upgrade_query($query)
{ {
...@@ -1657,7 +1662,7 @@ function qa_db_upgrade_query($query) ...@@ -1657,7 +1662,7 @@ function qa_db_upgrade_query($query)
/** /**
* Output $text to the browser (after converting to HTML) and do all we can to get it displayed * Output $text to the browser (after converting to HTML) and do all we can to get it displayed
* @param $text * @param string $text
*/ */
function qa_db_upgrade_progress($text) function qa_db_upgrade_progress($text)
{ {
......
...@@ -28,9 +28,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -28,9 +28,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Get rate limit information for $action from the database for user $userid and/or IP address $ip, if they're set. * Get rate limit information for $action from the database for user $userid and/or IP address $ip, if they're set.
* Return as an array with the limit type in the key, and a labelled array of the period and count. * Return as an array with the limit type in the key, and a labelled array of the period and count.
* @param $userid * @param mixed $userid
* @param $ip * @param string|null $ip
* @param $action * @param string $action
* @return array * @return array
*/ */
function qa_db_limits_get($userid, $ip, $action) function qa_db_limits_get($userid, $ip, $action)
...@@ -50,7 +50,7 @@ function qa_db_limits_get($userid, $ip, $action) ...@@ -50,7 +50,7 @@ function qa_db_limits_get($userid, $ip, $action)
$arguments[] = $action; $arguments[] = $action;
} }
if (count($selects)) { if (!empty($selects)) {
$query = qa_db_apply_sub(implode(' UNION ALL ', $selects), $arguments); $query = qa_db_apply_sub(implode(' UNION ALL ', $selects), $arguments);
return qa_db_read_all_assoc(qa_db_query_raw($query), 'limitkey'); return qa_db_read_all_assoc(qa_db_query_raw($query), 'limitkey');
...@@ -61,10 +61,10 @@ function qa_db_limits_get($userid, $ip, $action) ...@@ -61,10 +61,10 @@ function qa_db_limits_get($userid, $ip, $action)
/** /**
* Increment the database rate limit count for user $userid and $action by $count within $period * Increment the database rate limit count for user $userid and $action by $count within $period
* @param $userid * @param mixed $userid
* @param $action * @param string $action
* @param $period * @param int $period
* @param $count * @param int $count
*/ */
function qa_db_limits_user_add($userid, $action, $period, $count) function qa_db_limits_user_add($userid, $action, $period, $count)
{ {
...@@ -78,10 +78,10 @@ function qa_db_limits_user_add($userid, $action, $period, $count) ...@@ -78,10 +78,10 @@ function qa_db_limits_user_add($userid, $action, $period, $count)
/** /**
* Increment the database rate limit count for IP address $ip and $action by $count within $period * Increment the database rate limit count for IP address $ip and $action by $count within $period
* @param $ip * @param string $ip
* @param $action * @param string $action
* @param $period * @param int $period
* @param $count * @param int $count
*/ */
function qa_db_limits_ip_add($ip, $action, $period, $count) function qa_db_limits_ip_add($ip, $action, $period, $count)
{ {
......
...@@ -28,12 +28,12 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -28,12 +28,12 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Record a message sent from $fromuserid to $touserid with $content in $format in the database. $public sets whether * Record a message sent from $fromuserid to $touserid with $content in $format in the database. $public sets whether
* public (on wall) or private. Return the messageid of the row created. * public (on wall) or private. Return the messageid of the row created.
* @param $fromuserid * @param mixed $fromuserid
* @param $touserid * @param mixed $touserid
* @param $content * @param string $content
* @param $format * @param string $format
* @param bool $public * @param bool $public
* @return mixed * @return string
*/ */
function qa_db_message_create($fromuserid, $touserid, $content, $format, $public = false) function qa_db_message_create($fromuserid, $touserid, $content, $format, $public = false)
{ {
...@@ -48,8 +48,8 @@ function qa_db_message_create($fromuserid, $touserid, $content, $format, $public ...@@ -48,8 +48,8 @@ function qa_db_message_create($fromuserid, $touserid, $content, $format, $public
/** /**
* Hide the message with $messageid, in $box (inbox|outbox) from the user. * Hide the message with $messageid, in $box (inbox|outbox) from the user.
* @param $messageid * @param int $messageid
* @param $box * @param string $box
*/ */
function qa_db_message_user_hide($messageid, $box) function qa_db_message_user_hide($messageid, $box)
{ {
...@@ -64,7 +64,7 @@ function qa_db_message_user_hide($messageid, $box) ...@@ -64,7 +64,7 @@ function qa_db_message_user_hide($messageid, $box)
/** /**
* Delete the message with $messageid from the database. * Delete the message with $messageid from the database.
* @param $messageid * @param int $messageid
* @param bool $public * @param bool $public
*/ */
function qa_db_message_delete($messageid, $public = true) function qa_db_message_delete($messageid, $public = true)
...@@ -81,7 +81,7 @@ function qa_db_message_delete($messageid, $public = true) ...@@ -81,7 +81,7 @@ function qa_db_message_delete($messageid, $public = true)
/** /**
* Recalculate the cached count of wall posts for user $userid in the database * Recalculate the cached count of wall posts for user $userid in the database
* @param $userid * @param mixed $userid
*/ */
function qa_db_user_recount_posts($userid) function qa_db_user_recount_posts($userid)
{ {
......
...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Set the metadata for user $userid with $key to $value. Keys beginning qa_ are reserved for the Q2A core. * Set the metadata for user $userid with $key to $value. Keys beginning qa_ are reserved for the Q2A core.
* @param $userid * @param mixed $userid
* @param $key * @param string $key
* @param $value * @param string $value
*/ */
function qa_db_usermeta_set($userid, $key, $value) function qa_db_usermeta_set($userid, $key, $value)
{ {
...@@ -39,8 +39,8 @@ function qa_db_usermeta_set($userid, $key, $value) ...@@ -39,8 +39,8 @@ function qa_db_usermeta_set($userid, $key, $value)
/** /**
* Clear the metadata for user $userid with $key ($key can also be an array of keys) * Clear the metadata for user $userid with $key ($key can also be an array of keys)
* @param $userid * @param mixed $userid
* @param $key * @param string $key
*/ */
function qa_db_usermeta_clear($userid, $key) function qa_db_usermeta_clear($userid, $key)
{ {
...@@ -51,8 +51,8 @@ function qa_db_usermeta_clear($userid, $key) ...@@ -51,8 +51,8 @@ function qa_db_usermeta_clear($userid, $key)
/** /**
* Return the metadata value for user $userid with $key ($key can also be an array of keys in which case this * Return the metadata value for user $userid with $key ($key can also be an array of keys in which case this
* returns an array of metadata key => value). * returns an array of metadata key => value).
* @param $userid * @param mixed $userid
* @param $key * @param string $key
* @return array|mixed|null * @return array|mixed|null
*/ */
function qa_db_usermeta_get($userid, $key) function qa_db_usermeta_get($userid, $key)
...@@ -63,9 +63,9 @@ function qa_db_usermeta_get($userid, $key) ...@@ -63,9 +63,9 @@ function qa_db_usermeta_get($userid, $key)
/** /**
* Set the metadata for post $postid with $key to $value. Keys beginning qa_ are reserved for the Q2A core. * Set the metadata for post $postid with $key to $value. Keys beginning qa_ are reserved for the Q2A core.
* @param $postid * @param int $postid
* @param $key * @param string $key
* @param $value * @param string $value
*/ */
function qa_db_postmeta_set($postid, $key, $value) function qa_db_postmeta_set($postid, $key, $value)
{ {
...@@ -75,8 +75,8 @@ function qa_db_postmeta_set($postid, $key, $value) ...@@ -75,8 +75,8 @@ function qa_db_postmeta_set($postid, $key, $value)
/** /**
* Clear the metadata for post $postid with $key ($key can also be an array of keys) * Clear the metadata for post $postid with $key ($key can also be an array of keys)
* @param $postid * @param int $postid
* @param $key * @param string $key
*/ */
function qa_db_postmeta_clear($postid, $key) function qa_db_postmeta_clear($postid, $key)
{ {
...@@ -87,8 +87,8 @@ function qa_db_postmeta_clear($postid, $key) ...@@ -87,8 +87,8 @@ function qa_db_postmeta_clear($postid, $key)
/** /**
* Return the metadata value for post $postid with $key ($key can also be an array of keys in which case this * Return the metadata value for post $postid with $key ($key can also be an array of keys in which case this
* returns an array of metadata key => value). * returns an array of metadata key => value).
* @param $postid * @param int $postid
* @param $key * @param string $key
* @return array|mixed|null * @return array|mixed|null
*/ */
function qa_db_postmeta_get($postid, $key) function qa_db_postmeta_get($postid, $key)
...@@ -99,9 +99,9 @@ function qa_db_postmeta_get($postid, $key) ...@@ -99,9 +99,9 @@ function qa_db_postmeta_get($postid, $key)
/** /**
* Set the metadata for category $categoryid with $key to $value. Keys beginning qa_ are reserved for the Q2A core. * Set the metadata for category $categoryid with $key to $value. Keys beginning qa_ are reserved for the Q2A core.
* @param $categoryid * @param int $categoryid
* @param $key * @param string $key
* @param $value * @param string $value
*/ */
function qa_db_categorymeta_set($categoryid, $key, $value) function qa_db_categorymeta_set($categoryid, $key, $value)
{ {
...@@ -111,8 +111,8 @@ function qa_db_categorymeta_set($categoryid, $key, $value) ...@@ -111,8 +111,8 @@ function qa_db_categorymeta_set($categoryid, $key, $value)
/** /**
* Clear the metadata for category $categoryid with $key ($key can also be an array of keys) * Clear the metadata for category $categoryid with $key ($key can also be an array of keys)
* @param $categoryid * @param int $categoryid
* @param $key * @param string $key
*/ */
function qa_db_categorymeta_clear($categoryid, $key) function qa_db_categorymeta_clear($categoryid, $key)
{ {
...@@ -123,8 +123,8 @@ function qa_db_categorymeta_clear($categoryid, $key) ...@@ -123,8 +123,8 @@ function qa_db_categorymeta_clear($categoryid, $key)
/** /**
* Return the metadata value for category $categoryid with $key ($key can also be an array of keys in which * Return the metadata value for category $categoryid with $key ($key can also be an array of keys in which
* case this returns an array of metadata key => value). * case this returns an array of metadata key => value).
* @param $categoryid * @param int $categoryid
* @param $key * @param string $key
* @return array|mixed|null * @return array|mixed|null
*/ */
function qa_db_categorymeta_get($categoryid, $key) function qa_db_categorymeta_get($categoryid, $key)
...@@ -135,9 +135,9 @@ function qa_db_categorymeta_get($categoryid, $key) ...@@ -135,9 +135,9 @@ function qa_db_categorymeta_get($categoryid, $key)
/** /**
* Set the metadata for tag $tag with $key to $value. Keys beginning qa_ are reserved for the Q2A core. * Set the metadata for tag $tag with $key to $value. Keys beginning qa_ are reserved for the Q2A core.
* @param $tag * @param string $tag
* @param $key * @param string $key
* @param $value * @param string $value
*/ */
function qa_db_tagmeta_set($tag, $key, $value) function qa_db_tagmeta_set($tag, $key, $value)
{ {
...@@ -147,8 +147,8 @@ function qa_db_tagmeta_set($tag, $key, $value) ...@@ -147,8 +147,8 @@ function qa_db_tagmeta_set($tag, $key, $value)
/** /**
* Clear the metadata for tag $tag with $key ($key can also be an array of keys) * Clear the metadata for tag $tag with $key ($key can also be an array of keys)
* @param $tag * @param string $tag
* @param $key * @param string $key
*/ */
function qa_db_tagmeta_clear($tag, $key) function qa_db_tagmeta_clear($tag, $key)
{ {
...@@ -159,9 +159,9 @@ function qa_db_tagmeta_clear($tag, $key) ...@@ -159,9 +159,9 @@ function qa_db_tagmeta_clear($tag, $key)
/** /**
* Return the metadata value for tag $tag with $key ($key can also be an array of keys in which case this * Return the metadata value for tag $tag with $key ($key can also be an array of keys in which case this
* returns an array of metadata key => value). * returns an array of metadata key => value).
* @param $tag * @param string $tag
* @param $key * @param string $key
* @return array|mixed|null * @return mixed
*/ */
function qa_db_tagmeta_get($tag, $key) function qa_db_tagmeta_get($tag, $key)
{ {
...@@ -171,11 +171,11 @@ function qa_db_tagmeta_get($tag, $key) ...@@ -171,11 +171,11 @@ function qa_db_tagmeta_get($tag, $key)
/** /**
* Internal general function to set metadata * Internal general function to set metadata
* @param $metatable * @param string $metatable
* @param $idcolumn * @param string $idcolumn
* @param $idvalue * @param string $idvalue
* @param $title * @param string $title
* @param $content * @param string $content
*/ */
function qa_db_meta_set($metatable, $idcolumn, $idvalue, $title, $content) function qa_db_meta_set($metatable, $idcolumn, $idvalue, $title, $content)
{ {
...@@ -189,10 +189,10 @@ function qa_db_meta_set($metatable, $idcolumn, $idvalue, $title, $content) ...@@ -189,10 +189,10 @@ function qa_db_meta_set($metatable, $idcolumn, $idvalue, $title, $content)
/** /**
* Internal general function to clear metadata * Internal general function to clear metadata
* @param $metatable * @param string $metatable
* @param $idcolumn * @param string $idcolumn
* @param $idvalue * @param string $idvalue
* @param $title * @param string|array $title
*/ */
function qa_db_meta_clear($metatable, $idcolumn, $idvalue, $title) function qa_db_meta_clear($metatable, $idcolumn, $idvalue, $title)
{ {
...@@ -214,11 +214,11 @@ function qa_db_meta_clear($metatable, $idcolumn, $idvalue, $title) ...@@ -214,11 +214,11 @@ function qa_db_meta_clear($metatable, $idcolumn, $idvalue, $title)
/** /**
* Internal general function to return metadata * Internal general function to return metadata
* @param $metatable * @param string $metatable
* @param $idcolumn * @param string $idcolumn
* @param $idvalue * @param string $idvalue
* @param $title * @param string|array $title
* @return array|mixed|null * @return mixed
*/ */
function qa_db_meta_get($metatable, $idcolumn, $idvalue, $title) function qa_db_meta_get($metatable, $idcolumn, $idvalue, $title)
{ {
......
...@@ -27,10 +27,10 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,10 +27,10 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Create a notice for $userid with $content in $format and optional $tags (not displayed) and return its noticeid * Create a notice for $userid with $content in $format and optional $tags (not displayed) and return its noticeid
* @param $userid * @param mixed $userid
* @param $content * @param string $content
* @param string $format * @param string $format
* @param $tags * @param string|null $tags
* @return mixed * @return mixed
*/ */
function qa_db_usernotice_create($userid, $content, $format = '', $tags = null) function qa_db_usernotice_create($userid, $content, $format = '', $tags = null)
...@@ -46,8 +46,8 @@ function qa_db_usernotice_create($userid, $content, $format = '', $tags = null) ...@@ -46,8 +46,8 @@ function qa_db_usernotice_create($userid, $content, $format = '', $tags = null)
/** /**
* Delete the notice $notice which belongs to $userid * Delete the notice $notice which belongs to $userid
* @param $userid * @param mixed $userid
* @param $noticeid * @param int $noticeid
*/ */
function qa_db_usernotice_delete($userid, $noticeid) function qa_db_usernotice_delete($userid, $noticeid)
{ {
...@@ -60,7 +60,7 @@ function qa_db_usernotice_delete($userid, $noticeid) ...@@ -60,7 +60,7 @@ function qa_db_usernotice_delete($userid, $noticeid)
/** /**
* Return an array summarizing the notices to be displayed for $userid, including the tags (not displayed) * Return an array summarizing the notices to be displayed for $userid, including the tags (not displayed)
* @param $userid * @param mixed $userid
* @return array * @return array
*/ */
function qa_db_usernotices_list($userid) function qa_db_usernotices_list($userid)
......
...@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Set option $name to $value in the database * Set option $name to $value in the database
* @param $name * @param string $name
* @param $value * @param string $value
*/ */
function qa_db_set_option($name, $value) function qa_db_set_option($name, $value)
{ {
......
...@@ -27,6 +27,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,6 +27,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Returns an array of option names required to perform calculations in userpoints table * Returns an array of option names required to perform calculations in userpoints table
* @return mixed
*/ */
function qa_db_points_option_names() function qa_db_points_option_names()
{ {
...@@ -49,6 +50,7 @@ function qa_db_points_option_names() ...@@ -49,6 +50,7 @@ function qa_db_points_option_names()
* The element 'formula' contains the SQL fragment that calculates the columns value for one or more users, * The element 'formula' contains the SQL fragment that calculates the columns value for one or more users,
* where the ~ symbol within the fragment is substituted for a constraint on which users we are interested in. * where the ~ symbol within the fragment is substituted for a constraint on which users we are interested in.
* The element 'multiple' specifies what to multiply each column by to create the final sum in the points column. * The element 'multiple' specifies what to multiply each column by to create the final sum in the points column.
* @return mixed
*/ */
function qa_db_points_calculations() function qa_db_points_calculations()
{ {
...@@ -156,10 +158,10 @@ function qa_db_points_calculations() ...@@ -156,10 +158,10 @@ function qa_db_points_calculations()
/** /**
* Update the userpoints table in the database for $userid and $columns, plus the summary points column. * Update the userpoints table in the database for $userid and $columns, plus the summary points column.
* Set $columns to true for all, empty for none, an array for several, or a single value for one. * Set $columns to true for all, false for none, an array for several, or a single value for one.
* This dynamically builds some fairly crazy looking SQL, but it works, and saves repeat calculations. * This dynamically builds some fairly crazy looking SQL, but it works, and saves repeat calculations.
* @param $userid * @param mixed $userid
* @param $columns * @param bool|string|array $columns
* @return mixed * @return mixed
*/ */
function qa_db_points_update_ifuser($userid, $columns) function qa_db_points_update_ifuser($userid, $columns)
...@@ -217,8 +219,8 @@ function qa_db_points_update_ifuser($userid, $columns) ...@@ -217,8 +219,8 @@ function qa_db_points_update_ifuser($userid, $columns)
/** /**
* Set the number of explicit bonus points for $userid to $bonus * Set the number of explicit bonus points for $userid to $bonus
* @param $userid * @param mixed $userid
* @param $bonus * @param int $bonus
*/ */
function qa_db_points_set_bonus($userid, $bonus) function qa_db_points_set_bonus($userid, $bonus)
{ {
......
...@@ -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)
{ {
......
...@@ -30,10 +30,10 @@ require_once QA_INCLUDE_DIR . 'app/updates.php'; ...@@ -30,10 +30,10 @@ require_once QA_INCLUDE_DIR . 'app/updates.php';
/** /**
* Update the selected answer in the database for $questionid to $selchildid, and optionally record that $lastuserid did it from $lastip * Update the selected answer in the database for $questionid to $selchildid, and optionally record that $lastuserid did it from $lastip
* @param $questionid * @param int $questionid
* @param $selchildid * @param int|null $selchildid
* @param $lastuserid * @param mixed|null $lastuserid
* @param $lastip * @param string|null $lastip
*/ */
function qa_db_post_set_selchildid($questionid, $selchildid, $lastuserid = null, $lastip = null) function qa_db_post_set_selchildid($questionid, $selchildid, $lastuserid = null, $lastip = null)
{ {
...@@ -61,10 +61,10 @@ function qa_db_post_set_selchildid($questionid, $selchildid, $lastuserid = null, ...@@ -61,10 +61,10 @@ function qa_db_post_set_selchildid($questionid, $selchildid, $lastuserid = null,
/** /**
* Set $questionid to be closed by post $closedbyid (null if not closed) in the database, and optionally record that * Set $questionid to be closed by post $closedbyid (null if not closed) in the database, and optionally record that
* $lastuserid did it from $lastip * $lastuserid did it from $lastip
* @param $questionid * @param int $questionid
* @param $closedbyid * @param int $closedbyid
* @param $lastuserid * @param mixed|null $lastuserid
* @param $lastip * @param string|null $lastip
*/ */
function qa_db_post_set_closed($questionid, $closedbyid, $lastuserid = null, $lastip = null) function qa_db_post_set_closed($questionid, $closedbyid, $lastuserid = null, $lastip = null)
{ {
...@@ -84,10 +84,10 @@ function qa_db_post_set_closed($questionid, $closedbyid, $lastuserid = null, $la ...@@ -84,10 +84,10 @@ function qa_db_post_set_closed($questionid, $closedbyid, $lastuserid = null, $la
/** /**
* Set the type in the database of $postid to $type, and optionally record that $lastuserid did it from $lastip * Set the type in the database of $postid to $type, and optionally record that $lastuserid did it from $lastip
* @param $postid * @param int $postid
* @param $type * @param string $type
* @param $lastuserid * @param mixed|null $lastuserid
* @param $lastip * @param string|null $lastip
* @param string $updatetype * @param string $updatetype
*/ */
function qa_db_post_set_type($postid, $type, $lastuserid = null, $lastip = null, $updatetype = QA_UPDATE_TYPE) function qa_db_post_set_type($postid, $type, $lastuserid = null, $lastip = null, $updatetype = QA_UPDATE_TYPE)
...@@ -109,10 +109,10 @@ function qa_db_post_set_type($postid, $type, $lastuserid = null, $lastip = null, ...@@ -109,10 +109,10 @@ function qa_db_post_set_type($postid, $type, $lastuserid = null, $lastip = null,
/** /**
* Set the parent in the database of $postid to $parentid, and optionally record that $lastuserid did it from $lastip * Set the parent in the database of $postid to $parentid, and optionally record that $lastuserid did it from $lastip
* (if at least one is specified) * (if at least one is specified)
* @param $postid * @param int $postid
* @param $parentid * @param int $parentid
* @param $lastuserid * @param mixed|null $lastuserid
* @param $lastip * @param string|null $lastip
*/ */
function qa_db_post_set_parent($postid, $parentid, $lastuserid = null, $lastip = null) function qa_db_post_set_parent($postid, $parentid, $lastuserid = null, $lastip = null)
{ {
...@@ -134,16 +134,16 @@ function qa_db_post_set_parent($postid, $parentid, $lastuserid = null, $lastip = ...@@ -134,16 +134,16 @@ function qa_db_post_set_parent($postid, $parentid, $lastuserid = null, $lastip =
* Set the text fields in the database of $postid to $title, $content, $tagstring, $notify and $name, and record that * Set the text fields in the database of $postid to $title, $content, $tagstring, $notify and $name, and record that
* $lastuserid did it from $lastip (if at least one is specified) with $updatetype. For backwards compatibility if $name * $lastuserid did it from $lastip (if at least one is specified) with $updatetype. For backwards compatibility if $name
* is null then the name will not be changed. * is null then the name will not be changed.
* @param $postid * @param int $postid
* @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 $lastuserid * @param mixed|null $lastuserid
* @param $lastip * @param string|null $lastip
* @param string $updatetype * @param string $updatetype
* @param $name * @param string|null $name
*/ */
function qa_db_post_set_content($postid, $title, $content, $format, $tagstring, $notify, $lastuserid = null, $lastip = null, $updatetype = QA_UPDATE_CONTENT, $name = null) function qa_db_post_set_content($postid, $title, $content, $format, $tagstring, $notify, $lastuserid = null, $lastip = null, $updatetype = QA_UPDATE_CONTENT, $name = null)
{ {
...@@ -164,8 +164,8 @@ function qa_db_post_set_content($postid, $title, $content, $format, $tagstring, ...@@ -164,8 +164,8 @@ function qa_db_post_set_content($postid, $title, $content, $format, $tagstring,
/** /**
* Set the author in the database of $postid to $userid, and set the lastuserid to $userid as well if appropriate * Set the author in the database of $postid to $userid, and set the lastuserid to $userid as well if appropriate
* @param $postid * @param int $postid
* @param $userid * @param mixed $userid
*/ */
function qa_db_post_set_userid($postid, $userid) function qa_db_post_set_userid($postid, $userid)
{ {
...@@ -179,10 +179,10 @@ function qa_db_post_set_userid($postid, $userid) ...@@ -179,10 +179,10 @@ function qa_db_post_set_userid($postid, $userid)
/** /**
* Set the (exact) category in the database of $postid to $categoryid, and optionally record that $lastuserid did it from * Set the (exact) category in the database of $postid to $categoryid, and optionally record that $lastuserid did it from
* $lastip (if at least one is specified) * $lastip (if at least one is specified)
* @param $postid * @param int $postid
* @param $categoryid * @param int $categoryid
* @param $lastuserid * @param mixed|null $lastuserid
* @param $lastip * @param string|null $lastip
*/ */
function qa_db_post_set_category($postid, $categoryid, $lastuserid = null, $lastip = null) function qa_db_post_set_category($postid, $categoryid, $lastuserid = null, $lastip = null)
{ {
...@@ -202,12 +202,12 @@ function qa_db_post_set_category($postid, $categoryid, $lastuserid = null, $last ...@@ -202,12 +202,12 @@ function qa_db_post_set_category($postid, $categoryid, $lastuserid = null, $last
/** /**
* Set the category path in the database of each of $postids to $path retrieved via qa_db_post_get_category_path() * Set the category path in the database of each of $postids to $path retrieved via qa_db_post_get_category_path()
* @param $postids * @param array $postids
* @param $path * @param array $path
*/ */
function qa_db_posts_set_category_path($postids, $path) function qa_db_posts_set_category_path($postids, $path)
{ {
if (count($postids)) { if (!empty($postids)) {
// requires QA_CATEGORY_DEPTH=4 // requires QA_CATEGORY_DEPTH=4
qa_db_query_sub( qa_db_query_sub(
'UPDATE ^posts SET categoryid=#, catidpath1=#, catidpath2=#, catidpath3=# WHERE postid IN (#)', 'UPDATE ^posts SET categoryid=#, catidpath1=#, catidpath2=#, catidpath3=# WHERE postid IN (#)',
...@@ -219,8 +219,8 @@ function qa_db_posts_set_category_path($postids, $path) ...@@ -219,8 +219,8 @@ function qa_db_posts_set_category_path($postids, $path)
/** /**
* Set the created date of $postid to $created, which is a unix timestamp. If created is null, set to now. * Set the created date of $postid to $created, which is a unix timestamp. If created is null, set to now.
* @param $postid * @param int $postid
* @param $created * @param int|null $created
*/ */
function qa_db_post_set_created($postid, $created) function qa_db_post_set_created($postid, $created)
{ {
...@@ -240,8 +240,8 @@ function qa_db_post_set_created($postid, $created) ...@@ -240,8 +240,8 @@ function qa_db_post_set_created($postid, $created)
/** /**
* Set the last updated date of $postid to $updated, which is a unix timestamp. If updated is null, set to now. * Set the last updated date of $postid to $updated, which is a unix timestamp. If updated is null, set to now.
* @param $postid * @param int $postid
* @param $updated * @param int|null $updated
*/ */
function qa_db_post_set_updated($postid, $updated) function qa_db_post_set_updated($postid, $updated)
{ {
...@@ -261,7 +261,7 @@ function qa_db_post_set_updated($postid, $updated) ...@@ -261,7 +261,7 @@ function qa_db_post_set_updated($postid, $updated)
/** /**
* Deletes post $postid from the database (will also delete any votes on the post due to foreign key cascading) * Deletes post $postid from the database (will also delete any votes on the post due to foreign key cascading)
* @param $postid * @param int $postid
*/ */
function qa_db_post_delete($postid) function qa_db_post_delete($postid)
{ {
...@@ -274,7 +274,7 @@ function qa_db_post_delete($postid) ...@@ -274,7 +274,7 @@ function qa_db_post_delete($postid)
/** /**
* Return an array of wordids that were indexed in the database for the title of $postid * Return an array of wordids that were indexed in the database for the title of $postid
* @param $postid * @param int $postid
* @return array * @return array
*/ */
function qa_db_titlewords_get_post_wordids($postid) function qa_db_titlewords_get_post_wordids($postid)
...@@ -288,7 +288,7 @@ function qa_db_titlewords_get_post_wordids($postid) ...@@ -288,7 +288,7 @@ function qa_db_titlewords_get_post_wordids($postid)
/** /**
* Remove all entries in the database index of title words for $postid * Remove all entries in the database index of title words for $postid
* @param $postid * @param int $postid
*/ */
function qa_db_titlewords_delete_post($postid) function qa_db_titlewords_delete_post($postid)
{ {
...@@ -301,7 +301,7 @@ function qa_db_titlewords_delete_post($postid) ...@@ -301,7 +301,7 @@ function qa_db_titlewords_delete_post($postid)
/** /**
* Return an array of wordids that were indexed in the database for the content of $postid * Return an array of wordids that were indexed in the database for the content of $postid
* @param $postid * @param int $postid
* @return array * @return array
*/ */
function qa_db_contentwords_get_post_wordids($postid) function qa_db_contentwords_get_post_wordids($postid)
...@@ -315,7 +315,7 @@ function qa_db_contentwords_get_post_wordids($postid) ...@@ -315,7 +315,7 @@ function qa_db_contentwords_get_post_wordids($postid)
/** /**
* Remove all entries in the database index of content words for $postid * Remove all entries in the database index of content words for $postid
* @param $postid * @param int $postid
*/ */
function qa_db_contentwords_delete_post($postid) function qa_db_contentwords_delete_post($postid)
{ {
...@@ -328,7 +328,7 @@ function qa_db_contentwords_delete_post($postid) ...@@ -328,7 +328,7 @@ function qa_db_contentwords_delete_post($postid)
/** /**
* Return an array of wordids that were indexed in the database for the individual words in tags of $postid * Return an array of wordids that were indexed in the database for the individual words in tags of $postid
* @param $postid * @param int $postid
* @return array * @return array
*/ */
function qa_db_tagwords_get_post_wordids($postid) function qa_db_tagwords_get_post_wordids($postid)
...@@ -342,7 +342,7 @@ function qa_db_tagwords_get_post_wordids($postid) ...@@ -342,7 +342,7 @@ function qa_db_tagwords_get_post_wordids($postid)
/** /**
* Remove all entries in the database index of individual words in tags of $postid * Remove all entries in the database index of individual words in tags of $postid
* @param $postid * @param int $postid
*/ */
function qa_db_tagwords_delete_post($postid) function qa_db_tagwords_delete_post($postid)
{ {
...@@ -355,7 +355,7 @@ function qa_db_tagwords_delete_post($postid) ...@@ -355,7 +355,7 @@ function qa_db_tagwords_delete_post($postid)
/** /**
* Return an array of wordids that were indexed in the database for the whole tags of $postid * Return an array of wordids that were indexed in the database for the whole tags of $postid
* @param $postid * @param int $postid
* @return array * @return array
*/ */
function qa_db_posttags_get_post_wordids($postid) function qa_db_posttags_get_post_wordids($postid)
...@@ -369,7 +369,7 @@ function qa_db_posttags_get_post_wordids($postid) ...@@ -369,7 +369,7 @@ function qa_db_posttags_get_post_wordids($postid)
/** /**
* Remove all entries in the database index of whole tags for $postid * Remove all entries in the database index of whole tags for $postid
* @param $postid * @param int $postid
*/ */
function qa_db_posttags_delete_post($postid) function qa_db_posttags_delete_post($postid)
{ {
...@@ -382,12 +382,12 @@ function qa_db_posttags_delete_post($postid) ...@@ -382,12 +382,12 @@ function qa_db_posttags_delete_post($postid)
/** /**
* Return the array $postids containing only those elements which are the postid of a question in the database * Return the array $postids containing only those elements which are the postid of a question in the database
* @param $postids * @param array $postids
* @return array * @return array
*/ */
function qa_db_posts_filter_q_postids($postids) function qa_db_posts_filter_q_postids($postids)
{ {
if (count($postids)) { if (!empty($postids)) {
return qa_db_read_all_values(qa_db_query_sub( return qa_db_read_all_values(qa_db_query_sub(
"SELECT postid FROM ^posts WHERE type='Q' AND postid IN (#)", "SELECT postid FROM ^posts WHERE type='Q' AND postid IN (#)",
$postids $postids
...@@ -400,12 +400,12 @@ function qa_db_posts_filter_q_postids($postids) ...@@ -400,12 +400,12 @@ function qa_db_posts_filter_q_postids($postids)
/** /**
* Return an array of all the userids of authors of posts in the array $postids * Return an array of all the userids of authors of posts in the array $postids
* @param $postids * @param array $postids
* @return array * @return array
*/ */
function qa_db_posts_get_userids($postids) function qa_db_posts_get_userids($postids)
{ {
if (count($postids)) { if (!empty($postids)) {
return qa_db_read_all_values(qa_db_query_sub( return qa_db_read_all_values(qa_db_query_sub(
"SELECT DISTINCT userid FROM ^posts WHERE postid IN (#) AND userid IS NOT NULL", "SELECT DISTINCT userid FROM ^posts WHERE postid IN (#) AND userid IS NOT NULL",
$postids $postids
......
...@@ -31,6 +31,7 @@ require_once QA_INCLUDE_DIR . 'db/post-create.php'; ...@@ -31,6 +31,7 @@ require_once QA_INCLUDE_DIR . 'db/post-create.php';
/** /**
* Return the number of custom pages currently in the database * Return the number of custom pages currently in the database
* @return string
*/ */
function qa_db_count_pages() function qa_db_count_pages()
{ {
...@@ -42,8 +43,8 @@ function qa_db_count_pages() ...@@ -42,8 +43,8 @@ function qa_db_count_pages()
/** /**
* Return the information to reindex up to $count pages starting from $startpageid in the database * Return the information to reindex up to $count pages starting from $startpageid in the database
* @param $startpageid * @param int $startpageid
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_pages_get_for_reindexing($startpageid, $count) function qa_db_pages_get_for_reindexing($startpageid, $count)
...@@ -59,8 +60,8 @@ function qa_db_pages_get_for_reindexing($startpageid, $count) ...@@ -59,8 +60,8 @@ function qa_db_pages_get_for_reindexing($startpageid, $count)
/** /**
* Return the information required to reindex up to $count posts starting from $startpostid in the database * Return the information required to reindex up to $count posts starting from $startpostid in the database
* @param $startpostid * @param int $startpostid
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_posts_get_for_reindexing($startpostid, $count) function qa_db_posts_get_for_reindexing($startpostid, $count)
...@@ -74,8 +75,8 @@ function qa_db_posts_get_for_reindexing($startpostid, $count) ...@@ -74,8 +75,8 @@ function qa_db_posts_get_for_reindexing($startpostid, $count)
/** /**
* Prepare posts $firstpostid to $lastpostid for reindexing in the database by removing their prior index entries * Prepare posts $firstpostid to $lastpostid for reindexing in the database by removing their prior index entries
* @param $firstpostid * @param int $firstpostid
* @param $lastpostid * @param int $lastpostid
*/ */
function qa_db_prepare_for_reindexing($firstpostid, $lastpostid) function qa_db_prepare_for_reindexing($firstpostid, $lastpostid)
{ {
...@@ -103,7 +104,7 @@ function qa_db_prepare_for_reindexing($firstpostid, $lastpostid) ...@@ -103,7 +104,7 @@ function qa_db_prepare_for_reindexing($firstpostid, $lastpostid)
/** /**
* Remove any rows in the database word indexes with postid from $firstpostid upwards * Remove any rows in the database word indexes with postid from $firstpostid upwards
* @param $firstpostid * @param int $firstpostid
*/ */
function qa_db_truncate_indexes($firstpostid) function qa_db_truncate_indexes($firstpostid)
{ {
...@@ -131,6 +132,7 @@ function qa_db_truncate_indexes($firstpostid) ...@@ -131,6 +132,7 @@ function qa_db_truncate_indexes($firstpostid)
/** /**
* Return the number of words currently referenced in the database * Return the number of words currently referenced in the database
* @return string
*/ */
function qa_db_count_words() function qa_db_count_words()
{ {
...@@ -142,8 +144,8 @@ function qa_db_count_words() ...@@ -142,8 +144,8 @@ function qa_db_count_words()
/** /**
* Return the ids of up to $count words in the database starting from $startwordid * Return the ids of up to $count words in the database starting from $startwordid
* @param $startwordid * @param int $startwordid
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_words_prepare_for_recounting($startwordid, $count) function qa_db_words_prepare_for_recounting($startwordid, $count)
...@@ -157,8 +159,8 @@ function qa_db_words_prepare_for_recounting($startwordid, $count) ...@@ -157,8 +159,8 @@ function qa_db_words_prepare_for_recounting($startwordid, $count)
/** /**
* Recalculate the cached counts for words $firstwordid to $lastwordid in the database * Recalculate the cached counts for words $firstwordid to $lastwordid in the database
* @param $firstwordid * @param int $firstwordid
* @param $lastwordid * @param int $lastwordid
*/ */
function qa_db_words_recount($firstwordid, $lastwordid) function qa_db_words_recount($firstwordid, $lastwordid)
{ {
...@@ -193,8 +195,8 @@ function qa_db_words_recount($firstwordid, $lastwordid) ...@@ -193,8 +195,8 @@ function qa_db_words_recount($firstwordid, $lastwordid)
/** /**
* Return the ids of up to $count posts in the database starting from $startpostid * Return the ids of up to $count posts in the database starting from $startpostid
* @param $startpostid * @param int $startpostid
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_posts_get_for_recounting($startpostid, $count) function qa_db_posts_get_for_recounting($startpostid, $count)
...@@ -208,8 +210,8 @@ function qa_db_posts_get_for_recounting($startpostid, $count) ...@@ -208,8 +210,8 @@ function qa_db_posts_get_for_recounting($startpostid, $count)
/** /**
* Recalculate the cached vote counts for posts $firstpostid to $lastpostid in the database * Recalculate the cached vote counts for posts $firstpostid to $lastpostid in the database
* @param $firstpostid * @param int $firstpostid
* @param $lastpostid * @param int $lastpostid
*/ */
function qa_db_posts_votes_recount($firstpostid, $lastpostid) function qa_db_posts_votes_recount($firstpostid, $lastpostid)
{ {
...@@ -223,9 +225,10 @@ function qa_db_posts_votes_recount($firstpostid, $lastpostid) ...@@ -223,9 +225,10 @@ function qa_db_posts_votes_recount($firstpostid, $lastpostid)
/** /**
* Recalculate the cached answer counts for posts $firstpostid to $lastpostid in the database, along with the highest netvotes of any of their answers * Recalculate the cached answer counts for posts $firstpostid to $lastpostid in the database, along with the highest
* @param $firstpostid * netvotes of any of their answers
* @param $lastpostid * @param int $firstpostid
* @param int $lastpostid
*/ */
function qa_db_posts_answers_recount($firstpostid, $lastpostid) function qa_db_posts_answers_recount($firstpostid, $lastpostid)
{ {
...@@ -243,10 +246,10 @@ function qa_db_posts_answers_recount($firstpostid, $lastpostid) ...@@ -243,10 +246,10 @@ function qa_db_posts_answers_recount($firstpostid, $lastpostid)
// For recalculating user points... // For recalculating user points...
/** /**
* Return the ids of up to $count users in the database starting from $startuserid * Return the ids of up to $count users in the database starting from $startuserid.
* If using single sign-on integration, base this on user activity rather than the users table which we don't have * If using single sign-on integration, base this on user activity rather than the users table which we don't have
* @param $startuserid * @param int $startuserid
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_users_get_for_recalc_points($startuserid, $count) function qa_db_users_get_for_recalc_points($startuserid, $count)
...@@ -267,8 +270,8 @@ function qa_db_users_get_for_recalc_points($startuserid, $count) ...@@ -267,8 +270,8 @@ function qa_db_users_get_for_recalc_points($startuserid, $count)
/** /**
* Recalculate all userpoints columns for users $firstuserid to $lastuserid in the database * Recalculate all userpoints columns for users $firstuserid to $lastuserid in the database
* @param $firstuserid * @param mixed $firstuserid
* @param $lastuserid * @param mixed $lastuserid
*/ */
function qa_db_users_recalc_points($firstuserid, $lastuserid) function qa_db_users_recalc_points($firstuserid, $lastuserid)
{ {
...@@ -324,7 +327,7 @@ function qa_db_users_recalc_points($firstuserid, $lastuserid) ...@@ -324,7 +327,7 @@ function qa_db_users_recalc_points($firstuserid, $lastuserid)
/** /**
* Remove any rows in the userpoints table where userid is greater than $lastuserid * Remove any rows in the userpoints table where userid is greater than $lastuserid
* @param $lastuserid * @param mixed $lastuserid
*/ */
function qa_db_truncate_userpoints($lastuserid) function qa_db_truncate_userpoints($lastuserid)
{ {
...@@ -339,8 +342,8 @@ function qa_db_truncate_userpoints($lastuserid) ...@@ -339,8 +342,8 @@ function qa_db_truncate_userpoints($lastuserid)
/** /**
* Return the ids of up to $count questions in the database starting from $startpostid * Return the ids of up to $count questions in the database starting from $startpostid
* @param $startpostid * @param int $startpostid
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_qs_get_for_event_refilling($startpostid, $count) function qa_db_qs_get_for_event_refilling($startpostid, $count)
...@@ -356,8 +359,8 @@ function qa_db_qs_get_for_event_refilling($startpostid, $count) ...@@ -356,8 +359,8 @@ function qa_db_qs_get_for_event_refilling($startpostid, $count)
/** /**
* Return the ids of up to $count posts (including queued/hidden) in the database starting from $startpostid * Return the ids of up to $count posts (including queued/hidden) in the database starting from $startpostid
* @param $startpostid * @param int $startpostid
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_posts_get_for_recategorizing($startpostid, $count) function qa_db_posts_get_for_recategorizing($startpostid, $count)
...@@ -372,8 +375,8 @@ function qa_db_posts_get_for_recategorizing($startpostid, $count) ...@@ -372,8 +375,8 @@ function qa_db_posts_get_for_recategorizing($startpostid, $count)
/** /**
* Recalculate the (exact) categoryid for the posts (including queued/hidden) between $firstpostid and $lastpostid * Recalculate the (exact) categoryid for the posts (including queued/hidden) between $firstpostid and $lastpostid
* in the database, where the category of comments and answers is set by the category of the antecedent question * in the database, where the category of comments and answers is set by the category of the antecedent question
* @param $firstpostid * @param int $firstpostid
* @param $lastpostid * @param int $lastpostid
*/ */
function qa_db_posts_recalc_categoryid($firstpostid, $lastpostid) function qa_db_posts_recalc_categoryid($firstpostid, $lastpostid)
{ {
...@@ -386,8 +389,8 @@ function qa_db_posts_recalc_categoryid($firstpostid, $lastpostid) ...@@ -386,8 +389,8 @@ function qa_db_posts_recalc_categoryid($firstpostid, $lastpostid)
/** /**
* Return the ids of up to $count categories in the database starting from $startcategoryid * Return the ids of up to $count categories in the database starting from $startcategoryid
* @param $startcategoryid * @param int $startcategoryid
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_categories_get_for_recalcs($startcategoryid, $count) function qa_db_categories_get_for_recalcs($startcategoryid, $count)
...@@ -403,9 +406,9 @@ function qa_db_categories_get_for_recalcs($startcategoryid, $count) ...@@ -403,9 +406,9 @@ function qa_db_categories_get_for_recalcs($startcategoryid, $count)
/** /**
* Return the ids of up to $limit posts of $type that can be deleted from the database (i.e. have no dependents) * Return the ids of up to $limit posts of $type that can be deleted from the database (i.e. have no dependents)
* @param $type * @param string $type
* @param int $startpostid * @param int $startpostid
* @param $limit * @param int|null $limit
* @return array * @return array
*/ */
function qa_db_posts_get_for_deleting($type, $startpostid = 0, $limit = null) function qa_db_posts_get_for_deleting($type, $startpostid = 0, $limit = null)
...@@ -423,6 +426,7 @@ function qa_db_posts_get_for_deleting($type, $startpostid = 0, $limit = null) ...@@ -423,6 +426,7 @@ function qa_db_posts_get_for_deleting($type, $startpostid = 0, $limit = null)
/** /**
* Return the number of blobs whose content is stored in the database, rather than on disk * Return the number of blobs whose content is stored in the database, rather than on disk
* @return string
*/ */
function qa_db_count_blobs_in_db() function qa_db_count_blobs_in_db()
{ {
...@@ -432,7 +436,7 @@ function qa_db_count_blobs_in_db() ...@@ -432,7 +436,7 @@ function qa_db_count_blobs_in_db()
/** /**
* Return the id, content and format of the first blob whose content is stored in the database starting from $startblobid * Return the id, content and format of the first blob whose content is stored in the database starting from $startblobid
* @param $startblobid * @param int $startblobid
* @return array|null * @return array|null
*/ */
function qa_db_get_next_blob_in_db($startblobid) function qa_db_get_next_blob_in_db($startblobid)
...@@ -446,6 +450,7 @@ function qa_db_get_next_blob_in_db($startblobid) ...@@ -446,6 +450,7 @@ function qa_db_get_next_blob_in_db($startblobid)
/** /**
* Return the number of blobs whose content is stored on disk, rather than in the database * Return the number of blobs whose content is stored on disk, rather than in the database
* @return string
*/ */
function qa_db_count_blobs_on_disk() function qa_db_count_blobs_on_disk()
{ {
...@@ -455,7 +460,7 @@ function qa_db_count_blobs_on_disk() ...@@ -455,7 +460,7 @@ function qa_db_count_blobs_on_disk()
/** /**
* Return the id and format of the first blob whose content is stored on disk starting from $startblobid * Return the id and format of the first blob whose content is stored on disk starting from $startblobid
* @param $startblobid * @param int $startblobid
* @return array|null * @return array|null
*/ */
function qa_db_get_next_blob_on_disk($startblobid) function qa_db_get_next_blob_on_disk($startblobid)
......
...@@ -31,6 +31,7 @@ require_once QA_INCLUDE_DIR.'db/maxima.php'; ...@@ -31,6 +31,7 @@ require_once QA_INCLUDE_DIR.'db/maxima.php';
* Return the results of all the SELECT operations specified by the supplied selectspec parameters, while also * Return the results of all the SELECT operations specified by the supplied selectspec parameters, while also
* performing all pending selects that have not yet been executed. If only one parameter is supplied, return its * performing all pending selects that have not yet been executed. If only one parameter is supplied, return its
* result, otherwise return an array of results indexed as per the parameters. * result, otherwise return an array of results indexed as per the parameters.
* @return mixed
*/ */
function qa_db_select_with_pending() // any number of parameters read via func_get_args() function qa_db_select_with_pending() // any number of parameters read via func_get_args()
{ {
...@@ -74,8 +75,8 @@ function qa_db_select_with_pending() // any number of parameters read via func_g ...@@ -74,8 +75,8 @@ function qa_db_select_with_pending() // any number of parameters read via func_g
/** /**
* Queue a $selectspec for running later, with $pendingid (used for retrieval) * Queue a $selectspec for running later, with $pendingid (used for retrieval)
* @param $pendingid * @param string $pendingid
* @param $selectspec * @param array $selectspec
*/ */
function qa_db_queue_pending_select($pendingid, $selectspec) function qa_db_queue_pending_select($pendingid, $selectspec)
{ {
...@@ -88,9 +89,9 @@ function qa_db_queue_pending_select($pendingid, $selectspec) ...@@ -88,9 +89,9 @@ function qa_db_queue_pending_select($pendingid, $selectspec)
/** /**
* Get the result of the queued SELECT query identified by $pendingid. Run the query if it hasn't run already. If * Get the result of the queued SELECT query identified by $pendingid. Run the query if it hasn't run already. If
* $selectspec is supplied, it doesn't matter if this hasn't been queued before - it will be queued and run now. * $selectspec is supplied, it doesn't matter if this hasn't been queued before - it will be queued and run now.
* @param $pendingid * @param string $pendingid
* @param $selectspec * @param array|null $selectspec
* @return * @return mixed
*/ */
function qa_db_get_pending_result($pendingid, $selectspec = null) function qa_db_get_pending_result($pendingid, $selectspec = null)
{ {
...@@ -113,7 +114,7 @@ function qa_db_get_pending_result($pendingid, $selectspec = null) ...@@ -113,7 +114,7 @@ function qa_db_get_pending_result($pendingid, $selectspec = null)
/** /**
* Remove the results of queued SELECT query identified by $pendingid if it has already been run. This means it will * Remove the results of queued SELECT query identified by $pendingid if it has already been run. This means it will
* run again if its results are requested via qa_db_get_pending_result() * run again if its results are requested via qa_db_get_pending_result()
* @param $pendingid * @param string $pendingid
*/ */
function qa_db_flush_pending_result($pendingid) function qa_db_flush_pending_result($pendingid)
{ {
...@@ -125,16 +126,16 @@ function qa_db_flush_pending_result($pendingid) ...@@ -125,16 +126,16 @@ function qa_db_flush_pending_result($pendingid)
/** /**
* Modify a selectspec to count the number of items. This assumes the original selectspec does not have a LIMIT clause. * Modify a selectspec to count the number of items. This assumes the original selectspec does not have a LIMIT clause.
* Currently works with message inbox/outbox functions and user-flags function. * Currently works with message inbox/outbox functions and user-flags function.
* @param $selectSpec * @param array $selectspec
* @return mixed * @return array
*/ */
function qa_db_selectspec_count($selectSpec) function qa_db_selectspec_count($selectspec)
{ {
$selectSpec['columns'] = array('count' => 'COUNT(*)'); $selectspec['columns'] = array('count' => 'COUNT(*)');
$selectSpec['single'] = true; $selectspec['single'] = true;
unset($selectSpec['arraykey']); unset($selectspec['arraykey']);
return $selectSpec; return $selectspec;
} }
...@@ -143,7 +144,7 @@ function qa_db_selectspec_count($selectSpec) ...@@ -143,7 +144,7 @@ function qa_db_selectspec_count($selectSpec)
* If $voteuserid is set, retrieve the vote made by a particular that user on each post. * If $voteuserid is set, retrieve the vote made by a particular that user on each post.
* If $full is true, get full information on the posts, instead of just information for listing pages. * If $full is true, get full information on the posts, instead of just information for listing pages.
* If $user is true, get information about the user who wrote the post (or cookie if anonymous). * If $user is true, get information about the user who wrote the post (or cookie if anonymous).
* @param $voteuserid * @param mixed|null $voteuserid
* @param bool $full * @param bool $full
* @param bool $user * @param bool $user
* @return array * @return array
...@@ -224,8 +225,8 @@ function qa_db_posts_basic_selectspec($voteuserid = null, $full = false, $user = ...@@ -224,8 +225,8 @@ function qa_db_posts_basic_selectspec($voteuserid = null, $full = false, $user =
* comment) which is related to the main post (question) retrieved. Pass the name of table which will contain the other * comment) which is related to the main post (question) retrieved. Pass the name of table which will contain the other
* post in $poststable. Set $fromupdated to true to get information about when this other post was edited, rather than * post in $poststable. Set $fromupdated to true to get information about when this other post was edited, rather than
* created. If $full is true, get full information on this other post. * created. If $full is true, get full information on this other post.
* @param $selectspec * @param array $selectspec
* @param $poststable * @param string $poststable
* @param bool $fromupdated * @param bool $fromupdated
* @param bool $full * @param bool $full
*/ */
...@@ -263,9 +264,9 @@ function qa_db_add_selectspec_opost(&$selectspec, $poststable, $fromupdated = fa ...@@ -263,9 +264,9 @@ function qa_db_add_selectspec_opost(&$selectspec, $poststable, $fromupdated = fa
* post (answer or comment) which is related to the main post (question) retrieved. Pass the name of table which will * post (answer or comment) which is related to the main post (question) retrieved. Pass the name of table which will
* contain the other user's details in $userstable and the name of the table which will contain the other user's points * contain the other user's details in $userstable and the name of the table which will contain the other user's points
* in $pointstable. * in $pointstable.
* @param $selectspec * @param array $selectspec
* @param $userstable * @param string $userstable
* @param $pointstable * @param string $pointstable
*/ */
function qa_db_add_selectspec_ousers(&$selectspec, $userstable, $pointstable) function qa_db_add_selectspec_ousers(&$selectspec, $userstable, $pointstable)
{ {
...@@ -285,7 +286,7 @@ function qa_db_add_selectspec_ousers(&$selectspec, $userstable, $pointstable) ...@@ -285,7 +286,7 @@ function qa_db_add_selectspec_ousers(&$selectspec, $userstable, $pointstable)
/** /**
* Given $categoryslugs in order of the hierarchiy, return the equivalent value for the backpath column in the categories table * Given $categoryslugs in order of the hierarchiy, return the equivalent value for the backpath column in the categories table
* @param $categoryslugs * @param array $categoryslugs
* @return string * @return string
*/ */
function qa_db_slugs_to_backpath($categoryslugs) function qa_db_slugs_to_backpath($categoryslugs)
...@@ -301,8 +302,8 @@ function qa_db_slugs_to_backpath($categoryslugs) ...@@ -301,8 +302,8 @@ function qa_db_slugs_to_backpath($categoryslugs)
/** /**
* Return SQL code that represents the constraint of a post being in the category with $categoryslugs, or any of its subcategories * Return SQL code that represents the constraint of a post being in the category with $categoryslugs, or any of its subcategories
* @param $categoryslugs * @param array $categoryslugs
* @param $arguments * @param array $arguments
* @return string * @return string
*/ */
function qa_db_categoryslugs_sql_args($categoryslugs, &$arguments) function qa_db_categoryslugs_sql_args($categoryslugs, &$arguments)
...@@ -328,14 +329,14 @@ function qa_db_categoryslugs_sql_args($categoryslugs, &$arguments) ...@@ -328,14 +329,14 @@ function qa_db_categoryslugs_sql_args($categoryslugs, &$arguments)
* restricted to $createip (if not null) and the category for $categoryslugs (if not null), with the corresponding vote * restricted to $createip (if not null) and the category for $categoryslugs (if not null), with the corresponding vote
* made by $voteuserid (if not null) and including $full content or not. Return $count (if null, a default is used) * made by $voteuserid (if not null) and including $full content or not. Return $count (if null, a default is used)
* questions starting from offset $start. * questions starting from offset $start.
* @param $voteuserid * @param mixed $voteuserid
* @param $sort * @param string $sort
* @param $start * @param int $start
* @param $categoryslugs * @param array|null $categoryslugs
* @param $createip * @param string|null $createip
* @param bool $specialtype * @param bool $specialtype
* @param bool $full * @param bool $full
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_qs_selectspec($voteuserid, $sort, $start, $categoryslugs = null, $createip = null, $specialtype = false, $full = false, $count = null) function qa_db_qs_selectspec($voteuserid, $sort, $start, $categoryslugs = null, $createip = null, $specialtype = false, $full = false, $count = null)
...@@ -392,13 +393,13 @@ function qa_db_qs_selectspec($voteuserid, $sort, $start, $categoryslugs = null, ...@@ -392,13 +393,13 @@ function qa_db_qs_selectspec($voteuserid, $sort, $start, $categoryslugs = null,
* questions are restricted to the category for $categoryslugs (if not null), and will have the corresponding vote made * questions are restricted to the category for $categoryslugs (if not null), and will have the corresponding vote made
* by $voteuserid (if not null) and will include $full content or not. Return $count (if null, a default is used) * by $voteuserid (if not null) and will include $full content or not. Return $count (if null, a default is used)
* questions starting from offset $start. * questions starting from offset $start.
* @param $voteuserid * @param mixed $voteuserid
* @param $by * @param string $by
* @param $start * @param int $start
* @param $categoryslugs * @param array|null $categoryslugs
* @param bool $specialtype * @param bool $specialtype
* @param bool $full * @param bool $full
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_unanswered_qs_selectspec($voteuserid, $by, $start, $categoryslugs = null, $specialtype = false, $full = false, $count = null) function qa_db_unanswered_qs_selectspec($voteuserid, $by, $start, $categoryslugs = null, $specialtype = false, $full = false, $count = null)
...@@ -443,13 +444,13 @@ function qa_db_unanswered_qs_selectspec($voteuserid, $by, $start, $categoryslugs ...@@ -443,13 +444,13 @@ function qa_db_unanswered_qs_selectspec($voteuserid, $by, $start, $categoryslugs
* corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used) * corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used)
* questions starting from offset $start. The selectspec will also retrieve some information about the answers * questions starting from offset $start. The selectspec will also retrieve some information about the answers
* themselves (including the content if $fullanswers is true), in columns named with the prefix 'o'. * themselves (including the content if $fullanswers is true), in columns named with the prefix 'o'.
* @param $voteuserid * @param mixed $voteuserid
* @param $start * @param int $start
* @param $categoryslugs * @param array|null $categoryslugs
* @param $createip * @param string|null $createip
* @param bool $specialtype * @param bool $specialtype
* @param bool $fullanswers * @param bool $fullanswers
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_recent_a_qs_selectspec($voteuserid, $start, $categoryslugs = null, $createip = null, $specialtype = false, $fullanswers = false, $count = null) function qa_db_recent_a_qs_selectspec($voteuserid, $start, $categoryslugs = null, $createip = null, $specialtype = false, $fullanswers = false, $count = null)
...@@ -495,13 +496,13 @@ function qa_db_recent_a_qs_selectspec($voteuserid, $start, $categoryslugs = null ...@@ -495,13 +496,13 @@ function qa_db_recent_a_qs_selectspec($voteuserid, $start, $categoryslugs = null
* corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used) * corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used)
* questions starting from offset $start. The selectspec will also retrieve some information about the comments * questions starting from offset $start. The selectspec will also retrieve some information about the comments
* themselves (including the content if $fullcomments is true), in columns named with the prefix 'o'. * themselves (including the content if $fullcomments is true), in columns named with the prefix 'o'.
* @param $voteuserid * @param mixed $voteuserid
* @param $start * @param int $start
* @param $categoryslugs * @param array|null $categoryslugs
* @param $createip * @param string|null $createip
* @param bool $specialtype * @param bool $specialtype
* @param bool $fullcomments * @param bool $fullcomments
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_recent_c_qs_selectspec($voteuserid, $start, $categoryslugs = null, $createip = null, $specialtype = false, $fullcomments = false, $count = null) function qa_db_recent_c_qs_selectspec($voteuserid, $start, $categoryslugs = null, $createip = null, $specialtype = false, $fullcomments = false, $count = null)
...@@ -549,13 +550,13 @@ function qa_db_recent_c_qs_selectspec($voteuserid, $start, $categoryslugs = null ...@@ -549,13 +550,13 @@ function qa_db_recent_c_qs_selectspec($voteuserid, $start, $categoryslugs = null
* corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used) * corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used)
* questions starting from offset $start. The selectspec will also retrieve some information about the edited posts * questions starting from offset $start. The selectspec will also retrieve some information about the edited posts
* themselves (including the content if $fulledited is true), in columns named with the prefix 'o'. * themselves (including the content if $fulledited is true), in columns named with the prefix 'o'.
* @param $voteuserid * @param mixed $voteuserid
* @param $start * @param int $start
* @param $categoryslugs * @param array|null $categoryslugs
* @param $lastip * @param string|null $lastip
* @param bool $onlyvisible * @param bool $onlyvisible
* @param bool $fulledited * @param bool $fulledited
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_recent_edit_qs_selectspec($voteuserid, $start, $categoryslugs = null, $lastip = null, $onlyvisible = true, $fulledited = false, $count = null) function qa_db_recent_edit_qs_selectspec($voteuserid, $start, $categoryslugs = null, $lastip = null, $onlyvisible = true, $fulledited = false, $count = null)
...@@ -597,10 +598,10 @@ function qa_db_recent_edit_qs_selectspec($voteuserid, $start, $categoryslugs = n ...@@ -597,10 +598,10 @@ function qa_db_recent_edit_qs_selectspec($voteuserid, $start, $categoryslugs = n
* on those questions made by $voteuserid (if not null). Return $count (if null, a default is used) questions starting * on those questions made by $voteuserid (if not null). Return $count (if null, a default is used) questions starting
* from offset $start. The selectspec will also retrieve some information about the flagged posts themselves (including * from offset $start. The selectspec will also retrieve some information about the flagged posts themselves (including
* the content if $fullflagged is true). * the content if $fullflagged is true).
* @param $voteuserid * @param mixed $voteuserid
* @param $start * @param int $start
* @param bool $fullflagged * @param bool $fullflagged
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_flagged_post_qs_selectspec($voteuserid, $start, $fullflagged = false, $count = null) function qa_db_flagged_post_qs_selectspec($voteuserid, $start, $fullflagged = false, $count = null)
...@@ -632,8 +633,8 @@ function qa_db_flagged_post_qs_selectspec($voteuserid, $start, $fullflagged = fa ...@@ -632,8 +633,8 @@ function qa_db_flagged_post_qs_selectspec($voteuserid, $start, $fullflagged = fa
/** /**
* Return the selectspec to retrieve the posts in $postids, with the corresponding vote on those posts made by * Return the selectspec to retrieve the posts in $postids, with the corresponding vote on those posts made by
* $voteuserid (if not null). Returns full information if $full is true. * $voteuserid (if not null). Returns full information if $full is true.
* @param $voteuserid * @param mixed $voteuserid
* @param $postids * @param array $postids
* @param bool $full * @param bool $full
* @return array * @return array
*/ */
...@@ -650,7 +651,7 @@ function qa_db_posts_selectspec($voteuserid, $postids, $full = false) ...@@ -650,7 +651,7 @@ function qa_db_posts_selectspec($voteuserid, $postids, $full = false)
/** /**
* Return the selectspec to retrieve the basetype for the posts in $postids, as an array mapping postid => basetype * Return the selectspec to retrieve the basetype for the posts in $postids, as an array mapping postid => basetype
* @param $postids * @param array $postids
* @return array * @return array
*/ */
function qa_db_posts_basetype_selectspec($postids) function qa_db_posts_basetype_selectspec($postids)
...@@ -667,8 +668,8 @@ function qa_db_posts_basetype_selectspec($postids) ...@@ -667,8 +668,8 @@ function qa_db_posts_basetype_selectspec($postids)
/** /**
* Return the selectspec to retrieve the basetype for the posts in $postids, as an array mapping postid => basetype * Return the selectspec to retrieve the basetype for the posts in $postids, as an array mapping postid => basetype
* @param $voteuserid * @param mixed $voteuserid
* @param $postids * @param array $postids
* @param bool $full * @param bool $full
* @return array * @return array
*/ */
...@@ -694,8 +695,8 @@ function qa_db_posts_to_qs_selectspec($voteuserid, $postids, $full = false) ...@@ -694,8 +695,8 @@ function qa_db_posts_to_qs_selectspec($voteuserid, $postids, $full = false)
/** /**
* Return the selectspec to retrieve the full information for $postid, with the corresponding vote made by $voteuserid (if not null) * Return the selectspec to retrieve the full information for $postid, with the corresponding vote made by $voteuserid (if not null)
* @param $voteuserid * @param mixed $voteuserid
* @param $postid * @param int $postid
* @return array * @return array
*/ */
function qa_db_full_post_selectspec($voteuserid, $postid) function qa_db_full_post_selectspec($voteuserid, $postid)
...@@ -713,8 +714,8 @@ function qa_db_full_post_selectspec($voteuserid, $postid) ...@@ -713,8 +714,8 @@ function qa_db_full_post_selectspec($voteuserid, $postid)
/** /**
* Return the selectspec to retrieve the full information for all posts whose parent is $parentid, with the * Return the selectspec to retrieve the full information for all posts whose parent is $parentid, with the
* corresponding vote made by $voteuserid (if not null) * corresponding vote made by $voteuserid (if not null)
* @param $voteuserid * @param mixed $voteuserid
* @param $parentid * @param int $parentid
* @return array * @return array
*/ */
function qa_db_full_child_posts_selectspec($voteuserid, $parentid) function qa_db_full_child_posts_selectspec($voteuserid, $parentid)
...@@ -731,8 +732,8 @@ function qa_db_full_child_posts_selectspec($voteuserid, $parentid) ...@@ -731,8 +732,8 @@ function qa_db_full_child_posts_selectspec($voteuserid, $parentid)
/** /**
* Return the selectspec to retrieve the full information for all posts whose parent is an answer which * Return the selectspec to retrieve the full information for all posts whose parent is an answer which
* has $questionid as its parent, with the corresponding vote made by $voteuserid (if not null) * has $questionid as its parent, with the corresponding vote made by $voteuserid (if not null)
* @param $voteuserid * @param mixed $voteuserid
* @param $questionid * @param int $questionid
* @return array * @return array
*/ */
function qa_db_full_a_child_posts_selectspec($voteuserid, $questionid) function qa_db_full_a_child_posts_selectspec($voteuserid, $questionid)
...@@ -749,7 +750,7 @@ function qa_db_full_a_child_posts_selectspec($voteuserid, $questionid) ...@@ -749,7 +750,7 @@ function qa_db_full_a_child_posts_selectspec($voteuserid, $questionid)
/** /**
* Return the selectspec to retrieve the question for the parent of $postid (where $postid is of a follow-on question or comment), * Return the selectspec to retrieve the question for the parent of $postid (where $postid is of a follow-on question or comment),
* i.e. the parent of $questionid's parent if $questionid's parent is an answer, otherwise $questionid's parent itself. * i.e. the parent of $questionid's parent if $questionid's parent is an answer, otherwise $questionid's parent itself.
* @param $postid * @param int $postid
* @return array * @return array
*/ */
function qa_db_post_parent_q_selectspec($postid) function qa_db_post_parent_q_selectspec($postid)
...@@ -766,7 +767,7 @@ function qa_db_post_parent_q_selectspec($postid) ...@@ -766,7 +767,7 @@ function qa_db_post_parent_q_selectspec($postid)
/** /**
* Return the selectspec to retrieve the post (either duplicate question or explanatory note) which has closed $questionid, if any * Return the selectspec to retrieve the post (either duplicate question or explanatory note) which has closed $questionid, if any
* @param $questionid * @param int $questionid
* @return array * @return array
*/ */
function qa_db_post_close_post_selectspec($questionid) function qa_db_post_close_post_selectspec($questionid)
...@@ -783,7 +784,7 @@ function qa_db_post_close_post_selectspec($questionid) ...@@ -783,7 +784,7 @@ function qa_db_post_close_post_selectspec($questionid)
/** /**
* Return the selectspec to retrieve the posts that have been closed as a duplicate of this question, if any * Return the selectspec to retrieve the posts that have been closed as a duplicate of this question, if any
* @param $questionid int The canonical question. * @param int $questionid int The canonical question.
* @return array * @return array
*/ */
function qa_db_post_duplicates_selectspec($questionid) function qa_db_post_duplicates_selectspec($questionid)
...@@ -798,9 +799,10 @@ function qa_db_post_duplicates_selectspec($questionid) ...@@ -798,9 +799,10 @@ function qa_db_post_duplicates_selectspec($questionid)
/** /**
* Return the selectspec to retrieve the metadata value for $postid with key $title * Return the selectspec to retrieve the metadata value for $postid with key $title. If $title is an array then the
* @param $postid * selectspec will return an array of the matched titles.
* @param $title * @param int $postid
* @param string|array $title
* @return array * @return array
*/ */
function qa_db_post_meta_selectspec($postid, $title) function qa_db_post_meta_selectspec($postid, $title)
...@@ -826,9 +828,9 @@ function qa_db_post_meta_selectspec($postid, $title) ...@@ -826,9 +828,9 @@ function qa_db_post_meta_selectspec($postid, $title)
* Return the selectspec to retrieve the most closely related questions to $questionid, with the corresponding vote * Return the selectspec to retrieve the most closely related questions to $questionid, with the corresponding vote
* made by $voteuserid (if not null). Return $count (if null, a default is used) questions. This works by looking for * made by $voteuserid (if not null). Return $count (if null, a default is used) questions. This works by looking for
* other questions which have title words, tag words or an (exact) category in common. * other questions which have title words, tag words or an (exact) category in common.
* @param $voteuserid * @param mixed $voteuserid
* @param $questionid * @param int $questionid
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_related_qs_selectspec($voteuserid, $questionid, $count = null) function qa_db_related_qs_selectspec($voteuserid, $questionid, $count = null)
...@@ -869,15 +871,15 @@ function qa_db_related_qs_selectspec($voteuserid, $questionid, $count = null) ...@@ -869,15 +871,15 @@ function qa_db_related_qs_selectspec($voteuserid, $questionid, $count = null)
* where the score came from (since a question could get weight from a match in the question itself, and/or weight from * where the score came from (since a question could get weight from a match in the question itself, and/or weight from
* a match in its answers, comments, or comments on answers). The 'matchparts' is a comma-separated list of tuples * a match in its answers, comments, or comments on answers). The 'matchparts' is a comma-separated list of tuples
* matchtype:matchpostid:matchscore to be used with qa_search_set_max_match(). * matchtype:matchpostid:matchscore to be used with qa_search_set_max_match().
* @param $voteuserid * @param mixed $voteuserid
* @param $titlewords * @param string $titlewords
* @param $contentwords * @param string $contentwords
* @param $tagwords * @param array $tagwords
* @param $handlewords * @param string $handlewords
* @param $handle * @param string $handle
* @param $start * @param int $start
* @param bool $full * @param bool $full
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_search_posts_selectspec($voteuserid, $titlewords, $contentwords, $tagwords, $handlewords, $handle, $start, $full = false, $count = null) function qa_db_search_posts_selectspec($voteuserid, $titlewords, $contentwords, $tagwords, $handlewords, $handle, $start, $full = false, $count = null)
...@@ -985,10 +987,9 @@ function qa_db_search_posts_selectspec($voteuserid, $titlewords, $contentwords, ...@@ -985,10 +987,9 @@ function qa_db_search_posts_selectspec($voteuserid, $titlewords, $contentwords,
/** /**
* Processes the matchparts column in $question which was returned from a search performed via qa_db_search_posts_selectspec() * Processes the matchparts column in $question which was returned from a search performed via qa_db_search_posts_selectspec()
* Returns the id of the strongest matching answer or comment, or null if the question itself was the strongest match * Returns the id of the strongest matching answer or comment, or null if the question itself was the strongest match
* @param $question * @param array $question
* @param $type * @param string $type
* @param $postid * @param int $postid
* @return null
*/ */
function qa_search_set_max_match($question, &$type, &$postid) function qa_search_set_max_match($question, &$type, &$postid)
{ {
...@@ -1006,16 +1007,14 @@ function qa_search_set_max_match($question, &$type, &$postid) ...@@ -1006,16 +1007,14 @@ function qa_search_set_max_match($question, &$type, &$postid)
} }
} }
} }
return null;
} }
/** /**
* Return a selectspec to retrieve the full information on the category whose id is $slugsorid (if $isid is true), * Return a selectspec to retrieve the full information on the category whose id is $slugsorid (if $isid is true),
* otherwise whose backpath matches $slugsorid * otherwise whose backpath matches $slugsorid
* @param $slugsorid * @param int|array $slugsorid
* @param $isid * @param bool $isid
* @return array * @return array
*/ */
function qa_db_full_category_selectspec($slugsorid, $isid) function qa_db_full_category_selectspec($slugsorid, $isid)
...@@ -1042,8 +1041,8 @@ function qa_db_full_category_selectspec($slugsorid, $isid) ...@@ -1042,8 +1041,8 @@ function qa_db_full_category_selectspec($slugsorid, $isid)
* top level, any ancestors (at any level) of the category, the category's siblings and sub-categories (to one level). * top level, any ancestors (at any level) of the category, the category's siblings and sub-categories (to one level).
* The central category is specified as follows. If $isid AND $ispostid then $slugsorid is the ID of a post with the category. * The central category is specified as follows. If $isid AND $ispostid then $slugsorid is the ID of a post with the category.
* Otherwise if $isid then $slugsorid is the category's own id. Otherwise $slugsorid is the full backpath of the category. * Otherwise if $isid then $slugsorid is the category's own id. Otherwise $slugsorid is the full backpath of the category.
* @param $slugsorid * @param int|array $slugsorid
* @param $isid * @param bool $isid
* @param bool $ispostid * @param bool $ispostid
* @param bool $full * @param bool $full
* @return array * @return array
...@@ -1106,7 +1105,7 @@ function qa_db_category_nav_selectspec($slugsorid, $isid, $ispostid = false, $fu ...@@ -1106,7 +1105,7 @@ function qa_db_category_nav_selectspec($slugsorid, $isid, $ispostid = false, $fu
/** /**
* Return the selectspec to retrieve information on all subcategories of $categoryid (used for Ajax navigation of hierarchy) * Return the selectspec to retrieve information on all subcategories of $categoryid (used for Ajax navigation of hierarchy)
* @param $categoryid * @param int $categoryid
* @return array * @return array
*/ */
function qa_db_category_sub_selectspec($categoryid) function qa_db_category_sub_selectspec($categoryid)
...@@ -1123,7 +1122,7 @@ function qa_db_category_sub_selectspec($categoryid) ...@@ -1123,7 +1122,7 @@ function qa_db_category_sub_selectspec($categoryid)
/** /**
* Return the selectspec to retrieve a single category as specified by its $slugs (in order of hierarchy) * Return the selectspec to retrieve a single category as specified by its $slugs (in order of hierarchy)
* @param $slugs * @param array $slugs
* @return array * @return array
*/ */
function qa_db_slugs_to_category_id_selectspec($slugs) function qa_db_slugs_to_category_id_selectspec($slugs)
...@@ -1140,8 +1139,8 @@ function qa_db_slugs_to_category_id_selectspec($slugs) ...@@ -1140,8 +1139,8 @@ function qa_db_slugs_to_category_id_selectspec($slugs)
/** /**
* Return the selectspec to retrieve the list of custom pages or links, ordered for display * Return the selectspec to retrieve the list of custom pages or links, ordered for display
* @param $onlynavin * @param array $onlynavin
* @param $onlypageids * @param array $onlypageids
* @return array * @return array
*/ */
function qa_db_pages_selectspec($onlynavin = null, $onlypageids = null) function qa_db_pages_selectspec($onlynavin = null, $onlypageids = null)
...@@ -1169,6 +1168,7 @@ function qa_db_pages_selectspec($onlynavin = null, $onlypageids = null) ...@@ -1169,6 +1168,7 @@ function qa_db_pages_selectspec($onlynavin = null, $onlypageids = null)
/** /**
* Return the selectspec to retrieve the list of widgets, ordered for display * Return the selectspec to retrieve the list of widgets, ordered for display
* @return array
*/ */
function qa_db_widgets_selectspec() function qa_db_widgets_selectspec()
{ {
...@@ -1182,8 +1182,8 @@ function qa_db_widgets_selectspec() ...@@ -1182,8 +1182,8 @@ function qa_db_widgets_selectspec()
/** /**
* Return the selectspec to retrieve the full information about a custom page * Return the selectspec to retrieve the full information about a custom page
* @param $slugorpageid * @param int|array $slugorpageid
* @param $ispageid * @param bool $ispageid
* @return array * @return array
*/ */
function qa_db_page_full_selectspec($slugorpageid, $ispageid) function qa_db_page_full_selectspec($slugorpageid, $ispageid)
...@@ -1201,11 +1201,11 @@ function qa_db_page_full_selectspec($slugorpageid, $ispageid) ...@@ -1201,11 +1201,11 @@ function qa_db_page_full_selectspec($slugorpageid, $ispageid)
* Return the selectspec to retrieve the most recent questions with $tag, with the corresponding vote on those * Return the selectspec to retrieve the most recent questions with $tag, with the corresponding vote on those
* questions made by $voteuserid (if not null) and including $full content or not. Return $count (if null, a default is * questions made by $voteuserid (if not null) and including $full content or not. Return $count (if null, a default is
* used) questions starting from $start. * used) questions starting from $start.
* @param $voteuserid * @param mixed $voteuserid
* @param $tag * @param string $tag
* @param $start * @param int $start
* @param bool $full * @param bool $full
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_tag_recent_qs_selectspec($voteuserid, $tag, $start, $full = false, $count = null) function qa_db_tag_recent_qs_selectspec($voteuserid, $tag, $start, $full = false, $count = null)
...@@ -1227,7 +1227,7 @@ function qa_db_tag_recent_qs_selectspec($voteuserid, $tag, $start, $full = false ...@@ -1227,7 +1227,7 @@ function qa_db_tag_recent_qs_selectspec($voteuserid, $tag, $start, $full = false
/** /**
* Return the selectspec to retrieve the number of questions tagged with $tag (single value) * Return the selectspec to retrieve the number of questions tagged with $tag (single value)
* @param $tag * @param string $tag
* @return array * @return array
*/ */
function qa_db_tag_word_selectspec($tag) function qa_db_tag_word_selectspec($tag)
...@@ -1246,9 +1246,9 @@ function qa_db_tag_word_selectspec($tag) ...@@ -1246,9 +1246,9 @@ function qa_db_tag_word_selectspec($tag)
* handle if we're using internal user management, or a userid if we're using external users. Also include the * handle if we're using internal user management, or a userid if we're using external users. Also include the
* corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used) * corresponding vote on those questions made by $voteuserid (if not null). Return $count (if null, a default is used)
* questions. * questions.
* @param $voteuserid * @param mixed $voteuserid
* @param $identifier * @param mixed $identifier
* @param $count * @param int|null $count
* @param int $start * @param int $start
* @return array * @return array
*/ */
...@@ -1271,9 +1271,9 @@ function qa_db_user_recent_qs_selectspec($voteuserid, $identifier, $count = null ...@@ -1271,9 +1271,9 @@ function qa_db_user_recent_qs_selectspec($voteuserid, $identifier, $count = null
* (see qa_db_user_recent_qs_selectspec() comment), with the corresponding vote on those questions made by $voteuserid * (see qa_db_user_recent_qs_selectspec() comment), with the corresponding vote on those questions made by $voteuserid
* (if not null). Return $count (if null, a default is used) questions. The selectspec will also retrieve some * (if not null). Return $count (if null, a default is used) questions. The selectspec will also retrieve some
* information about the answers themselves, in columns named with the prefix 'o'. * information about the answers themselves, in columns named with the prefix 'o'.
* @param $voteuserid * @param mixed $voteuserid
* @param $identifier * @param mixed $identifier
* @param $count * @param int|null $count
* @param int $start * @param int $start
* @return array * @return array
*/ */
...@@ -1307,9 +1307,9 @@ function qa_db_user_recent_a_qs_selectspec($voteuserid, $identifier, $count = nu ...@@ -1307,9 +1307,9 @@ function qa_db_user_recent_a_qs_selectspec($voteuserid, $identifier, $count = nu
* (see qa_db_user_recent_qs_selectspec() comment), with the corresponding vote on those questions made by $voteuserid * (see qa_db_user_recent_qs_selectspec() comment), with the corresponding vote on those questions made by $voteuserid
* (if not null). Return $count (if null, a default is used) questions. The selectspec will also retrieve some * (if not null). Return $count (if null, a default is used) questions. The selectspec will also retrieve some
* information about the comments themselves, in columns named with the prefix 'o'. * information about the comments themselves, in columns named with the prefix 'o'.
* @param $voteuserid * @param mixed $voteuserid
* @param $identifier * @param mixed $identifier
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_user_recent_c_qs_selectspec($voteuserid, $identifier, $count = null) function qa_db_user_recent_c_qs_selectspec($voteuserid, $identifier, $count = null)
...@@ -1340,9 +1340,9 @@ function qa_db_user_recent_c_qs_selectspec($voteuserid, $identifier, $count = nu ...@@ -1340,9 +1340,9 @@ function qa_db_user_recent_c_qs_selectspec($voteuserid, $identifier, $count = nu
* $identifier (see qa_db_user_recent_qs_selectspec() comment), with the corresponding vote on those questions made by * $identifier (see qa_db_user_recent_qs_selectspec() comment), with the corresponding vote on those questions made by
* $voteuserid (if not null). Return $count (if null, a default is used) questions. The selectspec will also retrieve * $voteuserid (if not null). Return $count (if null, a default is used) questions. The selectspec will also retrieve
* some information about the edited posts themselves, in columns named with the prefix 'o'. * some information about the edited posts themselves, in columns named with the prefix 'o'.
* @param $voteuserid * @param mixed $voteuserid
* @param $identifier * @param mixed $identifier
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_user_recent_edit_qs_selectspec($voteuserid, $identifier, $count = null) function qa_db_user_recent_edit_qs_selectspec($voteuserid, $identifier, $count = null)
...@@ -1372,8 +1372,8 @@ function qa_db_user_recent_edit_qs_selectspec($voteuserid, $identifier, $count = ...@@ -1372,8 +1372,8 @@ function qa_db_user_recent_edit_qs_selectspec($voteuserid, $identifier, $count =
/** /**
* Return the selectspec to retrieve the most popular tags. Return $count (if null, a default is used) tags, starting * Return the selectspec to retrieve the most popular tags. Return $count (if null, a default is used) tags, starting
* from offset $start. The selectspec will produce a sorted array with tags in the key, and counts in the values. * from offset $start. The selectspec will produce a sorted array with tags in the key, and counts in the values.
* @param $start * @param int $start
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_popular_tags_selectspec($start, $count = null) function qa_db_popular_tags_selectspec($start, $count = null)
...@@ -1408,8 +1408,8 @@ function qa_db_userfields_selectspec() ...@@ -1408,8 +1408,8 @@ function qa_db_userfields_selectspec()
/** /**
* Return the selecspec to retrieve a single array with details of the account of the user identified by * Return the selecspec to retrieve a single array with details of the account of the user identified by
* $useridhandle, which should be a userid if $isuserid is true, otherwise $useridhandle should be a handle. * $useridhandle, which should be a userid if $isuserid is true, otherwise $useridhandle should be a handle.
* @param $useridhandle * @param mixed $useridhandle
* @param $isuserid * @param bool $isuserid
* @return array * @return array
*/ */
function qa_db_user_account_selectspec($useridhandle, $isuserid) function qa_db_user_account_selectspec($useridhandle, $isuserid)
...@@ -1433,8 +1433,8 @@ function qa_db_user_account_selectspec($useridhandle, $isuserid) ...@@ -1433,8 +1433,8 @@ function qa_db_user_account_selectspec($useridhandle, $isuserid)
/** /**
* Return the selectspec to retrieve all user profile information of the user identified by * Return the selectspec to retrieve all user profile information of the user identified by
* $useridhandle (see qa_db_user_account_selectspec() comment), as an array of [field] => [value] * $useridhandle (see qa_db_user_account_selectspec() comment), as an array of [field] => [value]
* @param $useridhandle * @param mixed $useridhandle
* @param $isuserid * @param bool $isuserid
* @return array * @return array
*/ */
function qa_db_user_profile_selectspec($useridhandle, $isuserid) function qa_db_user_profile_selectspec($useridhandle, $isuserid)
...@@ -1451,7 +1451,7 @@ function qa_db_user_profile_selectspec($useridhandle, $isuserid) ...@@ -1451,7 +1451,7 @@ function qa_db_user_profile_selectspec($useridhandle, $isuserid)
/** /**
* Return the selectspec to retrieve all notices for the user $userid * Return the selectspec to retrieve all notices for the user $userid
* @param $userid * @param mixed $userid
* @return array * @return array
*/ */
function qa_db_user_notices_selectspec($userid) function qa_db_user_notices_selectspec($userid)
...@@ -1468,7 +1468,7 @@ function qa_db_user_notices_selectspec($userid) ...@@ -1468,7 +1468,7 @@ function qa_db_user_notices_selectspec($userid)
/** /**
* Return the selectspec to retrieve all columns from the userpoints table for the user identified by $identifier * Return the selectspec to retrieve all columns from the userpoints table for the user identified by $identifier
* (see qa_db_user_recent_qs_selectspec() comment), as a single array * (see qa_db_user_recent_qs_selectspec() comment), as a single array
* @param $identifier * @param mixed $identifier
* @param bool $isuserid * @param bool $isuserid
* @return array * @return array
*/ */
...@@ -1486,7 +1486,7 @@ function qa_db_user_points_selectspec($identifier, $isuserid = QA_FINAL_EXTERNAL ...@@ -1486,7 +1486,7 @@ function qa_db_user_points_selectspec($identifier, $isuserid = QA_FINAL_EXTERNAL
/** /**
* Return the selectspec to calculate the rank in points of the user identified by $identifier * Return the selectspec to calculate the rank in points of the user identified by $identifier
* (see qa_db_user_recent_qs_selectspec() comment), as a single value * (see qa_db_user_recent_qs_selectspec() comment), as a single value
* @param $identifier * @param mixed $identifier
* @param bool $isuserid * @param bool $isuserid
* @return array * @return array
*/ */
...@@ -1505,8 +1505,8 @@ function qa_db_user_rank_selectspec($identifier, $isuserid = QA_FINAL_EXTERNAL_U ...@@ -1505,8 +1505,8 @@ function qa_db_user_rank_selectspec($identifier, $isuserid = QA_FINAL_EXTERNAL_U
/** /**
* Return the selectspec to get the top scoring users, with handles if we're using internal user management. Return * Return the selectspec to get the top scoring users, with handles if we're using internal user management. Return
* $count (if null, a default is used) users starting from the offset $start. * $count (if null, a default is used) users starting from the offset $start.
* @param $start * @param int $start
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_top_users_selectspec($start, $count = null) function qa_db_top_users_selectspec($start, $count = null)
...@@ -1544,8 +1544,8 @@ function qa_db_top_users_selectspec($start, $count = null) ...@@ -1544,8 +1544,8 @@ function qa_db_top_users_selectspec($start, $count = null)
/** /**
* Return the selectspec to get the newest users. Return $count (if null, a default is used) users starting from the * Return the selectspec to get the newest users. Return $count (if null, a default is used) users starting from the
* offset $start. This query must not be run when using external users * offset $start. This query must not be run when using external users
* @param $start * @param int $start
* @param $count * @param int|null $count
* @return array * @return array
*/ */
function qa_db_newest_users_selectspec($start, $count = null) function qa_db_newest_users_selectspec($start, $count = null)
...@@ -1564,7 +1564,7 @@ function qa_db_newest_users_selectspec($start, $count = null) ...@@ -1564,7 +1564,7 @@ function qa_db_newest_users_selectspec($start, $count = null)
/** /**
* Return the selectspec to get information about users at a certain privilege level or higher * Return the selectspec to get information about users at a certain privilege level or higher
* @param $level * @param int $level
* @return array * @return array
*/ */
function qa_db_users_from_level_selectspec($level) function qa_db_users_from_level_selectspec($level)
...@@ -1580,9 +1580,9 @@ function qa_db_users_from_level_selectspec($level) ...@@ -1580,9 +1580,9 @@ function qa_db_users_from_level_selectspec($level)
/** /**
* Return the selectspec to get information about users with the $flag bit set (unindexed query) * Return the selectspec to get information about users with the $flag bit set (unindexed query)
* @param $flag * @param int $flag
* @param int $start * @param int $start
* @param $limit * @param int|null $limit
* @return array * @return array
*/ */
function qa_db_users_with_flag_selectspec($flag, $start = 0, $limit = null) function qa_db_users_with_flag_selectspec($flag, $start = 0, $limit = null)
...@@ -1606,6 +1606,7 @@ function qa_db_users_with_flag_selectspec($flag, $start = 0, $limit = null) ...@@ -1606,6 +1606,7 @@ function qa_db_users_with_flag_selectspec($flag, $start = 0, $limit = null)
/** /**
* Return columns for standard messages selectspec * Return columns for standard messages selectspec
* @return array
*/ */
function qa_db_messages_columns() function qa_db_messages_columns()
{ {
...@@ -1631,11 +1632,11 @@ function qa_db_messages_columns() ...@@ -1631,11 +1632,11 @@ function qa_db_messages_columns()
* the user identified by $fromidentifier+$fromisuserid to the user identified by $toidentifier+$toisuserid (see * the user identified by $fromidentifier+$fromisuserid to the user identified by $toidentifier+$toisuserid (see
* qa_db_user_recent_qs_selectspec() comment). If $fromidentifier is null, then get recent wall posts * qa_db_user_recent_qs_selectspec() comment). If $fromidentifier is null, then get recent wall posts
* for the user identified by $toidentifier+$toisuserid. Return $count (if null, a default is used) messages. * for the user identified by $toidentifier+$toisuserid. Return $count (if null, a default is used) messages.
* @param $fromidentifier * @param mixed $fromidentifier
* @param $fromisuserid * @param bool $fromisuserid
* @param $toidentifier * @param mixed $toidentifier
* @param $toisuserid * @param bool $toisuserid
* @param $count * @param int|null $count
* @param int $start * @param int $start
* @return array * @return array
*/ */
...@@ -1669,11 +1670,11 @@ function qa_db_recent_messages_selectspec($fromidentifier, $fromisuserid, $toide ...@@ -1669,11 +1670,11 @@ function qa_db_recent_messages_selectspec($fromidentifier, $fromisuserid, $toide
* Get selectspec for messages *to* specified user. $type is either 'public' or 'private'. * Get selectspec for messages *to* specified user. $type is either 'public' or 'private'.
* $toidentifier is a handle or userid depending on the value of $toisuserid. * $toidentifier is a handle or userid depending on the value of $toisuserid.
* Returns $limit messages, or all of them if $limit is null (used in qa_db_selectspec_count). * Returns $limit messages, or all of them if $limit is null (used in qa_db_selectspec_count).
* @param $type * @param string $type
* @param $toidentifier * @param mixed $toidentifier
* @param $toisuserid * @param mixed $toisuserid
* @param int $start * @param int $start
* @param $limit * @param int|null $limit
* @return array * @return array
*/ */
function qa_db_messages_inbox_selectspec($type, $toidentifier, $toisuserid, $start = 0, $limit = null) function qa_db_messages_inbox_selectspec($type, $toidentifier, $toisuserid, $start = 0, $limit = null)
...@@ -1705,11 +1706,11 @@ function qa_db_messages_inbox_selectspec($type, $toidentifier, $toisuserid, $sta ...@@ -1705,11 +1706,11 @@ function qa_db_messages_inbox_selectspec($type, $toidentifier, $toisuserid, $sta
* Get selectspec for messages *from* specified user. $type is either 'public' or 'private'. * Get selectspec for messages *from* specified user. $type is either 'public' or 'private'.
* $fromidentifier is a handle or userid depending on the value of $fromisuserid. * $fromidentifier is a handle or userid depending on the value of $fromisuserid.
* Returns $limit messages, or all of them if $limit is null (used in qa_db_selectspec_count). * Returns $limit messages, or all of them if $limit is null (used in qa_db_selectspec_count).
* @param $type * @param string $type
* @param $fromidentifier * @param mixed $fromidentifier
* @param $fromisuserid * @param bool $fromisuserid
* @param int $start * @param int $start
* @param $limit * @param int|null $limit
* @return array * @return array
*/ */
function qa_db_messages_outbox_selectspec($type, $fromidentifier, $fromisuserid, $start = 0, $limit = null) function qa_db_messages_outbox_selectspec($type, $fromidentifier, $fromisuserid, $start = 0, $limit = null)
...@@ -1740,9 +1741,9 @@ function qa_db_messages_outbox_selectspec($type, $fromidentifier, $fromisuserid, ...@@ -1740,9 +1741,9 @@ function qa_db_messages_outbox_selectspec($type, $fromidentifier, $fromisuserid,
/** /**
* Return the selectspec to retrieve whether or not $userid has favorited entity $entitytype identifier by $identifier. * Return the selectspec to retrieve whether or not $userid has favorited entity $entitytype identifier by $identifier.
* The $identifier should be a handle, word, backpath or postid for users, tags, categories and questions respectively. * The $identifier should be a handle, word, backpath or postid for users, tags, categories and questions respectively.
* @param $userid * @param mixed $userid
* @param $entitytype * @param string $entitytype
* @param $identifier * @param mixed $identifier
* @return array * @return array
*/ */
function qa_db_is_favorite_selectspec($userid, $entitytype, $identifier) function qa_db_is_favorite_selectspec($userid, $entitytype, $identifier)
...@@ -1784,8 +1785,8 @@ function qa_db_is_favorite_selectspec($userid, $entitytype, $identifier) ...@@ -1784,8 +1785,8 @@ function qa_db_is_favorite_selectspec($userid, $entitytype, $identifier)
/** /**
* Return the selectspec to retrieve an array of $userid's favorited questions, with the usual information. * Return the selectspec to retrieve an array of $userid's favorited questions, with the usual information.
* Returns $limit questions, or all of them if $limit is null (used in qa_db_selectspec_count). * Returns $limit questions, or all of them if $limit is null (used in qa_db_selectspec_count).
* @param $userid * @param mixed $userid
* @param $limit * @param int|null $limit
* @param int $start * @param int $start
* @return array * @return array
*/ */
...@@ -1815,8 +1816,8 @@ function qa_db_user_favorite_qs_selectspec($userid, $limit = null, $start = 0) ...@@ -1815,8 +1816,8 @@ function qa_db_user_favorite_qs_selectspec($userid, $limit = null, $start = 0)
/** /**
* Return the selectspec to retrieve an array of $userid's favorited users, with information about those users' accounts. * Return the selectspec to retrieve an array of $userid's favorited users, with information about those users' accounts.
* Returns $limit users, or all of them if $limit is null (used in qa_db_selectspec_count). * Returns $limit users, or all of them if $limit is null (used in qa_db_selectspec_count).
* @param $userid * @param mixed $userid
* @param $limit * @param int|null $limit
* @param int $start * @param int $start
* @return array * @return array
*/ */
...@@ -1846,8 +1847,8 @@ function qa_db_user_favorite_users_selectspec($userid, $limit = null, $start = 0 ...@@ -1846,8 +1847,8 @@ function qa_db_user_favorite_users_selectspec($userid, $limit = null, $start = 0
/** /**
* Return the selectspec to retrieve an array of $userid's favorited tags, with information about those tags. * Return the selectspec to retrieve an array of $userid's favorited tags, with information about those tags.
* Returns $limit tags, or all of them if $limit is null (used in qa_db_selectspec_count). * Returns $limit tags, or all of them if $limit is null (used in qa_db_selectspec_count).
* @param $userid * @param mixed $userid
* @param $limit * @param int|null $limit
* @param int $start * @param int $start
* @return array * @return array
*/ */
...@@ -1876,7 +1877,7 @@ function qa_db_user_favorite_tags_selectspec($userid, $limit = null, $start = 0) ...@@ -1876,7 +1877,7 @@ function qa_db_user_favorite_tags_selectspec($userid, $limit = null, $start = 0)
/** /**
* Return the selectspec to retrieve an array of $userid's favorited categories, with information about those categories. * Return the selectspec to retrieve an array of $userid's favorited categories, with information about those categories.
* @param $userid * @param mixed $userid
* @return array * @return array
*/ */
function qa_db_user_favorite_categories_selectspec($userid) function qa_db_user_favorite_categories_selectspec($userid)
...@@ -1895,7 +1896,7 @@ function qa_db_user_favorite_categories_selectspec($userid) ...@@ -1895,7 +1896,7 @@ function qa_db_user_favorite_categories_selectspec($userid)
/** /**
* Return the selectspec to retrieve information about all a user's favorited items except the questions. Depending on * Return the selectspec to retrieve information about all a user's favorited items except the questions. Depending on
* the type of item, the array for each item will contain a userid, category backpath or tag word. * the type of item, the array for each item will contain a userid, category backpath or tag word.
* @param $userid * @param mixed $userid
* @return array * @return array
*/ */
function qa_db_user_favorite_non_qs_selectspec($userid) function qa_db_user_favorite_non_qs_selectspec($userid)
...@@ -1915,7 +1916,7 @@ function qa_db_user_favorite_non_qs_selectspec($userid) ...@@ -1915,7 +1916,7 @@ function qa_db_user_favorite_non_qs_selectspec($userid)
* include updates on the user's favorites and $forcontent to whether it should include responses to user's content. * include updates on the user's favorites and $forcontent to whether it should include responses to user's content.
* This combines events from both the user's stream and the the shared stream for any entities which the user has * This combines events from both the user's stream and the the shared stream for any entities which the user has
* favorited and which no longer post to user streams (see long comment in /qa-include/db/favorites.php). * favorited and which no longer post to user streams (see long comment in /qa-include/db/favorites.php).
* @param $userid * @param mixed $userid
* @param bool $forfavorites * @param bool $forfavorites
* @param bool $forcontent * @param bool $forcontent
* @return array * @return array
...@@ -1970,7 +1971,7 @@ function qa_db_user_updates_selectspec($userid, $forfavorites = true, $forconten ...@@ -1970,7 +1971,7 @@ function qa_db_user_updates_selectspec($userid, $forfavorites = true, $forconten
/** /**
* Return the selectspec to retrieve all of the per-hour activity limits for user $userid * Return the selectspec to retrieve all of the per-hour activity limits for user $userid
* @param $userid * @param mixed $userid
* @return array * @return array
*/ */
function qa_db_user_limits_selectspec($userid) function qa_db_user_limits_selectspec($userid)
...@@ -1986,7 +1987,7 @@ function qa_db_user_limits_selectspec($userid) ...@@ -1986,7 +1987,7 @@ function qa_db_user_limits_selectspec($userid)
/** /**
* Return the selectspec to retrieve all of the per-hour activity limits for ip address $ip * Return the selectspec to retrieve all of the per-hour activity limits for ip address $ip
* @param $ip * @param string $ip
* @return array * @return array
*/ */
function qa_db_ip_limits_selectspec($ip) function qa_db_ip_limits_selectspec($ip)
...@@ -2004,7 +2005,7 @@ function qa_db_ip_limits_selectspec($ip) ...@@ -2004,7 +2005,7 @@ function qa_db_ip_limits_selectspec($ip)
* Return the selectspec to retrieve all of the context specific (currently per-categpry) levels for the user identified by * Return the selectspec to retrieve all of the context specific (currently per-categpry) levels for the user identified by
* $identifier, which is treated as a userid if $isuserid is true, otherwise as a handle. Set $full to true to obtain extra * $identifier, which is treated as a userid if $isuserid is true, otherwise as a handle. Set $full to true to obtain extra
* information about these contexts (currently, categories). * information about these contexts (currently, categories).
* @param $identifier * @param mixed $identifier
* @param bool $isuserid * @param bool $isuserid
* @param bool $full * @param bool $full
* @return array * @return array
......
...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Return the expected value for the passcheck column given the $password and password $salt * Return the expected value for the passcheck column given the $password and password $salt
* @param $password * @param string $password
* @param $salt * @param string $salt
* @return mixed|string * @return string
*/ */
function qa_db_calc_passcheck($password, $salt) function qa_db_calc_passcheck($password, $salt)
{ {
...@@ -41,12 +41,12 @@ function qa_db_calc_passcheck($password, $salt) ...@@ -41,12 +41,12 @@ function qa_db_calc_passcheck($password, $salt)
/** /**
* Create a new user in the database with $email, $password, $handle, privilege $level, and $ip address * Create a new user in the database with $email, $password, $handle, privilege $level, and $ip address
* @param $email * @param string $email
* @param $password * @param string|null $password
* @param $handle * @param string $handle
* @param $level * @param int $level
* @param $ip * @param string $ip
* @return mixed * @return string
*/ */
function qa_db_user_create($email, $password, $handle, $level, $ip) function qa_db_user_create($email, $password, $handle, $level, $ip)
{ {
...@@ -77,7 +77,7 @@ function qa_db_user_create($email, $password, $handle, $level, $ip) ...@@ -77,7 +77,7 @@ function qa_db_user_create($email, $password, $handle, $level, $ip)
/** /**
* Delete user $userid from the database, along with everything they have ever done (to the extent that it's possible) * Delete user $userid from the database, along with everything they have ever done (to the extent that it's possible)
* @param $userid * @param mixed $userid
*/ */
function qa_db_user_delete($userid) function qa_db_user_delete($userid)
{ {
...@@ -101,7 +101,7 @@ function qa_db_user_delete($userid) ...@@ -101,7 +101,7 @@ function qa_db_user_delete($userid)
/** /**
* Return the ids of all users in the database which match $email (should be one or none) * Return the ids of all users in the database which match $email (should be one or none)
* @param $email * @param string $email
* @return array * @return array
*/ */
function qa_db_user_find_by_email($email) function qa_db_user_find_by_email($email)
...@@ -115,7 +115,7 @@ function qa_db_user_find_by_email($email) ...@@ -115,7 +115,7 @@ function qa_db_user_find_by_email($email)
/** /**
* Return the ids of all users in the database which match $handle (=username), should be one or none * Return the ids of all users in the database which match $handle (=username), should be one or none
* @param $handle * @param string $handle
* @return array * @return array
*/ */
function qa_db_user_find_by_handle($handle) function qa_db_user_find_by_handle($handle)
...@@ -129,12 +129,12 @@ function qa_db_user_find_by_handle($handle) ...@@ -129,12 +129,12 @@ function qa_db_user_find_by_handle($handle)
/** /**
* Return an array mapping each userid in $userids that can be found to that user's handle * Return an array mapping each userid in $userids that can be found to that user's handle
* @param $userids * @param array $userids
* @return array * @return array
*/ */
function qa_db_user_get_userid_handles($userids) function qa_db_user_get_userid_handles($userids)
{ {
if (count($userids)) { if (!empty($userids)) {
return qa_db_read_all_assoc(qa_db_query_sub( return qa_db_read_all_assoc(qa_db_query_sub(
'SELECT userid, handle FROM ^users WHERE userid IN (#)', 'SELECT userid, handle FROM ^users WHERE userid IN (#)',
$userids $userids
...@@ -147,12 +147,12 @@ function qa_db_user_get_userid_handles($userids) ...@@ -147,12 +147,12 @@ function qa_db_user_get_userid_handles($userids)
/** /**
* Return an array mapping mapping each handle in $handle that can be found to that user's userid * Return an array mapping mapping each handle in $handle that can be found to that user's userid
* @param $handles * @param array $handles
* @return array * @return array
*/ */
function qa_db_user_get_handle_userids($handles) function qa_db_user_get_handle_userids($handles)
{ {
if (count($handles)) { if (!empty($handles)) {
return qa_db_read_all_assoc(qa_db_query_sub( return qa_db_read_all_assoc(qa_db_query_sub(
'SELECT handle, userid FROM ^users WHERE handle IN ($)', 'SELECT handle, userid FROM ^users WHERE handle IN ($)',
$handles $handles
...@@ -193,8 +193,8 @@ function qa_db_user_set($userid, $fields, $value = null) ...@@ -193,8 +193,8 @@ function qa_db_user_set($userid, $fields, $value = null)
/** /**
* Set the password of $userid to $password, and reset their salt at the same time * Set the password of $userid to $password, and reset their salt at the same time
* @param $userid * @param mixed $userid
* @param $password * @param string $password
* @return mixed * @return mixed
*/ */
function qa_db_user_set_password($userid, $password) function qa_db_user_set_password($userid, $password)
...@@ -221,9 +221,9 @@ function qa_db_user_set_password($userid, $password) ...@@ -221,9 +221,9 @@ function qa_db_user_set_password($userid, $password)
/** /**
* Switch on the $flag bit of the flags column for $userid if $set is true, or switch off otherwise * Switch on the $flag bit of the flags column for $userid if $set is true, or switch off otherwise
* @param $userid * @param mixed $userid
* @param $flag * @param int $flag
* @param $set * @param bool $set
*/ */
function qa_db_user_set_flag($userid, $flag, $set) function qa_db_user_set_flag($userid, $flag, $set)
{ {
...@@ -236,6 +236,7 @@ function qa_db_user_set_flag($userid, $flag, $set) ...@@ -236,6 +236,7 @@ function qa_db_user_set_flag($userid, $flag, $set)
/** /**
* Return a random string to be used for a user's emailcode column * Return a random string to be used for a user's emailcode column
* @return string
*/ */
function qa_db_user_rand_emailcode() function qa_db_user_rand_emailcode()
{ {
...@@ -249,6 +250,7 @@ function qa_db_user_rand_emailcode() ...@@ -249,6 +250,7 @@ function qa_db_user_rand_emailcode()
/** /**
* Return a random string to be used for a user's sessioncode column (for browser session cookies) * Return a random string to be used for a user's sessioncode column (for browser session cookies)
* @return string
*/ */
function qa_db_user_rand_sessioncode() function qa_db_user_rand_sessioncode()
{ {
...@@ -262,9 +264,9 @@ function qa_db_user_rand_sessioncode() ...@@ -262,9 +264,9 @@ function qa_db_user_rand_sessioncode()
/** /**
* Set a row in the database user profile table to store $value for $field for $userid * Set a row in the database user profile table to store $value for $field for $userid
* @param $userid * @param mixed $userid
* @param $field * @param string $field
* @param $value * @param string $value
*/ */
function qa_db_user_profile_set($userid, $field, $value) function qa_db_user_profile_set($userid, $field, $value)
{ {
...@@ -278,8 +280,8 @@ function qa_db_user_profile_set($userid, $field, $value) ...@@ -278,8 +280,8 @@ function qa_db_user_profile_set($userid, $field, $value)
/** /**
* Note in the database that $userid just logged in from $ip address * Note in the database that $userid just logged in from $ip address
* @param $userid * @param mixed $userid
* @param $ip * @param string $ip
*/ */
function qa_db_user_logged_in($userid, $ip) function qa_db_user_logged_in($userid, $ip)
{ {
...@@ -292,8 +294,8 @@ function qa_db_user_logged_in($userid, $ip) ...@@ -292,8 +294,8 @@ function qa_db_user_logged_in($userid, $ip)
/** /**
* Note in the database that $userid just performed a write operation from $ip address * Note in the database that $userid just performed a write operation from $ip address
* @param $userid * @param mixed $userid
* @param $ip * @param string $ip
*/ */
function qa_db_user_written($userid, $ip) function qa_db_user_written($userid, $ip)
{ {
...@@ -306,9 +308,9 @@ function qa_db_user_written($userid, $ip) ...@@ -306,9 +308,9 @@ function qa_db_user_written($userid, $ip)
/** /**
* Add an external login in the database for $source and $identifier for user $userid * Add an external login in the database for $source and $identifier for user $userid
* @param $userid * @param mixed $userid
* @param $source * @param string $source
* @param $identifier * @param string $identifier
*/ */
function qa_db_user_login_add($userid, $source, $identifier) function qa_db_user_login_add($userid, $source, $identifier)
{ {
...@@ -322,8 +324,8 @@ function qa_db_user_login_add($userid, $source, $identifier) ...@@ -322,8 +324,8 @@ function qa_db_user_login_add($userid, $source, $identifier)
/** /**
* Return some information about the user with external login $source and $identifier in the database, if a match is found * Return some information about the user with external login $source and $identifier in the database, if a match is found
* @param $source * @param string $source
* @param $identifier * @param string $identifier
* @return array * @return array
*/ */
function qa_db_user_login_find($source, $identifier) function qa_db_user_login_find($source, $identifier)
...@@ -338,7 +340,7 @@ function qa_db_user_login_find($source, $identifier) ...@@ -338,7 +340,7 @@ function qa_db_user_login_find($source, $identifier)
/** /**
* Lock all tables if $sync is true, otherwise unlock them. Used to synchronize creation of external login mappings. * Lock all tables if $sync is true, otherwise unlock them. Used to synchronize creation of external login mappings.
* @param $sync * @param bool $sync
*/ */
function qa_db_user_login_sync($sync) function qa_db_user_login_sync($sync)
{ {
...@@ -360,8 +362,8 @@ function qa_db_user_login_sync($sync) ...@@ -360,8 +362,8 @@ function qa_db_user_login_sync($sync)
/** /**
* Reset the full set of context-specific (currently, per category) user levels for user $userid to $userlevels, where * Reset the full set of context-specific (currently, per category) user levels for user $userid to $userlevels, where
* $userlevels is an array of arrays, the inner arrays containing items 'entitytype', 'entityid' and 'level'. * $userlevels is an array of arrays, the inner arrays containing items 'entitytype', 'entityid' and 'level'.
* @param $userid * @param mixed $userid
* @param $userlevels * @param array $userlevels
*/ */
function qa_db_user_levels_set($userid, $userlevels) function qa_db_user_levels_set($userid, $userlevels)
{ {
...@@ -382,8 +384,8 @@ function qa_db_user_levels_set($userid, $userlevels) ...@@ -382,8 +384,8 @@ function qa_db_user_levels_set($userid, $userlevels)
/** /**
* Get the information required for sending a mailing to the next $count users with userids greater than $lastuserid * Get the information required for sending a mailing to the next $count users with userids greater than $lastuserid
* @param $lastuserid * @param mixed $lastuserid
* @param $count * @param int $count
* @return array * @return array
*/ */
function qa_db_users_get_mailing_next($lastuserid, $count) function qa_db_users_get_mailing_next($lastuserid, $count)
......
...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Set the vote for $userid on $postid to $vote in the database * Set the vote for $userid on $postid to $vote in the database
* @param $postid * @param int $postid
* @param $userid * @param mixed $userid
* @param $vote * @param int $vote
*/ */
function qa_db_uservote_set($postid, $userid, $vote) function qa_db_uservote_set($postid, $userid, $vote)
{ {
...@@ -44,9 +44,9 @@ function qa_db_uservote_set($postid, $userid, $vote) ...@@ -44,9 +44,9 @@ function qa_db_uservote_set($postid, $userid, $vote)
/** /**
* Get the vote for $userid on $postid from the database (or NULL if none) * Get the vote for $userid on $postid from the database (or NULL if none)
* @param $postid * @param int $postid
* @param $userid * @param mixed $userid
* @return mixed|null * @return string|null
*/ */
function qa_db_uservote_get($postid, $userid) function qa_db_uservote_get($postid, $userid)
{ {
...@@ -59,13 +59,13 @@ function qa_db_uservote_get($postid, $userid) ...@@ -59,13 +59,13 @@ function qa_db_uservote_get($postid, $userid)
/** /**
* Set the flag for $userid on $postid to $flag (true or false) in the database * Set the flag for $userid on $postid to $flag (true or false) in the database
* @param $postid * @param int $postid
* @param $userid * @param mixed $userid
* @param $flag * @param bool $flag
*/ */
function qa_db_userflag_set($postid, $userid, $flag) function qa_db_userflag_set($postid, $userid, $flag)
{ {
$flag = $flag ? 1 : 0; $flag = (int)$flag;
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^uservotes (postid, userid, vote, flag) VALUES (#, #, 0, #) ON DUPLICATE KEY UPDATE flag=#', 'INSERT INTO ^uservotes (postid, userid, vote, flag) VALUES (#, #, 0, #) ON DUPLICATE KEY UPDATE flag=#',
...@@ -76,7 +76,7 @@ function qa_db_userflag_set($postid, $userid, $flag) ...@@ -76,7 +76,7 @@ function qa_db_userflag_set($postid, $userid, $flag)
/** /**
* Clear all flags for $postid in the database * Clear all flags for $postid in the database
* @param $postid * @param int $postid
*/ */
function qa_db_userflags_clear_all($postid) function qa_db_userflags_clear_all($postid)
{ {
...@@ -89,7 +89,7 @@ function qa_db_userflags_clear_all($postid) ...@@ -89,7 +89,7 @@ function qa_db_userflags_clear_all($postid)
/** /**
* Recalculate the cached count of upvotes, downvotes and netvotes for $postid in the database * Recalculate the cached count of upvotes, downvotes and netvotes for $postid in the database
* @param $postid * @param int $postid
*/ */
function qa_db_post_recount_votes($postid) function qa_db_post_recount_votes($postid)
{ {
...@@ -104,7 +104,7 @@ function qa_db_post_recount_votes($postid) ...@@ -104,7 +104,7 @@ function qa_db_post_recount_votes($postid)
/** /**
* Recalculate the cached count of flags for $postid in the database * Recalculate the cached count of flags for $postid in the database
* @param $postid * @param int $postid
*/ */
function qa_db_post_recount_flags($postid) function qa_db_post_recount_flags($postid)
{ {
...@@ -119,7 +119,7 @@ function qa_db_post_recount_flags($postid) ...@@ -119,7 +119,7 @@ function qa_db_post_recount_flags($postid)
/** /**
* Returns all non-zero votes on post $postid from the database as an array of [userid] => [vote] * Returns all non-zero votes on post $postid from the database as an array of [userid] => [vote]
* @param $postid * @param int $postid
* @return array * @return array
*/ */
function qa_db_uservote_post_get($postid) function qa_db_uservote_post_get($postid)
...@@ -133,7 +133,7 @@ function qa_db_uservote_post_get($postid) ...@@ -133,7 +133,7 @@ function qa_db_uservote_post_get($postid)
/** /**
* Returns all the postids from the database for posts that $userid has voted on or flagged * Returns all the postids from the database for posts that $userid has voted on or flagged
* @param $userid * @param mixed $userid
* @return array * @return array
*/ */
function qa_db_uservoteflag_user_get($userid) function qa_db_uservoteflag_user_get($userid)
...@@ -147,7 +147,7 @@ function qa_db_uservoteflag_user_get($userid) ...@@ -147,7 +147,7 @@ function qa_db_uservoteflag_user_get($userid)
/** /**
* Return information about all the non-zero votes and/or flags on the posts in postids, including user handles for internal user management * Return information about all the non-zero votes and/or flags on the posts in postids, including user handles for internal user management
* @param $postids * @param array $postids
* @return array * @return array
*/ */
function qa_db_uservoteflag_posts_get($postids) function qa_db_uservoteflag_posts_get($postids)
...@@ -168,7 +168,6 @@ function qa_db_uservoteflag_posts_get($postids) ...@@ -168,7 +168,6 @@ function qa_db_uservoteflag_posts_get($postids)
/** /**
* Remove all votes assigned to a post that had been cast by the owner of the post. * Remove all votes assigned to a post that had been cast by the owner of the post.
*
* @param int $postid The post ID from which the owner's votes will be removed. * @param int $postid The post ID from which the owner's votes will be removed.
*/ */
function qa_db_uservote_remove_own($postid) function qa_db_uservote_remove_own($postid)
......
...@@ -33,11 +33,11 @@ require_once QA_INCLUDE_DIR . 'app/post-update.php'; ...@@ -33,11 +33,11 @@ require_once QA_INCLUDE_DIR . 'app/post-update.php';
* Checks for a POSTed click on $question by the current user and returns true if it was permitted and processed. Pass * Checks for a POSTed click on $question by the current user and returns true if it was permitted and processed. Pass
* in the question's $answers, all $commentsfollows from it or its answers, and its closing $closepost (or null if * in the question's $answers, all $commentsfollows from it or its answers, and its closing $closepost (or null if
* none). If there is an error to display, it will be passed out in $error. * none). If there is an error to display, it will be passed out in $error.
* @param $question * @param array $question
* @param $answers * @param array $answers
* @param $commentsfollows * @param array $commentsfollows
* @param $closepost * @param array $closepost
* @param $error * @param string $error
* @return bool * @return bool
*/ */
function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closepost, &$error) function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closepost, &$error)
...@@ -127,12 +127,12 @@ function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closep ...@@ -127,12 +127,12 @@ function qa_page_q_single_click_q($question, $answers, $commentsfollows, $closep
* the $question, all of its $answers, and all $commentsfollows from it or its answers. Set $allowselectmove to whether * the $question, all of its $answers, and all $commentsfollows from it or its answers. Set $allowselectmove to whether
* it is legitimate to change the selected answer for the question from one to another (this can't be done via Ajax). * it is legitimate to change the selected answer for the question from one to another (this can't be done via Ajax).
* If there is an error to display, it will be passed out in $error. * If there is an error to display, it will be passed out in $error.
* @param $answer * @param array $answer
* @param $question * @param array $question
* @param $answers * @param array $answers
* @param $commentsfollows * @param array $commentsfollows
* @param $allowselectmove * @param bool $allowselectmove
* @param $error * @param string $error
* @return bool * @return bool
*/ */
function qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows, $allowselectmove, &$error) function qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows, $allowselectmove, &$error)
...@@ -231,10 +231,10 @@ function qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows ...@@ -231,10 +231,10 @@ function qa_page_q_single_click_a($answer, $question, $answers, $commentsfollows
* Checks for a POSTed click on $comment by the current user and returns true if it was permitted and processed. Pass * Checks for a POSTed click on $comment by the current user and returns true if it was permitted and processed. Pass
* in the antecedent $question and the comment's $parent post. If there is an error to display, it will be passed out * in the antecedent $question and the comment's $parent post. If there is an error to display, it will be passed out
* in $error. * in $error.
* @param $comment * @param array $comment
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $error * @param string $error
* @return bool * @return bool
*/ */
function qa_page_q_single_click_c($comment, $question, $parent, &$error) function qa_page_q_single_click_c($comment, $question, $parent, &$error)
...@@ -322,8 +322,8 @@ function qa_page_q_single_click_c($comment, $question, $parent, &$error) ...@@ -322,8 +322,8 @@ function qa_page_q_single_click_c($comment, $question, $parent, &$error)
/** /**
* Check the form security (anti-CSRF protection) for one of the buttons shown for post $post. Return true if the * Check the form security (anti-CSRF protection) for one of the buttons shown for post $post. Return true if the
* security passed, otherwise return false and set an error message in $error * security passed, otherwise return false and set an error message in $error
* @param $post * @param array $post
* @param $error * @param string $error
* @return bool * @return bool
*/ */
function qa_page_q_click_check_form_code($post, &$error) function qa_page_q_click_check_form_code($post, &$error)
...@@ -341,12 +341,12 @@ function qa_page_q_click_check_form_code($post, &$error) ...@@ -341,12 +341,12 @@ function qa_page_q_click_check_form_code($post, &$error)
* Processes a POSTed form to add an answer to $question, returning the postid if successful, otherwise null. Pass in * Processes a POSTed form to add an answer to $question, returning the postid if successful, otherwise null. Pass in
* other $answers to the question and whether a $usecaptcha is required. The form fields submitted will be passed out * other $answers to the question and whether a $usecaptcha is required. The form fields submitted will be passed out
* as an array in $in, as well as any $errors on those fields. * as an array in $in, as well as any $errors on those fields.
* @param $question * @param array $question
* @param $answers * @param array $answers
* @param $usecaptcha * @param bool $usecaptcha
* @param $in * @param array $in
* @param $errors * @param array $errors
* @return mixed|null * @return int|null
*/ */
function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors) function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors)
{ {
...@@ -424,13 +424,13 @@ function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors ...@@ -424,13 +424,13 @@ function qa_page_q_add_a_submit($question, $answers, $usecaptcha, &$in, &$errors
* $question and the comment's $parent post. Set $usecaptcha to whether a captcha is required. Pass an array which * $question and the comment's $parent post. Set $usecaptcha to whether a captcha is required. Pass an array which
* includes the other comments with the same parent in $commentsfollows (it can contain other posts which are ignored). * includes the other comments with the same parent in $commentsfollows (it can contain other posts which are ignored).
* The form fields submitted will be passed out as an array in $in, as well as any $errors on those fields. * The form fields submitted will be passed out as an array in $in, as well as any $errors on those fields.
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $commentsfollows * @param array $commentsfollows
* @param $usecaptcha * @param bool $usecaptcha
* @param $in * @param array $in
* @param $errors * @param array $errors
* @return mixed|null * @return int|null
*/ */
function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, &$in, &$errors) function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptcha, &$in, &$errors)
{ {
...@@ -494,7 +494,7 @@ function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptch ...@@ -494,7 +494,7 @@ function qa_page_q_add_c_submit($question, $parent, $commentsfollows, $usecaptch
/** /**
* Return the array of information to be passed to filter modules for the post in $post (from the database) * Return the array of information to be passed to filter modules for the post in $post (from the database)
* @param $post * @param array $post
* @return array * @return array
*/ */
function qa_page_q_prepare_post_for_filters($post) function qa_page_q_prepare_post_for_filters($post)
......
...@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,8 +27,8 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Given a $question and its $childposts from the database, return a list of that question's answers * Given a $question and its $childposts from the database, return a list of that question's answers
* @param $question * @param array $question
* @param $childposts * @param array $childposts
* @return array * @return array
*/ */
function qa_page_q_load_as($question, $childposts) function qa_page_q_load_as($question, $childposts)
...@@ -53,9 +53,9 @@ function qa_page_q_load_as($question, $childposts) ...@@ -53,9 +53,9 @@ function qa_page_q_load_as($question, $childposts)
* Given a $question, its $childposts and its answers $achildposts from the database, * Given a $question, its $childposts and its answers $achildposts from the database,
* return a list of comments or follow-on questions for that question or its answers. * return a list of comments or follow-on questions for that question or its answers.
* Follow-on and duplicate questions are now returned, with their visibility determined in qa_page_q_comment_follow_list() * Follow-on and duplicate questions are now returned, with their visibility determined in qa_page_q_comment_follow_list()
* @param $question * @param array $question
* @param $childposts * @param array $childposts
* @param $achildposts * @param array $achildposts
* @param array $duplicateposts * @param array $duplicateposts
* @return array * @return array
*/ */
...@@ -93,11 +93,10 @@ function qa_page_q_load_c_follows($question, $childposts, $achildposts, $duplica ...@@ -93,11 +93,10 @@ function qa_page_q_load_c_follows($question, $childposts, $achildposts, $duplica
* Calculates which operations the current user may perform on a post. This function is a key part of Q2A's logic * Calculates which operations the current user may perform on a post. This function is a key part of Q2A's logic
* and is ripe for overriding by plugins. The latter two arrays can contain additional posts retrieved from the * and is ripe for overriding by plugins. The latter two arrays can contain additional posts retrieved from the
* database, and these will be ignored. * database, and these will be ignored.
*
* @param array $post The question/answer/comment to check. * @param array $post The question/answer/comment to check.
* @param array $parentpost The post's parent if there is one. * @param array|null $parentpost The post's parent if there is one.
* @param array $siblingposts The post's siblings (i.e. those with the same type and parent as the post). * @param array|null $siblingposts The post's siblings (i.e. those with the same type and parent as the post).
* @param array $childposts The post's children (e.g. comments on answers). * @param array|null $childposts The post's children (e.g. comments on answers).
* @return array List of elements that can be added to the post. * @return array List of elements that can be added to the post.
*/ */
function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $childposts = null) function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $childposts = null)
...@@ -257,11 +256,11 @@ function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $ ...@@ -257,11 +256,11 @@ function qa_page_q_post_rules($post, $parentpost = null, $siblingposts = null, $
* is closed, pass the post used to close this question in $closepost, otherwise null. $usershtml should be an array * is closed, pass the post used to close this question in $closepost, otherwise null. $usershtml should be an array
* which maps userids to HTML user representations, including the question's author and (if present) last editor. If a * which maps userids to HTML user representations, including the question's author and (if present) last editor. If a
* form has been explicitly requested for the page, set $formrequested to true - this will hide the buttons. * form has been explicitly requested for the page, set $formrequested to true - this will hide the buttons.
* @param $question * @param array $question
* @param $parentquestion * @param array|null $parentquestion
* @param $closepost * @param int|null $closepost
* @param $usershtml * @param array $usershtml
* @param $formrequested * @param bool $formrequested
* @return array * @return array
*/ */
function qa_page_q_question_view($question, $parentquestion, $closepost, $usershtml, $formrequested) function qa_page_q_question_view($question, $parentquestion, $closepost, $usershtml, $formrequested)
...@@ -492,11 +491,11 @@ function qa_page_q_question_view($question, $parentquestion, $closepost, $usersh ...@@ -492,11 +491,11 @@ function qa_page_q_question_view($question, $parentquestion, $closepost, $usersh
* answer's $question and whether it $isselected. $usershtml should be an array which maps userids to HTML user * answer's $question and whether it $isselected. $usershtml should be an array which maps userids to HTML user
* representations, including the answer's author and (if present) last editor. If a form has been explicitly requested * representations, including the answer's author and (if present) last editor. If a form has been explicitly requested
* for the page, set $formrequested to true - this will hide the buttons. * for the page, set $formrequested to true - this will hide the buttons.
* @param $question * @param array $question
* @param $answer * @param array $answer
* @param $isselected * @param bool $isselected
* @param $usershtml * @param array $usershtml
* @param $formrequested * @param bool $formrequested
* @return array * @return array
*/ */
function qa_page_q_answer_view($question, $answer, $isselected, $usershtml, $formrequested) function qa_page_q_answer_view($question, $answer, $isselected, $usershtml, $formrequested)
...@@ -643,18 +642,17 @@ function qa_page_q_answer_view($question, $answer, $isselected, $usershtml, $for ...@@ -643,18 +642,17 @@ function qa_page_q_answer_view($question, $answer, $isselected, $usershtml, $for
* current user. Pass the comment's $parent post and antecedent $question. $usershtml should be an array which maps * current user. Pass the comment's $parent post and antecedent $question. $usershtml should be an array which maps
* userids to HTML user representations, including the comments's author and (if present) last editor. If a form has * userids to HTML user representations, including the comments's author and (if present) last editor. If a form has
* been explicitly requested for the page, set $formrequested to true - this will hide the buttons. * been explicitly requested for the page, set $formrequested to true - this will hide the buttons.
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $comment * @param array $comment
* @param $usershtml * @param array $usershtml
* @param $formrequested * @param bool $formrequested
* @return array * @return array
*/ */
function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formrequested) function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formrequested)
{ {
$commentid = $comment['postid']; $commentid = $comment['postid'];
$questionid = ($parent['basetype'] == 'Q') ? $parent['postid'] : $parent['parentid']; $questionid = ($parent['basetype'] == 'Q') ? $parent['postid'] : $parent['parentid'];
$answerid = ($parent['basetype'] == 'Q') ? null : $parent['postid'];
$userid = qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
$cookieid = qa_cookie_get(); $cookieid = qa_cookie_get();
...@@ -784,13 +782,13 @@ function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formr ...@@ -784,13 +782,13 @@ function qa_page_q_comment_view($question, $parent, $comment, $usershtml, $formr
* comments' and follow on questions' authors and (if present) last editors. If a form has been explicitly requested * comments' and follow on questions' authors and (if present) last editors. If a form has been explicitly requested
* for the page, set $formrequested to true and pass the postid of the post for the form in $formpostid - this will * for the page, set $formrequested to true and pass the postid of the post for the form in $formpostid - this will
* hide the buttons and remove the $formpostid comment from the list. * hide the buttons and remove the $formpostid comment from the list.
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $commentsfollows * @param array $commentsfollows
* @param $alwaysfull * @param bool $alwaysfull
* @param $usershtml * @param array $usershtml
* @param $formrequested * @param bool $formrequested
* @param $formpostid * @param int $formpostid
* @return array * @return array
*/ */
function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $alwaysfull, $usershtml, $formrequested, $formpostid) function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $alwaysfull, $usershtml, $formrequested, $formpostid)
...@@ -865,7 +863,7 @@ function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $al ...@@ -865,7 +863,7 @@ function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $al
} }
} }
if (!count($commentlist['cs'])) if (empty($commentlist['cs']))
$commentlist['hidden'] = true; $commentlist['hidden'] = true;
return $commentlist; return $commentlist;
...@@ -877,14 +875,14 @@ function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $al ...@@ -877,14 +875,14 @@ function qa_page_q_comment_follow_list($question, $parent, $commentsfollows, $al
* and the result of qa_user_captcha_reason() in $captchareason. Pass previous inputs from a submitted version of this * and the result of qa_user_captcha_reason() in $captchareason. Pass previous inputs from a submitted version of this
* form in the array $in and resulting errors in $errors. If $loadnow is true, the form will be loaded immediately. Set * form in the array $in and resulting errors in $errors. If $loadnow is true, the form will be loaded immediately. Set
* $formrequested to true if the user explicitly requested it, as opposed being shown automatically. * $formrequested to true if the user explicitly requested it, as opposed being shown automatically.
* @param $qa_content * @param array $qa_content
* @param $formid * @param string $formid
* @param $captchareason * @param string $captchareason
* @param $question * @param array $question
* @param $in * @param array $in
* @param $errors * @param array $errors
* @param $loadnow * @param bool $loadnow
* @param $formrequested * @param bool $formrequested
* @return array * @return array
*/ */
function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question, $in, $errors, $loadnow, $formrequested) function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question, $in, $errors, $loadnow, $formrequested)
...@@ -1026,14 +1024,14 @@ function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question, ...@@ -1026,14 +1024,14 @@ function qa_page_q_add_a_form(&$qa_content, $formid, $captchareason, $question,
* to use for the form in $formid and the result of qa_user_captcha_reason() in $captchareason. Pass previous inputs * to use for the form in $formid and the result of qa_user_captcha_reason() in $captchareason. Pass previous inputs
* from a submitted version of this form in the array $in and resulting errors in $errors. If $loadfocusnow is true, * from a submitted version of this form in the array $in and resulting errors in $errors. If $loadfocusnow is true,
* the form will be loaded and focused immediately. * the form will be loaded and focused immediately.
* @param $qa_content * @param array $qa_content
* @param $question * @param array $question
* @param $parent * @param array $parent
* @param $formid * @param string $formid
* @param $captchareason * @param string $captchareason
* @param $in * @param array $in
* @param $errors * @param array $errors
* @param $loadfocusnow * @param bool $loadfocusnow
* @return array * @return array
*/ */
function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captchareason, $in, $errors, $loadfocusnow) function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captchareason, $in, $errors, $loadfocusnow)
......
...@@ -35,7 +35,7 @@ define('QA_BUILD_DATE', '2019-01-12'); ...@@ -35,7 +35,7 @@ define('QA_BUILD_DATE', '2019-01-12');
* Classes are mapped to PHP files with the underscores converted to directory separators. The Q2A_Util_Debug class is in * Classes are mapped to PHP files with the underscores converted to directory separators. The Q2A_Util_Debug class is in
* the file qa-include/Q2A/Util/Debug.php. A class named Q2A_Db_User_Messages would be in a file qa-include/Q2A/Db/User/Messages.php. * the file qa-include/Q2A/Util/Debug.php. A class named Q2A_Db_User_Messages would be in a file qa-include/Q2A/Db/User/Messages.php.
* *
* @param $class * @param string $class
*/ */
function qa_autoload($class) function qa_autoload($class)
{ {
...@@ -86,7 +86,7 @@ if (!isset($qa_autoconnect) || $qa_autoconnect !== false) { ...@@ -86,7 +86,7 @@ if (!isset($qa_autoconnect) || $qa_autoconnect !== false) {
* Converts the $version string (e.g. 1.6.2.2) to a floating point that can be used for greater/lesser comparisons * Converts the $version string (e.g. 1.6.2.2) to a floating point that can be used for greater/lesser comparisons
* (PHP's version_compare() function is not quite suitable for our needs) * (PHP's version_compare() function is not quite suitable for our needs)
* @deprecated 1.8.2 no longer used * @deprecated 1.8.2 no longer used
* @param $version * @param string $version
* @return float * @return float
*/ */
function qa_version_to_float($version) function qa_version_to_float($version)
...@@ -109,7 +109,7 @@ function qa_version_to_float($version) ...@@ -109,7 +109,7 @@ function qa_version_to_float($version)
/** /**
* Returns true if the current Q2A version is lower than $version * Returns true if the current Q2A version is lower than $version
* @param $version * @param string $version
* @return bool * @return bool
*/ */
function qa_qa_version_below($version) function qa_qa_version_below($version)
...@@ -120,7 +120,7 @@ function qa_qa_version_below($version) ...@@ -120,7 +120,7 @@ function qa_qa_version_below($version)
/** /**
* Returns true if the current PHP version is lower than $version * Returns true if the current PHP version is lower than $version
* @param $version * @param string $version
* @return bool * @return bool
*/ */
function qa_php_version_below($version) function qa_php_version_below($version)
...@@ -350,7 +350,7 @@ function qa_initialize_modularity() ...@@ -350,7 +350,7 @@ function qa_initialize_modularity()
/** /**
* Set up output buffering. Use gzip compression if option set and it's not an admin page (since some of these contain lengthy processes). * Set up output buffering. Use gzip compression if option set and it's not an admin page (since some of these contain lengthy processes).
* @param $request * @param string $request
* @return bool whether buffering was used * @return bool whether buffering was used
*/ */
function qa_initialize_buffering($request = '') function qa_initialize_buffering($request = '')
...@@ -418,10 +418,10 @@ function qa_initialize_postdb_plugins() ...@@ -418,10 +418,10 @@ function qa_initialize_postdb_plugins()
/** /**
* Standard database failure handler function which bring up the install/repair/upgrade page * Standard database failure handler function which bring up the install/repair/upgrade page
* @param $type * @param string $type
* @param int $errno * @param int|null $errno
* @param string $error * @param string|null $error
* @param string $query * @param string|null $query
* @return mixed * @return mixed
*/ */
function qa_page_db_fail_handler($type, $errno = null, $error = null, $query = null) function qa_page_db_fail_handler($type, $errno = null, $error = null, $query = null)
...@@ -445,9 +445,9 @@ function qa_page_db_fail_handler($type, $errno = null, $error = null, $query = n ...@@ -445,9 +445,9 @@ function qa_page_db_fail_handler($type, $errno = null, $error = null, $query = n
* Name, Description, Min Q2A & Min PHP are not currently used by themes. * Name, Description, Min Q2A & Min PHP are not currently used by themes.
* *
* @deprecated Deprecated from 1.7; Q2A_Util_Metadata class and metadata.json files should be used instead * @deprecated Deprecated from 1.7; Q2A_Util_Metadata class and metadata.json files should be used instead
* @param $contents * @param string $contents
* @param $type * @param string $type
* @param bool $versiononly * @param bool|null $versiononly
* @return array * @return array
*/ */
function qa_addon_metadata($contents, $type, $versiononly = false) function qa_addon_metadata($contents, $type, $versiononly = false)
...@@ -538,12 +538,12 @@ function qa_load_override_files() ...@@ -538,12 +538,12 @@ function qa_load_override_files()
/** /**
* Register a module of $type named $name, whose class named $class is defined in file $include (or null if no include necessary) * Register a module of $type named $name, whose class named $class is defined in file $include (or null if no include necessary)
* If this module comes from a plugin, pass in the local plugin $directory and the $urltoroot relative url for that directory * If this module comes from a plugin, pass in the local plugin $directory and the $urltoroot relative url for that directory
* @param $type * @param string $type
* @param $include * @param string $include
* @param $class * @param string $class
* @param $name * @param string $name
* @param string $directory * @param string $directory
* @param string $urltoroot * @param string|null $urltoroot
*/ */
function qa_register_module($type, $include, $class, $name, $directory = QA_INCLUDE_DIR, $urltoroot = null) function qa_register_module($type, $include, $class, $name, $directory = QA_INCLUDE_DIR, $urltoroot = null)
{ {
...@@ -568,10 +568,10 @@ function qa_register_module($type, $include, $class, $name, $directory = QA_INCL ...@@ -568,10 +568,10 @@ function qa_register_module($type, $include, $class, $name, $directory = QA_INCL
/** /**
* Register a layer named $name, defined in file $include. If this layer comes from a plugin (as all currently do), * Register a layer named $name, defined in file $include. If this layer comes from a plugin (as all currently do),
* pass in the local plugin $directory and the $urltoroot relative url for that directory * pass in the local plugin $directory and the $urltoroot relative url for that directory
* @param $include * @param string $include
* @param $name * @param string $name
* @param string $directory * @param string $directory
* @param string $urltoroot * @param string|null $urltoroot
*/ */
function qa_register_layer($include, $name, $directory = QA_INCLUDE_DIR, $urltoroot = null) function qa_register_layer($include, $name, $directory = QA_INCLUDE_DIR, $urltoroot = null)
{ {
...@@ -595,9 +595,9 @@ function qa_register_layer($include, $name, $directory = QA_INCLUDE_DIR, $urltor ...@@ -595,9 +595,9 @@ function qa_register_layer($include, $name, $directory = QA_INCLUDE_DIR, $urltor
/** /**
* Register a file $include containing override functions. If this file comes from a plugin (as all currently do), * Register a file $include containing override functions. If this file comes from a plugin (as all currently do),
* pass in the local plugin $directory and the $urltoroot relative url for that directory * pass in the local plugin $directory and the $urltoroot relative url for that directory
* @param $include * @param string $include
* @param string $directory * @param string $directory
* @param string $urltoroot * @param string|null $urltoroot
*/ */
function qa_register_overrides($include, $directory = QA_INCLUDE_DIR, $urltoroot = null) function qa_register_overrides($include, $directory = QA_INCLUDE_DIR, $urltoroot = null)
{ {
...@@ -615,8 +615,8 @@ function qa_register_overrides($include, $directory = QA_INCLUDE_DIR, $urltoroot ...@@ -615,8 +615,8 @@ function qa_register_overrides($include, $directory = QA_INCLUDE_DIR, $urltoroot
* Register a set of language phrases, which should be accessed by the prefix $name/ in the qa_lang_*() functions. * Register a set of language phrases, which should be accessed by the prefix $name/ in the qa_lang_*() functions.
* Pass in the $pattern representing the PHP files that define these phrases, where * in the pattern is replaced with * Pass in the $pattern representing the PHP files that define these phrases, where * in the pattern is replaced with
* the language code (e.g. 'fr') and/or 'default'. These files should be formatted like Q2A's qa-lang-*.php files. * the language code (e.g. 'fr') and/or 'default'. These files should be formatted like Q2A's qa-lang-*.php files.
* @param $pattern * @param string $pattern
* @param $name * @param string $name
*/ */
function qa_register_phrases($pattern, $name) function qa_register_phrases($pattern, $name)
{ {
...@@ -640,10 +640,10 @@ function qa_register_phrases($pattern, $name) ...@@ -640,10 +640,10 @@ function qa_register_phrases($pattern, $name)
/** /**
* Register a plugin module of $type named $name, whose class named $class is defined in file $include (or null if no include necessary) * Register a plugin module of $type named $name, whose class named $class is defined in file $include (or null if no include necessary)
* This function relies on some global variable values and can only be called from a plugin's qa-plugin.php file * This function relies on some global variable values and can only be called from a plugin's qa-plugin.php file
* @param $type * @param string $type
* @param $include * @param string $include
* @param $class * @param string $class
* @param $name * @param string $name
*/ */
function qa_register_plugin_module($type, $include, $class, $name) function qa_register_plugin_module($type, $include, $class, $name)
{ {
...@@ -659,8 +659,8 @@ function qa_register_plugin_module($type, $include, $class, $name) ...@@ -659,8 +659,8 @@ function qa_register_plugin_module($type, $include, $class, $name)
/** /**
* Register a plugin layer named $name, defined in file $include. Can only be called from a plugin's qa-plugin.php file * Register a plugin layer named $name, defined in file $include. Can only be called from a plugin's qa-plugin.php file
* @param $include * @param string $include
* @param $name * @param string $name
*/ */
function qa_register_plugin_layer($include, $name) function qa_register_plugin_layer($include, $name)
{ {
...@@ -676,7 +676,7 @@ function qa_register_plugin_layer($include, $name) ...@@ -676,7 +676,7 @@ function qa_register_plugin_layer($include, $name)
/** /**
* Register a plugin file $include containing override functions. Can only be called from a plugin's qa-plugin.php file * Register a plugin file $include containing override functions. Can only be called from a plugin's qa-plugin.php file
* @param $include * @param string $include
*/ */
function qa_register_plugin_overrides($include) function qa_register_plugin_overrides($include)
{ {
...@@ -692,8 +692,8 @@ function qa_register_plugin_overrides($include) ...@@ -692,8 +692,8 @@ function qa_register_plugin_overrides($include)
/** /**
* Register a file name $pattern within a plugin directory containing language phrases accessed by the prefix $name * Register a file name $pattern within a plugin directory containing language phrases accessed by the prefix $name
* @param $pattern * @param string $pattern
* @param $name * @param string $name
*/ */
function qa_register_plugin_phrases($pattern, $name) function qa_register_plugin_phrases($pattern, $name)
{ {
...@@ -712,8 +712,8 @@ function qa_register_plugin_phrases($pattern, $name) ...@@ -712,8 +712,8 @@ function qa_register_plugin_phrases($pattern, $name)
/** /**
* Calls eval() on the PHP code in $eval which came from the file $filename. It supplements PHP's regular error reporting by * Calls eval() on the PHP code in $eval which came from the file $filename. It supplements PHP's regular error reporting by
* displaying/logging (as appropriate) the original source filename, if an error occurred when evaluating the code. * displaying/logging (as appropriate) the original source filename, if an error occurred when evaluating the code.
* @param $eval * @param string $eval
* @param $filename * @param string $filename
*/ */
function qa_eval_from_file($eval, $filename) function qa_eval_from_file($eval, $filename)
{ {
...@@ -747,8 +747,8 @@ function qa_eval_from_file($eval, $filename) ...@@ -747,8 +747,8 @@ function qa_eval_from_file($eval, $filename)
/** /**
* Call $function with the arguments in the $args array (doesn't work with call-by-reference functions) * Call $function with the arguments in the $args array (doesn't work with call-by-reference functions)
* @param $function * @param string $function
* @param $args * @param array $args
* @return mixed * @return mixed
*/ */
function qa_call($function, $args) function qa_call($function, $args)
...@@ -776,7 +776,6 @@ function qa_call($function, $args) ...@@ -776,7 +776,6 @@ function qa_call($function, $args)
/** /**
* Determines whether a function is to be overridden by a plugin. But if the function is being called with * Determines whether a function is to be overridden by a plugin. But if the function is being called with
* the _base suffix, any override will be bypassed due to $qa_direct. * the _base suffix, any override will be bypassed due to $qa_direct.
*
* @param string $function The function to override * @param string $function The function to override
* @return string|null The name of the overriding function (of the form `qa_functionname_override_1_in_filename`) * @return string|null The name of the overriding function (of the form `qa_functionname_override_1_in_filename`)
*/ */
...@@ -804,8 +803,8 @@ function qa_to_override($function) ...@@ -804,8 +803,8 @@ function qa_to_override($function)
/** /**
* Call the function which immediately overrides $function with the arguments in the $args array * Call the function which immediately overrides $function with the arguments in the $args array
* @param $function * @param string $function
* @param $args * @param array $args
* @return mixed * @return mixed
*/ */
function qa_call_override($function, $args) function qa_call_override($function, $args)
...@@ -827,7 +826,7 @@ function qa_call_override($function, $args) ...@@ -827,7 +826,7 @@ function qa_call_override($function, $args)
/** /**
* Exit PHP immediately after reporting a shutdown with $reason to any installed process modules * Exit PHP immediately after reporting a shutdown with $reason to any installed process modules
* @param string $reason * @param string|null $reason
*/ */
function qa_exit($reason = null) function qa_exit($reason = null)
{ {
...@@ -840,7 +839,7 @@ function qa_exit($reason = null) ...@@ -840,7 +839,7 @@ function qa_exit($reason = null)
/** /**
* Display $message in the browser, write it to server error log, and then stop abruptly * Display $message in the browser, write it to server error log, and then stop abruptly
* @param $message * @param string $message
* @return mixed * @return mixed
*/ */
function qa_fatal_error($message) function qa_fatal_error($message)
...@@ -885,7 +884,7 @@ function qa_list_module_types() ...@@ -885,7 +884,7 @@ function qa_list_module_types()
/** /**
* Return a list of names of registered modules of $type * Return a list of names of registered modules of $type
* @param $type * @param string $type
* @return array * @return array
*/ */
function qa_list_modules($type) function qa_list_modules($type)
...@@ -896,8 +895,8 @@ function qa_list_modules($type) ...@@ -896,8 +895,8 @@ function qa_list_modules($type)
/** /**
* Return an array containing information about the module of $type named $name * Return an array containing information about the module of $type named $name
* @param $type * @param string $type
* @param $name * @param string $name
* @return array * @return array
*/ */
function qa_get_module_info($type, $name) function qa_get_module_info($type, $name)
...@@ -908,8 +907,8 @@ function qa_get_module_info($type, $name) ...@@ -908,8 +907,8 @@ function qa_get_module_info($type, $name)
/** /**
* Return an instantiated class for module of $type named $name, whose functions can be called, or null if it doesn't exist * Return an instantiated class for module of $type named $name, whose functions can be called, or null if it doesn't exist
* @param $type * @param string $type
* @param $name * @param string $name
* @return mixed|null * @return mixed|null
*/ */
function qa_load_module($type, $name) function qa_load_module($type, $name)
...@@ -942,7 +941,7 @@ function qa_load_module($type, $name) ...@@ -942,7 +941,7 @@ function qa_load_module($type, $name)
/** /**
* Return an array of instantiated clases for modules which have defined $method * Return an array of instantiated clases for modules which have defined $method
* (all modules are loaded but not included in the returned array) * (all modules are loaded but not included in the returned array)
* @param $method * @param string $method
* @return array * @return array
*/ */
function qa_load_all_modules_with($method) function qa_load_all_modules_with($method)
...@@ -966,8 +965,8 @@ function qa_load_all_modules_with($method) ...@@ -966,8 +965,8 @@ function qa_load_all_modules_with($method)
/** /**
* Return an array of instantiated clases for modules of $type which have defined $method * Return an array of instantiated clases for modules of $type which have defined $method
* (other modules of that type are also loaded but not included in the returned array) * (other modules of that type are also loaded but not included in the returned array)
* @param $type * @param string $type
* @param $method * @param string $method
* @return array * @return array
*/ */
function qa_load_modules_with($type, $method) function qa_load_modules_with($type, $method)
...@@ -991,13 +990,13 @@ function qa_load_modules_with($type, $method) ...@@ -991,13 +990,13 @@ function qa_load_modules_with($type, $method)
/** /**
* Return HTML representation of $string, work well with blocks of text if $multiline is true * Return HTML representation of $string, work well with blocks of text if $multiline is true
* @param $string * @param string $string
* @param bool $multiline * @param bool $multiline
* @return mixed|string * @return string
*/ */
function qa_html($string, $multiline = false) function qa_html($string, $multiline = false)
{ {
$html = htmlspecialchars((string)$string); $html = htmlspecialchars($string);
if ($multiline) { if ($multiline) {
$html = preg_replace('/\r\n?/', "\n", $html); $html = preg_replace('/\r\n?/', "\n", $html);
...@@ -1014,10 +1013,10 @@ function qa_html($string, $multiline = false) ...@@ -1014,10 +1013,10 @@ function qa_html($string, $multiline = false)
* Return $html after ensuring it is safe, i.e. removing Javascripts and the like - uses htmLawed library * Return $html after ensuring it is safe, i.e. removing Javascripts and the like - uses htmLawed library
* Links open in a new window if $linksnewwindow is true. Set $storage to true if sanitization is for * Links open in a new window if $linksnewwindow is true. Set $storage to true if sanitization is for
* storing in the database, rather than immediate display to user - some think this should be less strict. * storing in the database, rather than immediate display to user - some think this should be less strict.
* @param $html * @param string $html
* @param bool $linksnewwindow * @param bool $linksnewwindow
* @param bool $storage * @param bool $storage
* @return mixed|string * @return string
*/ */
function qa_sanitize_html($html, $linksnewwindow = false, $storage = false) function qa_sanitize_html($html, $linksnewwindow = false, $storage = false)
{ {
...@@ -1044,7 +1043,7 @@ function qa_sanitize_html($html, $linksnewwindow = false, $storage = false) ...@@ -1044,7 +1043,7 @@ function qa_sanitize_html($html, $linksnewwindow = false, $storage = false)
/** /**
* htmLawed hook function used to process tags in qa_sanitize_html(...) * htmLawed hook function used to process tags in qa_sanitize_html(...)
* @param $element * @param string $element
* @param array $attributes * @param array $attributes
* @return string * @return string
*/ */
...@@ -1074,19 +1073,19 @@ function qa_sanitize_html_hook_tag($element, $attributes = null) ...@@ -1074,19 +1073,19 @@ function qa_sanitize_html_hook_tag($element, $attributes = null)
/** /**
* Return XML representation of $string, which is similar to HTML but ASCII control characters are also disallowed * Return XML representation of $string, which is similar to HTML but ASCII control characters are also disallowed
* @param $string * @param string $string
* @return string * @return string
*/ */
function qa_xml($string) function qa_xml($string)
{ {
return htmlspecialchars(preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', (string)$string)); return htmlspecialchars(preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string));
} }
/** /**
* Return JavaScript representation of $value, putting in quotes if non-numeric or if $forcequotes is true. In the * Return JavaScript representation of $value, putting in quotes if non-numeric or if $forcequotes is true. In the
* case of boolean values they are returned as the appropriate true or false string * case of boolean values they are returned as the appropriate true or false string
* @param $value * @param mixed $value
* @param bool $forcequotes * @param bool $forcequotes
* @return string * @return string
*/ */
...@@ -1113,9 +1112,9 @@ function qa_js($value, $forcequotes = false) ...@@ -1113,9 +1112,9 @@ function qa_js($value, $forcequotes = false)
/** /**
* Inform Q2A that the current request is $request (slash-separated, independent of the url scheme chosen), * Inform Q2A that the current request is $request (slash-separated, independent of the url scheme chosen),
* that the relative path to the Q2A root apperas to be $relativeroot, and the url scheme appears to be $usedformat * that the relative path to the Q2A root apperas to be $relativeroot, and the url scheme appears to be $usedformat
* @param $request * @param string $request
* @param $relativeroot * @param string $relativeroot
* @param $usedformat * @param int|null $usedformat
* @return mixed * @return mixed
*/ */
function qa_set_request($request, $relativeroot, $usedformat = null) function qa_set_request($request, $relativeroot, $usedformat = null)
...@@ -1132,6 +1131,7 @@ function qa_set_request($request, $relativeroot, $usedformat = null) ...@@ -1132,6 +1131,7 @@ function qa_set_request($request, $relativeroot, $usedformat = null)
/** /**
* Returns the current Q2A request (slash-separated, independent of the url scheme chosen) * Returns the current Q2A request (slash-separated, independent of the url scheme chosen)
* @return string
*/ */
function qa_request() function qa_request()
{ {
...@@ -1144,8 +1144,8 @@ function qa_request() ...@@ -1144,8 +1144,8 @@ function qa_request()
/** /**
* Returns the indexed $part (as separated by slashes) of the current Q2A request, or null if it doesn't exist * Returns the indexed $part (as separated by slashes) of the current Q2A request, or null if it doesn't exist
* @param $part * @param int $part
* @return * @return string
*/ */
function qa_request_part($part) function qa_request_part($part)
{ {
...@@ -1167,8 +1167,8 @@ function qa_request_parts($start = 0) ...@@ -1167,8 +1167,8 @@ function qa_request_parts($start = 0)
/** /**
* Return string for incoming GET/POST/COOKIE value, stripping slashes if appropriate * Return string for incoming GET/POST/COOKIE value, stripping slashes if appropriate
* @param $string * @param string $string
* @return mixed|string * @return string
*/ */
function qa_gpc_to_string($string) function qa_gpc_to_string($string)
{ {
...@@ -1180,8 +1180,8 @@ function qa_gpc_to_string($string) ...@@ -1180,8 +1180,8 @@ function qa_gpc_to_string($string)
/** /**
* Return string with slashes added, if appropriate for later removal by qa_gpc_to_string() * Return string with slashes added, if appropriate for later removal by qa_gpc_to_string()
* @param $string * @param string $string
* @return mixed|string * @return string
*/ */
function qa_string_to_gpc($string) function qa_string_to_gpc($string)
{ {
...@@ -1193,8 +1193,8 @@ function qa_string_to_gpc($string) ...@@ -1193,8 +1193,8 @@ function qa_string_to_gpc($string)
/** /**
* Return string for incoming GET field, or null if it's not defined * Return string for incoming GET field, or null if it's not defined
* @param $field * @param string $field
* @return mixed|null|string * @return mixed|null
*/ */
function qa_get($field) function qa_get($field)
{ {
...@@ -1207,7 +1207,7 @@ function qa_get($field) ...@@ -1207,7 +1207,7 @@ function qa_get($field)
/** /**
* Return string for incoming POST field, or null if it's not defined. * Return string for incoming POST field, or null if it's not defined.
* While we're at it, trim() surrounding white space and converted to Unix line endings. * While we're at it, trim() surrounding white space and converted to Unix line endings.
* @param $field * @param string $field
* @return mixed|null * @return mixed|null
*/ */
function qa_post_text($field) function qa_post_text($field)
...@@ -1220,8 +1220,8 @@ function qa_post_text($field) ...@@ -1220,8 +1220,8 @@ function qa_post_text($field)
/** /**
* Return an array for incoming POST field, or null if it's not an array or not defined. * Return an array for incoming POST field, or null if it's not an array or not defined.
* While we're at it, trim() surrounding white space for each value and convert them to Unix line endings. * While we're at it, trim() surrounding white space for each value and convert them to Unix line endings.
* @param $field * @param string $field
* @return array|mixed|null * @return mixed|null
*/ */
function qa_post_array($field) function qa_post_array($field)
{ {
...@@ -1242,8 +1242,8 @@ function qa_post_array($field) ...@@ -1242,8 +1242,8 @@ function qa_post_array($field)
/** /**
* Return true if form button $name was clicked (as type=submit/image) to create this page request, or if a * Return true if form button $name was clicked (as type=submit/image) to create this page request, or if a
* simulated click was sent for the button (via 'qa_click' POST field) * simulated click was sent for the button (via 'qa_click' POST field)
* @param $name * @param string $name
* @return bool|mixed * @return bool
*/ */
function qa_clicked($name) function qa_clicked($name)
{ {
...@@ -1255,7 +1255,7 @@ function qa_clicked($name) ...@@ -1255,7 +1255,7 @@ function qa_clicked($name)
/** /**
* Determine the remote IP address of the user accessing the site. * Determine the remote IP address of the user accessing the site.
* @return mixed String representing IP if it's available, or null otherwise. * @return string|null String representing IP if it's available, or null otherwise.
*/ */
function qa_remote_ip_address() function qa_remote_ip_address()
{ {
...@@ -1270,6 +1270,7 @@ function qa_remote_ip_address() ...@@ -1270,6 +1270,7 @@ function qa_remote_ip_address()
* is too big to be properly processed by PHP, usually because there is an attachment in the HTTP request. A warning * is too big to be properly processed by PHP, usually because there is an attachment in the HTTP request. A warning
* is added to the server's log displaying the size of the file that triggered this situation. It is important to note * is added to the server's log displaying the size of the file that triggered this situation. It is important to note
* that whenever this happens the $_POST and $_FILES superglobals are empty. * that whenever this happens the $_POST and $_FILES superglobals are empty.
* @return bool
*/ */
function qa_post_limit_exceeded() function qa_post_limit_exceeded()
{ {
...@@ -1283,6 +1284,8 @@ function qa_post_limit_exceeded() ...@@ -1283,6 +1284,8 @@ function qa_post_limit_exceeded()
$postmaxsize = convert_to_bytes($unit, $postmaxsize); $postmaxsize = convert_to_bytes($unit, $postmaxsize);
return $_SERVER['CONTENT_LENGTH'] > $postmaxsize; return $_SERVER['CONTENT_LENGTH'] > $postmaxsize;
} }
return false;
} }
...@@ -1290,8 +1293,8 @@ function qa_post_limit_exceeded() ...@@ -1290,8 +1293,8 @@ function qa_post_limit_exceeded()
* Turns a numeric value and a unit (g/m/k) into bytes * Turns a numeric value and a unit (g/m/k) into bytes
* @param string $unit One of 'g', 'm', 'k'. It is case insensitive * @param string $unit One of 'g', 'm', 'k'. It is case insensitive
* @param int $value The value to turn into bytes * @param int $value The value to turn into bytes
* @return int The amount of bytes the unit and the value represent. If the unit is not one of 'g', 'm' or 'k' then * @return int The amount of bytes the unit and the value represent. If the unit is not one of 'g', 'm' or 'k' then the
* the original value is returned * original value is returned
*/ */
function convert_to_bytes($unit, $value) function convert_to_bytes($unit, $value)
{ {
...@@ -1311,7 +1314,7 @@ function convert_to_bytes($unit, $value) ...@@ -1311,7 +1314,7 @@ function convert_to_bytes($unit, $value)
/** /**
* Whether we are responding to an HTTP GET request * Return true if we are responding to an HTTP GET request
* @return bool True if the request is GET * @return bool True if the request is GET
*/ */
function qa_is_http_get() function qa_is_http_get()
...@@ -1323,6 +1326,7 @@ function qa_is_http_get() ...@@ -1323,6 +1326,7 @@ function qa_is_http_get()
/** /**
* Return true if we are responding to an HTTP POST request * Return true if we are responding to an HTTP POST request
* @return bool True if the request is POST
*/ */
function qa_is_http_post() function qa_is_http_post()
{ {
...@@ -1334,6 +1338,7 @@ function qa_is_http_post() ...@@ -1334,6 +1338,7 @@ function qa_is_http_post()
/** /**
* Return true if we appear to be responding to a secure HTTP request (but hard to be sure) * Return true if we appear to be responding to a secure HTTP request (but hard to be sure)
* @return bool
*/ */
function qa_is_https_probably() function qa_is_https_probably()
{ {
...@@ -1346,6 +1351,7 @@ function qa_is_https_probably() ...@@ -1346,6 +1351,7 @@ function qa_is_https_probably()
/** /**
* Return true if it appears the page request is coming from a human using a web browser, rather than a search engine * Return true if it appears the page request is coming from a human using a web browser, rather than a search engine
* or other bot. Based on a whitelist of terms in user agents, this can easily be tricked by a scraper or bad bot. * or other bot. Based on a whitelist of terms in user agents, this can easily be tricked by a scraper or bad bot.
* @return bool
*/ */
function qa_is_human_probably() function qa_is_human_probably()
{ {
...@@ -1363,7 +1369,9 @@ function qa_is_human_probably() ...@@ -1363,7 +1369,9 @@ function qa_is_human_probably()
/** /**
* Return true if it appears that the page request is coming from a mobile client rather than a desktop/laptop web browser * Return true if it appears that the page request is coming from a mobile client rather than a desktop/laptop web
* browser
* @return bool
*/ */
function qa_is_mobile_probably() function qa_is_mobile_probably()
{ {
...@@ -1405,7 +1413,7 @@ function qa_is_mobile_probably() ...@@ -1405,7 +1413,7 @@ function qa_is_mobile_probably()
* loading an option now will cause a problem (see issue in qa_default_option()). The part of * loading an option now will cause a problem (see issue in qa_default_option()). The part of
* $identifier before the slash (/) replaces the * in the qa-lang-*.php file references, and the * $identifier before the slash (/) replaces the * in the qa-lang-*.php file references, and the
* part after the / is the key of the array element to be taken from that file's returned result. * part after the / is the key of the array element to be taken from that file's returned result.
* @param $identifier * @param string $identifier
* @return string * @return string
*/ */
function qa_lang($identifier) function qa_lang($identifier)
...@@ -1455,8 +1463,8 @@ function qa_lang($identifier) ...@@ -1455,8 +1463,8 @@ function qa_lang($identifier)
/** /**
* Return the translated string for $identifier, with $symbol substituted for $textparam * Return the translated string for $identifier, with $symbol substituted for $textparam
* @param $identifier * @param string $identifier
* @param $textparam * @param string $textparam
* @param string $symbol * @param string $symbol
* @return mixed * @return mixed
*/ */
...@@ -1468,8 +1476,8 @@ function qa_lang_sub($identifier, $textparam, $symbol = '^') ...@@ -1468,8 +1476,8 @@ function qa_lang_sub($identifier, $textparam, $symbol = '^')
/** /**
* Return the translated string for $identifier, converted to HTML * Return the translated string for $identifier, converted to HTML
* @param $identifier * @param string $identifier
* @return mixed|string * @return string
*/ */
function qa_lang_html($identifier) function qa_lang_html($identifier)
{ {
...@@ -1479,8 +1487,8 @@ function qa_lang_html($identifier) ...@@ -1479,8 +1487,8 @@ function qa_lang_html($identifier)
/** /**
* Return the translated string for $identifier converted to HTML, with $symbol *then* substituted for $htmlparam * Return the translated string for $identifier converted to HTML, with $symbol *then* substituted for $htmlparam
* @param $identifier * @param string $identifier
* @param $htmlparam * @param string $htmlparam
* @param string $symbol * @param string $symbol
* @return mixed * @return mixed
*/ */
...@@ -1493,8 +1501,8 @@ function qa_lang_html_sub($identifier, $htmlparam, $symbol = '^') ...@@ -1493,8 +1501,8 @@ function qa_lang_html_sub($identifier, $htmlparam, $symbol = '^')
/** /**
* Return an array containing the translated string for $identifier converted to HTML, then split into three, * Return an array containing the translated string for $identifier converted to HTML, then split into three,
* with $symbol substituted for $htmlparam in the 'data' element, and obvious 'prefix' and 'suffix' elements * with $symbol substituted for $htmlparam in the 'data' element, and obvious 'prefix' and 'suffix' elements
* @param $identifier * @param string $identifier
* @param $htmlparam * @param string $htmlparam
* @param string $symbol * @param string $symbol
* @return array * @return array
*/ */
...@@ -1518,6 +1526,7 @@ function qa_lang_html_sub_split($identifier, $htmlparam, $symbol = '^') ...@@ -1518,6 +1526,7 @@ function qa_lang_html_sub_split($identifier, $htmlparam, $symbol = '^')
/** /**
* Return the relative path to the Q2A root (if it was previously set by qa_set_request()) * Return the relative path to the Q2A root (if it was previously set by qa_set_request())
* @return string
*/ */
function qa_path_to_root() function qa_path_to_root()
{ {
...@@ -1530,6 +1539,7 @@ function qa_path_to_root() ...@@ -1530,6 +1539,7 @@ function qa_path_to_root()
/** /**
* Return an array of mappings of Q2A requests, as defined in the qa-config.php file * Return an array of mappings of Q2A requests, as defined in the qa-config.php file
* @return array
*/ */
function qa_get_request_map() function qa_get_request_map()
{ {
...@@ -1545,11 +1555,11 @@ function qa_get_request_map() ...@@ -1545,11 +1555,11 @@ function qa_get_request_map()
* Slashes in $request will not be urlencoded, but any other characters will. * Slashes in $request will not be urlencoded, but any other characters will.
* If $neaturls is set, use that, otherwise retrieve the option. If $rooturl is set, take * If $neaturls is set, use that, otherwise retrieve the option. If $rooturl is set, take
* that as the root of the Q2A site, otherwise use path to root which was set elsewhere. * that as the root of the Q2A site, otherwise use path to root which was set elsewhere.
* @param $request * @param string $request
* @param array $params * @param array|null $params
* @param string $rooturl * @param string|null $rooturl
* @param int $neaturls * @param int|null $neaturls
* @param string $anchor * @param string|null $anchor
* @return string * @return string
*/ */
function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null) function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
...@@ -1623,11 +1633,11 @@ function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $a ...@@ -1623,11 +1633,11 @@ function qa_path($request, $params = null, $rooturl = null, $neaturls = null, $a
/** /**
* Return HTML representation of relative URI path for $request - see qa_path() for other parameters * Return HTML representation of relative URI path for $request - see qa_path() for other parameters
* @param $request * @param string $request
* @param array $params * @param array|null $params
* @param string $rooturl * @param string|null $rooturl
* @param int $neaturls * @param int|null $neaturls
* @param string $anchor * @param string|null $anchor
* @return mixed|string * @return mixed|string
*/ */
function qa_path_html($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null) function qa_path_html($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
...@@ -1638,9 +1648,9 @@ function qa_path_html($request, $params = null, $rooturl = null, $neaturls = nul ...@@ -1638,9 +1648,9 @@ function qa_path_html($request, $params = null, $rooturl = null, $neaturls = nul
/** /**
* Return the absolute URI for $request - see qa_path() for other parameters * Return the absolute URI for $request - see qa_path() for other parameters
* @param $request * @param string $request
* @param array $params * @param array|null $params
* @param string $anchor * @param string|null $anchor
* @return string * @return string
*/ */
function qa_path_absolute($request, $params = null, $anchor = null) function qa_path_absolute($request, $params = null, $anchor = null)
...@@ -1672,9 +1682,9 @@ function qa_q_request($questionid, $title) ...@@ -1672,9 +1682,9 @@ function qa_q_request($questionid, $title)
/** /**
* Return the HTML anchor that should be used for post $postid with $basetype (Q/A/C) * Return the HTML anchor that should be used for post $postid with $basetype (Q/A/C)
* @param $basetype * @param string $basetype
* @param $postid * @param int $postid
* @return mixed|string * @return string
*/ */
function qa_anchor($basetype, $postid) function qa_anchor($basetype, $postid)
{ {
...@@ -1687,12 +1697,12 @@ function qa_anchor($basetype, $postid) ...@@ -1687,12 +1697,12 @@ function qa_anchor($basetype, $postid)
/** /**
* Return the URL for question $questionid with $title, possibly using $absolute URLs. * Return the URL for question $questionid with $title, possibly using $absolute URLs.
* To link to a specific answer or comment in a question, set $showtype and $showid accordingly. * To link to a specific answer or comment in a question, set $showtype and $showid accordingly.
* @param $questionid * @param int $questionid
* @param $title * @param string $title
* @param bool $absolute * @param bool $absolute
* @param string $showtype * @param string|null $showtype
* @param int $showid * @param int|null $showid
* @return mixed|string * @return string
*/ */
function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $showid = null) function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $showid = null)
{ {
...@@ -1713,11 +1723,11 @@ function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $sh ...@@ -1713,11 +1723,11 @@ function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $sh
/** /**
* Return the HTML representation of the URL for $questionid - other parameters as for qa_q_path() * Return the HTML representation of the URL for $questionid - other parameters as for qa_q_path()
* @param $questionid * @param int $questionid
* @param $title * @param string $title
* @param bool $absolute * @param bool|null $absolute
* @param string $showtype * @param string|null $showtype
* @param int $showid * @param int|null $showid
* @return mixed|string * @return mixed|string
*/ */
function qa_q_path_html($questionid, $title, $absolute = false, $showtype = null, $showid = null) function qa_q_path_html($questionid, $title, $absolute = false, $showtype = null, $showid = null)
...@@ -1728,8 +1738,8 @@ function qa_q_path_html($questionid, $title, $absolute = false, $showtype = null ...@@ -1728,8 +1738,8 @@ function qa_q_path_html($questionid, $title, $absolute = false, $showtype = null
/** /**
* Return the request for the specified $feed * Return the request for the specified $feed
* @param $feed * @param string $feed
* @return mixed|string * @return string
*/ */
function qa_feed_request($feed) function qa_feed_request($feed)
{ {
...@@ -1741,6 +1751,7 @@ function qa_feed_request($feed) ...@@ -1741,6 +1751,7 @@ function qa_feed_request($feed)
/** /**
* Return an HTML-ready relative URL for the current page, preserving GET parameters - this is useful for action="..." in HTML forms * Return an HTML-ready relative URL for the current page, preserving GET parameters - this is useful for action="..." in HTML forms
* @return string
*/ */
function qa_self_html() function qa_self_html()
{ {
...@@ -1755,12 +1766,12 @@ function qa_self_html() ...@@ -1755,12 +1766,12 @@ function qa_self_html()
/** /**
* Return HTML for hidden fields to insert into a <form method="get"...> on the page. * Return HTML for hidden fields to insert into a <form method="get"...> on the page.
* This is needed because any parameters on the URL will be lost when the form is submitted. * This is needed because any parameters on the URL will be lost when the form is submitted.
* @param $request * @param string $request
* @param array $params * @param array|null $params
* @param string $rooturl * @param string|null $rooturl
* @param int $neaturls * @param int|null $neaturls
* @param string $anchor * @param string|null $anchor
* @return mixed|string * @return string
*/ */
function qa_path_form_html($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null) function qa_path_form_html($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
{ {
...@@ -1784,11 +1795,11 @@ function qa_path_form_html($request, $params = null, $rooturl = null, $neaturls ...@@ -1784,11 +1795,11 @@ function qa_path_form_html($request, $params = null, $rooturl = null, $neaturls
/** /**
* Redirect the user's web browser to $request and then we're done - see qa_path() for other parameters * Redirect the user's web browser to $request and then we're done - see qa_path() for other parameters
* @param $request * @param string $request
* @param array $params * @param array|null $params
* @param string $rooturl * @param string|null $rooturl
* @param int $neaturls * @param int|null $neaturls
* @param string $anchor * @param string|null $anchor
* @return mixed * @return mixed
*/ */
function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null) function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null, $anchor = null)
...@@ -1801,7 +1812,7 @@ function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null ...@@ -1801,7 +1812,7 @@ function qa_redirect($request, $params = null, $rooturl = null, $neaturls = null
/** /**
* Redirect the user's web browser to page $path which is already a URL * Redirect the user's web browser to page $path which is already a URL
* @param $url * @param string $url
* @return mixed * @return mixed
*/ */
function qa_redirect_raw($url) function qa_redirect_raw($url)
...@@ -1817,8 +1828,8 @@ function qa_redirect_raw($url) ...@@ -1817,8 +1828,8 @@ function qa_redirect_raw($url)
/** /**
* Return the contents of remote $url, using file_get_contents() if possible, otherwise curl functions * Return the contents of remote $url, using file_get_contents() if possible, otherwise curl functions
* @param $url * @param string $url
* @return mixed|string * @return bool|string
*/ */
function qa_retrieve_url($url) function qa_retrieve_url($url)
{ {
...@@ -1875,9 +1886,9 @@ function qa_service($key, $object = null) ...@@ -1875,9 +1886,9 @@ function qa_service($key, $object = null)
/** /**
* Shortcut to get or set an option value without specifying database * Shortcut to get or set an option value without specifying database
* @param $name * @param string $name
* @param mixed $value * @param mixed|null $value
* @return * @return string
*/ */
function qa_opt($name, $value = null) function qa_opt($name, $value = null)
{ {
...@@ -1898,7 +1909,7 @@ function qa_opt($name, $value = null) ...@@ -1898,7 +1909,7 @@ function qa_opt($name, $value = null)
/** /**
* Simple method to output a preformatted variable * Simple method to output a preformatted variable
* @param $var * @param mixed $var
*/ */
function qa_debug($var) function qa_debug($var)
{ {
...@@ -1925,12 +1936,12 @@ function qa_suspend_event_reports($suspend = true) ...@@ -1925,12 +1936,12 @@ function qa_suspend_event_reports($suspend = true)
/** /**
* Send a notification of event $event by $userid, $handle and $cookieid to all event modules, with extra $params * Send a notification of event $event by $userid, $handle and $cookieid to all event modules, with extra $params
* @param $event * @param string $event
* @param $userid * @param mixed $userid
* @param $handle * @param string $handle
* @param $cookieid * @param string $cookieid
* @param array $params * @param array $params
* @return mixed|void * @return mixed
*/ */
function qa_report_event($event, $userid, $handle, $cookieid, $params = array()) function qa_report_event($event, $userid, $handle, $cookieid, $params = array())
{ {
...@@ -1946,7 +1957,10 @@ function qa_report_event($event, $userid, $handle, $cookieid, $params = array()) ...@@ -1946,7 +1957,10 @@ function qa_report_event($event, $userid, $handle, $cookieid, $params = array())
$eventmodule->process_event($event, $userid, $handle, $cookieid, $params); $eventmodule->process_event($event, $userid, $handle, $cookieid, $params);
} }
/**
* Execute the given $method in all process modules. Parameters can be sent as arguments.
* @param string $method
*/
function qa_report_process_stage($method) // can have extra params function qa_report_process_stage($method) // can have extra params
{ {
global $qa_process_reports_suspended; global $qa_process_reports_suspended;
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
More about this license: http://www.question2answer.org/license.php More about this license: http://www.question2answer.org/license.php
*/ */
use Q2A\Database\DbResult;
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
...@@ -42,8 +44,8 @@ function qa_db_allow_connect() ...@@ -42,8 +44,8 @@ function qa_db_allow_connect()
* Connect to the Q2A database, select the right database, optionally install the $failhandler (and call it if necessary). * Connect to the Q2A database, select the right database, optionally install the $failhandler (and call it if necessary).
* Uses mysqli as of Q2A 1.7. * Uses mysqli as of Q2A 1.7.
* @deprecated 1.9.0 Use DbConnection->connect() instead. * @deprecated 1.9.0 Use DbConnection->connect() instead.
* @param null $failhandler * @param string|null $failhandler
* @return mixed|void * @return mixed
*/ */
function qa_db_connect($failhandler = null) function qa_db_connect($failhandler = null)
{ {
...@@ -56,7 +58,7 @@ function qa_db_connect($failhandler = null) ...@@ -56,7 +58,7 @@ function qa_db_connect($failhandler = null)
/** /**
* If a DB error occurs, call the installed fail handler (if any) otherwise report error and exit immediately. * If a DB error occurs, call the installed fail handler (if any) otherwise report error and exit immediately.
* @deprecated 1.9.0 Use DbConnection->failError() instead. * @deprecated 1.9.0 Use DbConnection->failError() instead.
* @param $type * @param string $type
* @param int $errno * @param int $errno
* @param string $error * @param string $error
* @param string $query * @param string $query
...@@ -105,8 +107,8 @@ function qa_db_disconnect() ...@@ -105,8 +107,8 @@ function qa_db_disconnect()
* Run the raw $query, call the global failure handler if necessary, otherwise return the result resource. * Run the raw $query, call the global failure handler if necessary, otherwise return the result resource.
* If appropriate, also track the resources used by database queries, and the queries themselves, for performance debugging. * If appropriate, also track the resources used by database queries, and the queries themselves, for performance debugging.
* @deprecated 1.9.0 Use DbConnection->query() instead. * @deprecated 1.9.0 Use DbConnection->query() instead.
* @param $query * @param string $query
* @return mixed * @return DbResult
*/ */
function qa_db_query_raw($query) function qa_db_query_raw($query)
{ {
...@@ -119,8 +121,8 @@ function qa_db_query_raw($query) ...@@ -119,8 +121,8 @@ function qa_db_query_raw($query)
/** /**
* Lower-level function to execute a query, which automatically retries if there is a MySQL deadlock error. * Lower-level function to execute a query, which automatically retries if there is a MySQL deadlock error.
* @deprecated 1.9.0 Use DbConnection->query() instead. * @deprecated 1.9.0 Use DbConnection->query() instead.
* @param $query * @param string $query
* @return mixed * @return DbResult
*/ */
function qa_db_query_execute($query) function qa_db_query_execute($query)
{ {
...@@ -133,8 +135,8 @@ function qa_db_query_execute($query) ...@@ -133,8 +135,8 @@ function qa_db_query_execute($query)
/** /**
* Return $string escaped for use in queries to the Q2A database (to which a connection must have been made). * Return $string escaped for use in queries to the Q2A database (to which a connection must have been made).
* @deprecated 1.9.0 No longer needed: parameters passed to DbConnection->query() are automatically escaped. * @deprecated 1.9.0 No longer needed: parameters passed to DbConnection->query() are automatically escaped.
* @param $string * @param string $string
* @return mixed * @return string
*/ */
function qa_db_escape_string($string) function qa_db_escape_string($string)
{ {
...@@ -151,8 +153,8 @@ function qa_db_escape_string($string) ...@@ -151,8 +153,8 @@ function qa_db_escape_string($string)
* Return $argument escaped for MySQL. Add quotes around it if $alwaysquote is true or it's not numeric. * Return $argument escaped for MySQL. Add quotes around it if $alwaysquote is true or it's not numeric.
* If $argument is an array, return a comma-separated list of escaped elements, with or without $arraybrackets. * If $argument is an array, return a comma-separated list of escaped elements, with or without $arraybrackets.
* @deprecated 1.9.0 * @deprecated 1.9.0
* @param $argument * @param mixed|null $argument
* @param $alwaysquote * @param bool $alwaysquote
* @param bool $arraybrackets * @param bool $arraybrackets
* @return mixed|string * @return mixed|string
*/ */
...@@ -184,7 +186,7 @@ function qa_db_argument_to_mysql($argument, $alwaysquote, $arraybrackets = false ...@@ -184,7 +186,7 @@ function qa_db_argument_to_mysql($argument, $alwaysquote, $arraybrackets = false
/** /**
* Return the full name (with prefix) of database table $rawname, usually if it used after a ^ symbol. * Return the full name (with prefix) of database table $rawname, usually if it used after a ^ symbol.
* @deprecated 1.9.0 Use DbConnection->addTablePrefix() instead. * @deprecated 1.9.0 Use DbConnection->addTablePrefix() instead.
* @param $rawname * @param string $rawname
* @return string * @return string
*/ */
function qa_db_add_table_prefix($rawname) function qa_db_add_table_prefix($rawname)
...@@ -198,7 +200,7 @@ function qa_db_add_table_prefix($rawname) ...@@ -198,7 +200,7 @@ function qa_db_add_table_prefix($rawname)
/** /**
* Callback function to add table prefixes, as used in qa_db_apply_sub(). * Callback function to add table prefixes, as used in qa_db_apply_sub().
* @deprecated 1.9.0 No longer needed. * @deprecated 1.9.0 No longer needed.
* @param $matches * @param array $matches
* @return string * @return string
*/ */
function qa_db_prefix_callback($matches) function qa_db_prefix_callback($matches)
...@@ -214,8 +216,8 @@ function qa_db_prefix_callback($matches) ...@@ -214,8 +216,8 @@ function qa_db_prefix_callback($matches)
* $ is replaced by the argument in quotes (even if it's a number), # only adds quotes if the argument is non-numeric. * $ is replaced by the argument in quotes (even if it's a number), # only adds quotes if the argument is non-numeric.
* It's important to use $ when matching a textual column since MySQL won't use indexes to compare text against numbers. * It's important to use $ when matching a textual column since MySQL won't use indexes to compare text against numbers.
* @deprecated 1.9.0 Use DbConnection->applyTableSub() instead. * @deprecated 1.9.0 Use DbConnection->applyTableSub() instead.
* @param $query * @param string $query
* @param $arguments * @param array $arguments
* @return mixed * @return mixed
*/ */
function qa_db_apply_sub($query, $arguments) function qa_db_apply_sub($query, $arguments)
...@@ -258,7 +260,7 @@ function qa_db_apply_sub($query, $arguments) ...@@ -258,7 +260,7 @@ function qa_db_apply_sub($query, $arguments)
* Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler). * Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler).
* @deprecated 1.9.0 Use DbConnection->query() instead. * @deprecated 1.9.0 Use DbConnection->query() instead.
* @param string $query * @param string $query
* @return mixed * @return DbResult
*/ */
function qa_db_query_sub($query) // arguments for substitution retrieved using func_get_args() function qa_db_query_sub($query) // arguments for substitution retrieved using func_get_args()
{ {
...@@ -266,13 +268,14 @@ function qa_db_query_sub($query) // arguments for substitution retrieved using f ...@@ -266,13 +268,14 @@ function qa_db_query_sub($query) // arguments for substitution retrieved using f
return qa_service('database')->query($query, $params); return qa_service('database')->query($query, $params);
} }
/** /**
* Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler). * Run $query after substituting ^, # and $ symbols, and return the result resource (or call fail handler).
* Query parameters are passed as an array. * Query parameters are passed as an array.
* @deprecated 1.9.0 Use DbConnection->query() instead. * @deprecated 1.9.0 Use DbConnection->query() instead.
* @param string $query * @param string $query
* @param array $params * @param array $params
* @return mixed * @return DbResult
*/ */
function qa_db_query_sub_params($query, $params) function qa_db_query_sub_params($query, $params)
{ {
...@@ -283,7 +286,7 @@ function qa_db_query_sub_params($query, $params) ...@@ -283,7 +286,7 @@ function qa_db_query_sub_params($query, $params)
/** /**
* Return the number of rows in $result. (Simple wrapper for mysqli_result::num_rows.) * Return the number of rows in $result. (Simple wrapper for mysqli_result::num_rows.)
* @deprecated 1.9.0 Use DbResult->affectedRows() instead. * @deprecated 1.9.0 Use DbResult->affectedRows() instead.
* @param $result * @param DbResult|mysqli_result $result
* @return int * @return int
*/ */
function qa_db_num_rows($result) function qa_db_num_rows($result)
...@@ -303,6 +306,7 @@ function qa_db_num_rows($result) ...@@ -303,6 +306,7 @@ function qa_db_num_rows($result)
/** /**
* Return the value of the auto-increment column for the last inserted row. * Return the value of the auto-increment column for the last inserted row.
* @deprecated 1.9.0 Use DbConnection->lastInsertId() instead. * @deprecated 1.9.0 Use DbConnection->lastInsertId() instead.
* @return string
*/ */
function qa_db_last_insert_id() function qa_db_last_insert_id()
{ {
...@@ -313,6 +317,7 @@ function qa_db_last_insert_id() ...@@ -313,6 +317,7 @@ function qa_db_last_insert_id()
/** /**
* Return the number of rows affected by the last query. * Return the number of rows affected by the last query.
* @deprecated 1.9.0 Use DbResult->affectedRows() instead. * @deprecated 1.9.0 Use DbResult->affectedRows() instead.
* @return int
*/ */
function qa_db_affected_rows() function qa_db_affected_rows()
{ {
...@@ -324,16 +329,18 @@ function qa_db_affected_rows() ...@@ -324,16 +329,18 @@ function qa_db_affected_rows()
/** /**
* For the previous INSERT ... ON DUPLICATE KEY UPDATE query, return whether an insert operation took place. * For the previous INSERT ... ON DUPLICATE KEY UPDATE query, return whether an insert operation took place.
* @deprecated 1.9.0 Use DbResult->affectedRows() instead. * @deprecated 1.9.0 Use DbResult->affectedRows() instead.
* @return bool
*/ */
function qa_db_insert_on_duplicate_inserted() function qa_db_insert_on_duplicate_inserted()
{ {
return (qa_db_affected_rows() == 1); return false;
} }
/** /**
* Return a random integer (as a string) for use in a BIGINT column. * Return a random integer (as a string) for use in a BIGINT column.
* Actual limit is 18,446,744,073,709,551,615 - we aim for 18,446,743,999,999,999,999. * Actual limit is 18,446,744,073,709,551,615 - we aim for 18,446,743,999,999,999,999.
* @return string
*/ */
function qa_db_random_bigint() function qa_db_random_bigint()
{ {
...@@ -344,6 +351,7 @@ function qa_db_random_bigint() ...@@ -344,6 +351,7 @@ function qa_db_random_bigint()
/** /**
* Return an array of the names of all tables in the Q2A database, converted to lower case. * Return an array of the names of all tables in the Q2A database, converted to lower case.
* No longer used by Q2A and shouldn't be needed. * No longer used by Q2A and shouldn't be needed.
* @return array
*/ */
function qa_db_list_tables_lc() function qa_db_list_tables_lc()
{ {
...@@ -423,8 +431,8 @@ function qa_db_list_tables($onlyTablesWithPrefix = false) ...@@ -423,8 +431,8 @@ function qa_db_list_tables($onlyTablesWithPrefix = false)
/** /**
* Return the data specified by a single $selectspec - see long comment above. * Return the data specified by a single $selectspec - see long comment above.
* @deprecated 1.9.0 Use DbConnection->singleSelect() instead. * @deprecated 1.9.0 Use DbConnection->singleSelect() instead.
* @param $selectspec * @param array $selectspec
* @return array|mixed * @return mixed
*/ */
function qa_db_single_select($selectspec) function qa_db_single_select($selectspec)
{ {
...@@ -496,9 +504,9 @@ function qa_db_post_select(&$outresult, $selectspec) ...@@ -496,9 +504,9 @@ function qa_db_post_select(&$outresult, $selectspec)
* is from column $key if specified, otherwise it's integer. The value of each element in the returned array * is from column $key if specified, otherwise it's integer. The value of each element in the returned array
* is from column $value if specified, otherwise it's a named array of all columns, given an array of arrays. * is from column $value if specified, otherwise it's a named array of all columns, given an array of arrays.
* @deprecated 1.9.0 Use DbResult->fetchAllAssoc() instead. * @deprecated 1.9.0 Use DbResult->fetchAllAssoc() instead.
* @param $result * @param DbResult|mysqli_result $result
* @param string $key * @param string|null $key
* @param mixed $value * @param int|string|null $value
* @return array * @return array
*/ */
function qa_db_read_all_assoc($result, $key = null, $value = null) function qa_db_read_all_assoc($result, $key = null, $value = null)
...@@ -529,7 +537,7 @@ function qa_db_read_all_assoc($result, $key = null, $value = null) ...@@ -529,7 +537,7 @@ function qa_db_read_all_assoc($result, $key = null, $value = null)
* Return the first row from the $result resource as an array of [column name] => [column value]. * Return the first row from the $result resource as an array of [column name] => [column value].
* If there's no first row, throw a fatal error unless $allowempty is true. * If there's no first row, throw a fatal error unless $allowempty is true.
* @deprecated 1.9.0 Use DbResult->fetchNextAssoc() instead. * @deprecated 1.9.0 Use DbResult->fetchNextAssoc() instead.
* @param $result * @param DbResult|mysqli_result $result
* @param bool $allowempty * @param bool $allowempty
* @return array|null * @return array|null
*/ */
...@@ -539,7 +547,6 @@ function qa_db_read_one_assoc($result, $allowempty = false) ...@@ -539,7 +547,6 @@ function qa_db_read_one_assoc($result, $allowempty = false)
return $allowempty ? $result->fetchNextAssoc() : $result->fetchNextAssocOrFail(); return $allowempty ? $result->fetchNextAssoc() : $result->fetchNextAssocOrFail();
} }
// backwards compatibility // backwards compatibility
if (!($result instanceof mysqli_result)) if (!($result instanceof mysqli_result))
qa_fatal_error('Reading one assoc from invalid result'); qa_fatal_error('Reading one assoc from invalid result');
...@@ -559,7 +566,7 @@ function qa_db_read_one_assoc($result, $allowempty = false) ...@@ -559,7 +566,7 @@ function qa_db_read_one_assoc($result, $allowempty = false)
/** /**
* Return a numbered array containing the first (and presumably only) column from the $result resource. * Return a numbered array containing the first (and presumably only) column from the $result resource.
* @deprecated 1.9.0 Use DbResult->fetchAllValues() instead. * @deprecated 1.9.0 Use DbResult->fetchAllValues() instead.
* @param $result * @param DbResult|mysqli_result $result
* @return array * @return array
*/ */
function qa_db_read_all_values($result) function qa_db_read_all_values($result)
...@@ -568,7 +575,6 @@ function qa_db_read_all_values($result) ...@@ -568,7 +575,6 @@ function qa_db_read_all_values($result)
return $result->fetchAllValues(0); return $result->fetchAllValues(0);
} }
// backwards compatibility // backwards compatibility
if (!($result instanceof mysqli_result)) if (!($result instanceof mysqli_result))
qa_fatal_error('Reading column from invalid result'); qa_fatal_error('Reading column from invalid result');
...@@ -586,9 +592,9 @@ function qa_db_read_all_values($result) ...@@ -586,9 +592,9 @@ function qa_db_read_all_values($result)
* Return the first column of the first row (and presumably only cell) from the $result resource. * Return the first column of the first row (and presumably only cell) from the $result resource.
* If there's no first row, throw a fatal error unless $allowempty is true. * If there's no first row, throw a fatal error unless $allowempty is true.
* @deprecated 1.9.0 Use DbResult->fetchOneValue() instead. * @deprecated 1.9.0 Use DbResult->fetchOneValue() instead.
* @param $result * @param DbResult|mysqli_result $result
* @param bool $allowempty * @param bool $allowempty
* @return mixed|null * @return string|null
*/ */
function qa_db_read_one_value($result, $allowempty = false) function qa_db_read_one_value($result, $allowempty = false)
{ {
...@@ -596,7 +602,6 @@ function qa_db_read_one_value($result, $allowempty = false) ...@@ -596,7 +602,6 @@ function qa_db_read_one_value($result, $allowempty = false)
return $allowempty ? $result->fetchOneValue(0) : $result->fetchOneValueOrFail(0); return $allowempty ? $result->fetchOneValue(0) : $result->fetchOneValueOrFail(0);
} }
// backwards compatibility // backwards compatibility
if (!($result instanceof mysqli_result)) if (!($result instanceof mysqli_result))
qa_fatal_error('Reading one value from invalid result'); qa_fatal_error('Reading one value from invalid result');
......
...@@ -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
......
...@@ -38,29 +38,60 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -38,29 +38,60 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
class qa_html_theme_base class qa_html_theme_base
{ {
/** @var string */
public $template; public $template;
/** @var array */
public $content; public $content;
/** @var string */
public $rooturl; public $rooturl;
/** @var string */
public $request; public $request;
public $isRTL; // (boolean) whether text direction is Right-To-Left
protected $minifyHtml; // (boolean) whether to indent the HTML /**
* Whether text direction is Right-To-Left
*
* @var bool
*/
public $isRTL;
/**
* Whether to indent the HTML
*
* @var bool
*/
protected $minifyHtml;
/** @var int */
protected $indent = 0; protected $indent = 0;
/** @var int */
protected $lines = 0; protected $lines = 0;
/** @var array */
protected $context = array(); protected $context = array();
// whether to use new block layout in rankings (true) or fall back to tables (false) /**
* Whether to use new block layout in rankings (true) or fall back to tables (false)
* @var bool
*/
protected $ranking_block_layout = false; protected $ranking_block_layout = false;
// theme 'slug' to use as CSS class
/**
* Theme 'slug' to use as CSS class
* @var string
*/
protected $theme; protected $theme;
/** /**
* Initialize the object and assign local variables. * Initialize the object and assign local variables.
* @param $template * @param string $template
* @param $content * @param string $content
* @param $rooturl * @param string $rooturl
* @param $request * @param string $request
*/ */
public function __construct($template, $content, $rooturl, $request) public function __construct($template, $content, $rooturl, $request)
{ {
...@@ -75,10 +106,10 @@ class qa_html_theme_base ...@@ -75,10 +106,10 @@ class qa_html_theme_base
/** /**
* @deprecated PHP4-style constructor deprecated from 1.7; please use proper `__construct` * @deprecated PHP4-style constructor deprecated from 1.7; please use proper `__construct`
* function instead. * function instead.
* @param $template * @param string $template
* @param $content * @param string $content
* @param $rooturl * @param string $rooturl
* @param $request * @param string $request
*/ */
public function qa_html_theme_base($template, $content, $rooturl, $request) public function qa_html_theme_base($template, $content, $rooturl, $request)
{ {
...@@ -90,7 +121,7 @@ class qa_html_theme_base ...@@ -90,7 +121,7 @@ class qa_html_theme_base
* Output each element in $elements on a separate line, with automatic HTML indenting. * Output each element in $elements on a separate line, with automatic HTML indenting.
* This should be passed markup which uses the <tag/> form for unpaired tags, to help keep * This should be passed markup which uses the <tag/> form for unpaired tags, to help keep
* track of indenting, although its actual output converts these to <tag> for W3C validation. * track of indenting, although its actual output converts these to <tag> for W3C validation.
* @param $elements * @param array $elements
*/ */
public function output_array($elements) public function output_array($elements)
{ {
...@@ -132,7 +163,7 @@ class qa_html_theme_base ...@@ -132,7 +163,7 @@ class qa_html_theme_base
/** /**
* Output $html at the current indent level, but don't change indent level based on the markup within. * Output $html at the current indent level, but don't change indent level based on the markup within.
* Useful for user-entered HTML which is unlikely to follow the rules we need to track indenting. * Useful for user-entered HTML which is unlikely to follow the rules we need to track indenting.
* @param $html * @param string $html
*/ */
public function output_raw($html) public function output_raw($html)
{ {
...@@ -144,8 +175,8 @@ class qa_html_theme_base ...@@ -144,8 +175,8 @@ class qa_html_theme_base
/** /**
* Output the three elements ['prefix'], ['data'] and ['suffix'] of $parts (if they're defined), * Output the three elements ['prefix'], ['data'] and ['suffix'] of $parts (if they're defined),
* with appropriate CSS classes based on $class, using $outertag and $innertag in the markup. * with appropriate CSS classes based on $class, using $outertag and $innertag in the markup.
* @param $parts * @param array $parts
* @param $class * @param string $class
* @param string $outertag * @param string $outertag
* @param string $innertag * @param string $innertag
* @param string $extraclass * @param string $extraclass
...@@ -167,8 +198,8 @@ class qa_html_theme_base ...@@ -167,8 +198,8 @@ class qa_html_theme_base
/** /**
* Set some context, which be accessed via $this->context for a function to know where it's being used on the page. * Set some context, which be accessed via $this->context for a function to know where it's being used on the page.
* @param $key * @param string $key
* @param $value * @param string $value
*/ */
public function set_context($key, $value) public function set_context($key, $value)
{ {
...@@ -178,7 +209,7 @@ class qa_html_theme_base ...@@ -178,7 +209,7 @@ class qa_html_theme_base
/** /**
* Clear some context (used at the end of the appropriate loop). * Clear some context (used at the end of the appropriate loop).
* @param $key * @param string $key
*/ */
public function clear_context($key) public function clear_context($key)
{ {
...@@ -189,8 +220,8 @@ class qa_html_theme_base ...@@ -189,8 +220,8 @@ class qa_html_theme_base
/** /**
* Reorder the parts of the page according to the $parts array which contains part keys in their new order. Call this * Reorder the parts of the page according to the $parts array which contains part keys in their new order. Call this
* before main_parts(). See the docs for qa_array_reorder() in util/sort.php for the other parameters. * before main_parts(). See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $parts * @param array $parts
* @param string $beforekey * @param string|null $beforekey
* @param bool $reorderrelative * @param bool $reorderrelative
*/ */
public function reorder_parts($parts, $beforekey = null, $reorderrelative = true) public function reorder_parts($parts, $beforekey = null, $reorderrelative = true)
...@@ -203,8 +234,8 @@ class qa_html_theme_base ...@@ -203,8 +234,8 @@ class qa_html_theme_base
/** /**
* Output the widgets (as provided in $this->content['widgets']) for $region and $place. * Output the widgets (as provided in $this->content['widgets']) for $region and $place.
* @param $region * @param string $region
* @param $place * @param string $place
*/ */
public function widgets($region, $place) public function widgets($region, $place)
{ {
...@@ -1017,8 +1048,8 @@ class qa_html_theme_base ...@@ -1017,8 +1048,8 @@ class qa_html_theme_base
/** /**
* Reorder the fields of $form according to the $keys array which contains the field keys in their new order. Call * Reorder the fields of $form according to the $keys array which contains the field keys in their new order. Call
* before any fields are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters. * before any fields are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $form * @param array
* @param $keys * @param array $keys
* @param mixed $beforekey * @param mixed $beforekey
* @param bool $reorderrelative * @param bool $reorderrelative
*/ */
...@@ -1205,8 +1236,8 @@ class qa_html_theme_base ...@@ -1205,8 +1236,8 @@ class qa_html_theme_base
/** /**
* Reorder the buttons of $form according to the $keys array which contains the button keys in their new order. Call * Reorder the buttons of $form according to the $keys array which contains the button keys in their new order. Call
* before any buttons are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters. * before any buttons are output. See the docs for qa_array_reorder() in util/sort.php for the other parameters.
* @param $form * @param array $form
* @param $keys * @param array $keys
* @param mixed $beforekey * @param mixed $beforekey
* @param bool $reorderrelative * @param bool $reorderrelative
*/ */
...@@ -1477,7 +1508,7 @@ class qa_html_theme_base ...@@ -1477,7 +1508,7 @@ class qa_html_theme_base
* removed in a future version. Themes can switch to the new layout by setting the member * removed in a future version. Themes can switch to the new layout by setting the member
* variable $ranking_block_layout to false. * variable $ranking_block_layout to false.
* @param $ranking * @param $ranking
* @param $class * @param string $class
*/ */
public function ranking_table($ranking, $class) public function ranking_table($ranking, $class)
{ {
...@@ -1507,7 +1538,7 @@ class qa_html_theme_base ...@@ -1507,7 +1538,7 @@ class qa_html_theme_base
/** /**
* @deprecated See ranking_table above. * @deprecated See ranking_table above.
* @param $item * @param $item
* @param $class * @param string $class
* @param $spacer * @param $spacer
*/ */
public function ranking_table_item($item, $class, $spacer) public function ranking_table_item($item, $class, $spacer)
...@@ -1535,7 +1566,7 @@ class qa_html_theme_base ...@@ -1535,7 +1566,7 @@ class qa_html_theme_base
/** /**
* @deprecated See ranking_table above. * @deprecated See ranking_table above.
* @param $class * @param string $class
*/ */
public function ranking_spacer($class) public function ranking_spacer($class)
{ {
...@@ -1897,8 +1928,8 @@ class qa_html_theme_base ...@@ -1897,8 +1928,8 @@ class qa_html_theme_base
/** /**
* @deprecated Deprecated from 1.7; please use avatar() instead. * @deprecated Deprecated from 1.7; please use avatar() instead.
* @param $post * @param array $post
* @param $class * @param string $class
* @param string $prefix * @param string $prefix
*/ */
public function post_avatar($post, $class, $prefix = null) public function post_avatar($post, $class, $prefix = null)
......
...@@ -39,8 +39,8 @@ function qa_has_gd_image() ...@@ -39,8 +39,8 @@ function qa_has_gd_image()
* Check if the image in $imagefile will be too big for PHP/GD to process given memory usage and limits * Check if the image in $imagefile will be too big for PHP/GD to process given memory usage and limits
* Pass the width and height limit beyond which the image will require scaling in $size (if any) * Pass the width and height limit beyond which the image will require scaling in $size (if any)
* Returns false if the image will fit fine, otherwise a safe estimate of the factor the image should be sized by * Returns false if the image will fit fine, otherwise a safe estimate of the factor the image should be sized by
* @param $imagefile * @param string $imagefile
* @param int $size * @param int|null $size
* @return bool|float * @return bool|float
*/ */
function qa_image_file_too_big($imagefile, $size = null) function qa_image_file_too_big($imagefile, $size = null)
...@@ -82,12 +82,12 @@ function qa_image_file_too_big($imagefile, $size = null) ...@@ -82,12 +82,12 @@ function qa_image_file_too_big($imagefile, $size = null)
* Given $imagedata containing JPEG/GIF/PNG data, constrain it proportionally to fit in $maxwidth x $maxheight. * Given $imagedata containing JPEG/GIF/PNG data, constrain it proportionally to fit in $maxwidth x $maxheight.
* Return the new image data (will always be a JPEG), and set the $width and $height variables. * Return the new image data (will always be a JPEG), and set the $width and $height variables.
* If $maxheight is omitted or set to null, assume it to be the same as $maxwidth. * If $maxheight is omitted or set to null, assume it to be the same as $maxwidth.
* @param $imagedata * @param string $imagedata
* @param int $width * @param int $width
* @param int $height * @param int $height
* @param int $maxwidth * @param int $maxwidth
* @param int $maxheight * @param int|null $maxheight
* @return null|string * @return string|null
*/ */
function qa_image_constrain_data($imagedata, &$width, &$height, $maxwidth, $maxheight = null) function qa_image_constrain_data($imagedata, &$width, &$height, $maxwidth, $maxheight = null)
{ {
...@@ -119,7 +119,7 @@ function qa_image_constrain_data($imagedata, &$width, &$height, $maxwidth, $maxh ...@@ -119,7 +119,7 @@ function qa_image_constrain_data($imagedata, &$width, &$height, $maxwidth, $maxh
* @param int $width * @param int $width
* @param int $height * @param int $height
* @param int $maxwidth * @param int $maxwidth
* @param int $maxheight * @param int|null $maxheight
* @return bool * @return bool
*/ */
function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null) function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null)
...@@ -141,9 +141,9 @@ function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null) ...@@ -141,9 +141,9 @@ function qa_image_constrain(&$width, &$height, $maxwidth, $maxheight = null)
/** /**
* Resize the GD $image to $width and $height, setting it to null if the resize failed * Resize the GD $image to $width and $height, setting it to null if the resize failed
* @param $image * @param resource $image
* @param $width * @param int $width
* @param $height * @param int $height
*/ */
function qa_gd_image_resize(&$image, $width, $height) function qa_gd_image_resize(&$image, $width, $height)
{ {
...@@ -181,6 +181,7 @@ function qa_gd_image_jpeg($image, $output = false) ...@@ -181,6 +181,7 @@ function qa_gd_image_jpeg($image, $output = false)
/** /**
* Return an array of strings listing the image formats that are supported * Return an array of strings listing the image formats that are supported
* @return array
*/ */
function qa_gd_image_formats() function qa_gd_image_formats()
{ {
......
...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly ...@@ -27,9 +27,9 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/** /**
* Sort the $array of inner arrays by sub-element $by1 of each inner array, and optionally then by sub-element $by2 * Sort the $array of inner arrays by sub-element $by1 of each inner array, and optionally then by sub-element $by2
* @param $array * @param array $array
* @param $by1 * @param string $by1
* @param null $by2 * @param string|null $by2
*/ */
function qa_sort_by(&$array, $by1, $by2 = null) function qa_sort_by(&$array, $by1, $by2 = null)
{ {
...@@ -44,8 +44,8 @@ function qa_sort_by(&$array, $by1, $by2 = null) ...@@ -44,8 +44,8 @@ function qa_sort_by(&$array, $by1, $by2 = null)
/** /**
* Function used in uasort to implement qa_sort_by() * Function used in uasort to implement qa_sort_by()
* @param $a * @param array $a
* @param $b * @param array $b
* @return int * @return int
*/ */
function qa_sort_by_fn($a, $b) function qa_sort_by_fn($a, $b)
...@@ -73,8 +73,8 @@ function qa_sort_by_fn($a, $b) ...@@ -73,8 +73,8 @@ function qa_sort_by_fn($a, $b)
/** /**
* General comparison function for two values, textual or numeric * General comparison function for two values, textual or numeric
* @deprecated * @deprecated
* @param $a * @param int|float|string $a
* @param $b * @param int|float|string $b
* @return int * @return int
*/ */
function qa_sort_cmp($a, $b) function qa_sort_cmp($a, $b)
...@@ -89,9 +89,9 @@ function qa_sort_cmp($a, $b) ...@@ -89,9 +89,9 @@ function qa_sort_cmp($a, $b)
/** /**
* Inserts $addelements into $array, preserving their keys, before $beforekey in that array. * Inserts $addelements into $array, preserving their keys, before $beforekey in that array.
* If $beforekey cannot be found, the elements are appended at the end of the array. * If $beforekey cannot be found, the elements are appended at the end of the array.
* @param $array * @param array $array
* @param $beforekey * @param string $beforekey
* @param $addelements * @param array $addelements
*/ */
function qa_array_insert(&$array, $beforekey, $addelements) function qa_array_insert(&$array, $beforekey, $addelements)
{ {
...@@ -130,9 +130,9 @@ define('QA_ARRAY_AT_END', 0.9); // place all the elements at the end of the arra ...@@ -130,9 +130,9 @@ define('QA_ARRAY_AT_END', 0.9); // place all the elements at the end of the arra
* element by passing the key of that element in $beforekey (if $beforekey is not found, the elements are moved to the * element by passing the key of that element in $beforekey (if $beforekey is not found, the elements are moved to the
* end of the array). Any of the QA_ARRAY_* values defined above can also be passed in the $beforekey parameter. * end of the array). Any of the QA_ARRAY_* values defined above can also be passed in the $beforekey parameter.
* If $reorderrelative is true, the relative ordering between the elements will also be set by the order in $keys. * If $reorderrelative is true, the relative ordering between the elements will also be set by the order in $keys.
* @param $array * @param array $array
* @param $keys * @param array $keys
* @param mixed $beforekey * @param mixed|null $beforekey
* @param bool $reorderrelative * @param bool $reorderrelative
*/ */
function qa_array_reorder(&$array, $keys, $beforekey = null, $reorderrelative = true) function qa_array_reorder(&$array, $keys, $beforekey = null, $reorderrelative = true)
......
...@@ -421,7 +421,7 @@ function qa_string_initialize() ...@@ -421,7 +421,7 @@ function qa_string_initialize()
* Return the UTF-8 input string converted into an array of words, changed $tolowercase (or not). * Return the UTF-8 input string converted into an array of words, changed $tolowercase (or not).
* Set $delimiters to true to keep the delimiters after each word and tweak what we used for word * Set $delimiters to true to keep the delimiters after each word and tweak what we used for word
* splitting with $splitideographs and $splithyphens. * splitting with $splitideographs and $splithyphens.
* @param $string * @param string $string
* @param bool $tolowercase * @param bool $tolowercase
* @param bool $delimiters * @param bool $delimiters
* @param bool $splitideographs * @param bool $splitideographs
...@@ -521,8 +521,8 @@ function qa_slugify($string, $asciiOnly = true, $maxLength = null) ...@@ -521,8 +521,8 @@ function qa_slugify($string, $asciiOnly = true, $maxLength = null)
/** /**
* Convert an array of tags into a string for storage in the database * Convert an array of tags into a string for storage in the database
* @param $tags * @param array $tags
* @return mixed|string * @return string
*/ */
function qa_tags_to_tagstring($tags) function qa_tags_to_tagstring($tags)
{ {
...@@ -534,7 +534,7 @@ function qa_tags_to_tagstring($tags) ...@@ -534,7 +534,7 @@ function qa_tags_to_tagstring($tags)
/** /**
* Convert a tag string as stored in the database into an array of tags * Convert a tag string as stored in the database into an array of tags
* @param $tagstring * @param string $tagstring
* @return array|mixed * @return array|mixed
*/ */
function qa_tagstring_to_tags($tagstring) function qa_tagstring_to_tags($tagstring)
...@@ -548,7 +548,6 @@ function qa_tagstring_to_tags($tagstring) ...@@ -548,7 +548,6 @@ function qa_tagstring_to_tags($tagstring)
/** /**
* Converts a string to a single line and removes words from it until it fits in the given length. Words are removed * Converts a string to a single line and removes words from it until it fits in the given length. Words are removed
* from a position around two thirds of the string and are replaced by the given ellipsis string * from a position around two thirds of the string and are replaced by the given ellipsis string
*
* @param string $string Text that will be turned into a single line and cut, if necessary * @param string $string Text that will be turned into a single line and cut, if necessary
* @param int $length Maximum allowed length of the returned string. This value can be overriden by the length of the * @param int $length Maximum allowed length of the returned string. This value can be overriden by the length of the
* ellipsis if it is higher than the maximum allowed length * ellipsis if it is higher than the maximum allowed length
...@@ -596,7 +595,7 @@ function qa_shorten_string_line($string, $length, $ellipsis = ' ... ') ...@@ -596,7 +595,7 @@ function qa_shorten_string_line($string, $length, $ellipsis = ' ... ')
/** /**
* Removes 4-byte Unicode characters (e.g. emoji) from a string due to missing support in MySQL < 5.5.3. * Removes 4-byte Unicode characters (e.g. emoji) from a string due to missing support in MySQL < 5.5.3.
* @param string $string * @param string $string
* @return string * @return string
*/ */
function qa_remove_utf8mb4($string) function qa_remove_utf8mb4($string)
...@@ -611,8 +610,8 @@ function qa_remove_utf8mb4($string) ...@@ -611,8 +610,8 @@ function qa_remove_utf8mb4($string)
/** /**
* Return an array of the words within $wordstring, each of which can contain asterisks * Return an array of the words within $wordstring, each of which can contain asterisks
* @param $wordstring * @param string $wordstring
* @return array|mixed * @return array
*/ */
function qa_block_words_explode($wordstring) function qa_block_words_explode($wordstring)
{ {
...@@ -624,7 +623,7 @@ function qa_block_words_explode($wordstring) ...@@ -624,7 +623,7 @@ function qa_block_words_explode($wordstring)
/** /**
* Return a regular expression fragment corresponding to the block words $wordstring * Return a regular expression fragment corresponding to the block words $wordstring
* @param $wordsstring * @param string $wordsstring
* @return mixed|string * @return mixed|string
*/ */
function qa_block_words_to_preg($wordsstring) function qa_block_words_to_preg($wordsstring)
...@@ -652,8 +651,8 @@ function qa_block_words_to_preg($wordsstring) ...@@ -652,8 +651,8 @@ function qa_block_words_to_preg($wordsstring)
/** /**
* Return an array of matches of the regular expression fragment $wordspreg in $string, [offset] => [length] * Return an array of matches of the regular expression fragment $wordspreg in $string, [offset] => [length]
* @param $string * @param string $string
* @param $wordspreg * @param string $wordspreg
* @return array * @return array
*/ */
function qa_block_words_match_all($string, $wordspreg) function qa_block_words_match_all($string, $wordspreg)
...@@ -693,7 +692,7 @@ function qa_block_words_match_all($string, $wordspreg) ...@@ -693,7 +692,7 @@ function qa_block_words_match_all($string, $wordspreg)
* @param string $string * @param string $string
* @param string $wordspreg * @param string $wordspreg
* @param string $character * @param string $character
* @return mixed * @return string
*/ */
function qa_block_words_replace($string, $wordspreg, $character = '*') function qa_block_words_replace($string, $wordspreg, $character = '*')
{ {
...@@ -713,7 +712,7 @@ function qa_block_words_replace($string, $wordspreg, $character = '*') ...@@ -713,7 +712,7 @@ function qa_block_words_replace($string, $wordspreg, $character = '*')
/** /**
* Return a random alphanumeric string (base 36) of $length * Return a random alphanumeric string (base 36) of $length
* @param $length * @param int $length
* @return string * @return string
*/ */
function qa_random_alphanum($length) function qa_random_alphanum($length)
...@@ -729,8 +728,8 @@ function qa_random_alphanum($length) ...@@ -729,8 +728,8 @@ function qa_random_alphanum($length)
/** /**
* Return true or false to indicate whether $email is a valid email (this is pretty flexible compared to most real emails out there) * Return true or false to indicate whether $email is a valid email (this is pretty flexible compared to most real emails out there)
* @param $email * @param string $email
* @return bool|mixed * @return bool
*/ */
function qa_email_validate($email) function qa_email_validate($email)
{ {
...@@ -742,8 +741,8 @@ function qa_email_validate($email) ...@@ -742,8 +741,8 @@ function qa_email_validate($email)
/** /**
* Return the number of characters in $string, preferably using PHP's multibyte string functions * Return the number of characters in $string, preferably using PHP's multibyte string functions
* @param $string * @param string $string
* @return int|mixed * @return int
*/ */
function qa_strlen($string) function qa_strlen($string)
{ {
...@@ -755,8 +754,8 @@ function qa_strlen($string) ...@@ -755,8 +754,8 @@ function qa_strlen($string)
/** /**
* Return a lower case version of $string, preferably using PHP's multibyte string functions * Return a lower case version of $string, preferably using PHP's multibyte string functions
* @param $string * @param string $string
* @return mixed|string * @return string
*/ */
function qa_strtolower($string) function qa_strtolower($string)
{ {
...@@ -768,10 +767,10 @@ function qa_strtolower($string) ...@@ -768,10 +767,10 @@ function qa_strtolower($string)
/** /**
* Return $length characters from $string, starting from $start, preferably using PHP's multibyte string functions * Return $length characters from $string, starting from $start, preferably using PHP's multibyte string functions
* @param $string * @param string $string
* @param $start * @param int $start
* @param int $length * @param int $length
* @return mixed|string * @return string
*/ */
function qa_substr($string, $start, $length = 2147483647) function qa_substr($string, $start, $length = 2147483647)
{ {
...@@ -783,6 +782,7 @@ function qa_substr($string, $start, $length = 2147483647) ...@@ -783,6 +782,7 @@ function qa_substr($string, $start, $length = 2147483647)
/** /**
* Return whether this version of PHP has been compiled with multibyte string support * Return whether this version of PHP has been compiled with multibyte string support
* @return bool
*/ */
function qa_has_multibyte() function qa_has_multibyte()
{ {
...@@ -792,8 +792,8 @@ function qa_has_multibyte() ...@@ -792,8 +792,8 @@ function qa_has_multibyte()
/** /**
* Return true if at least one of the values in array $matches is a substring of $string. Otherwise, return false. * Return true if at least one of the values in array $matches is a substring of $string. Otherwise, return false.
* @param $string * @param string $string
* @param $matches * @param array $matches
* @return bool * @return bool
*/ */
function qa_string_matches_one($string, $matches) function qa_string_matches_one($string, $matches)
......
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