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)
......
...@@ -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)
{ {
......
...@@ -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)
......
...@@ -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,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)
......
...@@ -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)
......
...@@ -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