Commit 4fb68aa6 by Scott

Coding style (misc)

parent 54ada742
......@@ -68,6 +68,7 @@ class Q2A_Util_Usage
/**
* Mark the beginning of a new stage of script execution and store usages accordingly.
* @param $stage
*/
public function mark($stage)
{
......@@ -78,6 +79,10 @@ class Q2A_Util_Usage
/**
* Logs query and updates database usage stats.
* @param $query
* @param $usedtime
* @param $gotrows
* @param $gotcolumns
*/
public function logDatabaseQuery($query, $usedtime, $gotrows, $gotcolumns)
{
......@@ -197,6 +202,9 @@ class Q2A_Util_Usage
/**
* Return the difference between two resource usage arrays, as an array.
* @param $oldusage
* @param $newusage
* @return array
*/
private function delta($oldusage, $newusage)
{
......
......@@ -903,7 +903,7 @@ function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $d
if (@$question['opersonal'])
$fields['what_your'] = true;
if (($question['obasetype'] != 'Q') || (@$question['oupdatetype'] == QA_UPDATE_FOLLOWS))
if ($question['obasetype'] != 'Q' || @$question['oupdatetype'] == QA_UPDATE_FOLLOWS)
$fields['what_url'] = qa_q_path_html($question['postid'], $question['title'], false, $question['obasetype'], $question['opostid']);
if (@$options['contentview'] && !empty($question['ocontent'])) {
......@@ -1210,7 +1210,7 @@ function qa_html_page_links($request, $start, $pagesize, $count, $prevnext, $par
$thispage = 1 + floor($start / $pagesize);
$lastpage = ceil(min($count, 1 + QA_MAX_LIMIT_START) / $pagesize);
if (($thispage > 1) || ($lastpage > $thispage)) {
if ($thispage > 1 || $lastpage > $thispage) {
$links = array('label' => qa_lang_html('main/page_label'), 'items' => array());
$keypages[1] = true;
......
......@@ -404,7 +404,7 @@ function qa_default_option($name)
case 'from_email': // heuristic to remove short prefix (e.g. www. or qa.)
$parts = explode('.', @$_SERVER['HTTP_HOST']);
if ((count($parts) > 2) && (strlen($parts[0]) < 5) && !is_numeric($parts[0]))
if (count($parts) > 2 && strlen($parts[0]) < 5 && !is_numeric($parts[0]))
unset($parts[0]);
$value = 'no-reply@' . ((count($parts) > 1) ? implode('.', $parts) : 'example.com');
......
......@@ -802,9 +802,10 @@ function qa_content_prepare($voting = false, $categoryids = null)
} else {
setcookie('qa_noticed', 1, time() + 86400 * 3650, '/', QA_COOKIE_DOMAIN, (bool)ini_get('session.cookie_secure'), true); // don't show first-time notice if a user has logged in
if (qa_opt('show_notice_welcome') && (qa_get_logged_in_flags() & QA_USER_FLAGS_WELCOME_NOTICE))
if (($requestlower != 'confirm') && ($requestlower != 'account')) // let people finish registering in peace
if (qa_opt('show_notice_welcome') && (qa_get_logged_in_flags() & QA_USER_FLAGS_WELCOME_NOTICE)) {
if ($requestlower != 'confirm' && $requestlower != 'account') // let people finish registering in peace
$qa_content['notices'][] = qa_notice_form('welcome', qa_opt('notice_welcome'));
}
}
$qa_content['script_rel'] = array('qa-content/jquery-1.11.3.min.js');
......
......@@ -298,8 +298,9 @@ function qa_comment_create($userid, $handle, $cookieid, $content, $format, $text
qa_db_queuedcount_update();
} else {
if (($question['type'] == 'Q') && (($parent['type'] == 'Q') || ($parent['type'] == 'A'))) // only index if antecedents fully visible
if ($question['type'] == 'Q' && ($parent['type'] == 'Q' || $parent['type'] == 'A')) { // only index if antecedents fully visible
qa_post_index($postid, 'C', $question['postid'], $parent['postid'], null, $content, $format, $text, null, $question['categoryid']);
}
qa_db_points_update_ifuser($userid, 'cposts');
qa_db_ccount_update();
......@@ -308,7 +309,7 @@ function qa_comment_create($userid, $handle, $cookieid, $content, $format, $text
$thread = array();
foreach ($commentsfollows as $comment) {
if (($comment['type'] == 'C') && ($comment['parentid'] == $parent['postid'])) // find just those for this parent, fully visible
if ($comment['type'] == 'C' && $comment['parentid'] == $parent['postid']) // find just those for this parent, fully visible
$thread[] = $comment;
}
......
......@@ -390,7 +390,7 @@ function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookie
if ($comment['type'] == 'C') {
$answer = @$answers[$comment['parentid']];
if ((!isset($answer)) || ($answer['type'] == 'A')) { // don't index comment if it or its parent is hidden
if (!isset($answer) || $answer['type'] == 'A') { // don't index comment if it or its parent is hidden
qa_post_index($comment['postid'], $comment['type'], $oldquestion['postid'], $comment['parentid'], null,
$comment['content'], $comment['format'], qa_viewer_text($comment['content'], $comment['format']), null, $comment['categoryid']);
}
......@@ -630,7 +630,7 @@ function qa_answer_set_content($oldanswer, $content, $format, $text, $notify, $u
$commentsfollows = qa_post_get_answer_commentsfollows($oldanswer['postid']);
foreach ($commentsfollows as $comment) {
if (($comment['basetype'] == 'C') && ($comment['parentid'] == $oldanswer['postid']))
if ($comment['basetype'] == 'C' && $comment['parentid'] == $oldanswer['postid'])
qa_post_unindex($comment['postid']);
}
......@@ -642,7 +642,7 @@ function qa_answer_set_content($oldanswer, $content, $format, $text, $notify, $u
if ($oldanswer['flagcount'])
qa_db_flaggedcount_update();
} elseif (($oldanswer['type'] == 'A') && ($question['type'] == 'Q')) { // don't index if question or answer are hidden/queued
} elseif ($oldanswer['type'] == 'A' && $question['type'] == 'Q') { // don't index if question or answer are hidden/queued
qa_post_index($oldanswer['postid'], 'A', $question['postid'], $oldanswer['parentid'], null, $content, $format, $text, null, $oldanswer['categoryid']);
}
......@@ -711,7 +711,7 @@ function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid,
qa_post_unindex($oldanswer['postid']);
foreach ($commentsfollows as $comment) {
if (($comment['basetype'] == 'C') && ($comment['parentid'] == $oldanswer['postid']))
if ($comment['basetype'] == 'C' && $comment['parentid'] == $oldanswer['postid'])
qa_post_unindex($comment['postid']);
}
......@@ -765,12 +765,12 @@ function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid,
if ($oldanswer['flagcount'])
qa_db_flaggedcount_update();
if (($question['type'] == 'Q') && ($status == QA_POST_STATUS_NORMAL)) { // even if answer visible, don't index if question is hidden or queued
if ($question['type'] == 'Q' && $status == QA_POST_STATUS_NORMAL) { // even if answer visible, don't index if question is hidden or queued
qa_post_index($oldanswer['postid'], 'A', $question['postid'], $oldanswer['parentid'], null, $oldanswer['content'],
$oldanswer['format'], qa_viewer_text($oldanswer['content'], $oldanswer['format']), null, $oldanswer['categoryid']);
foreach ($commentsfollows as $comment) {
if (($comment['type'] == 'C') && ($comment['parentid'] == $oldanswer['postid'])) { // and don't index hidden/queued comments
if ($comment['type'] == 'C' && $comment['parentid'] == $oldanswer['postid']) { // and don't index hidden/queued comments
qa_post_index($comment['postid'], $comment['type'], $question['postid'], $comment['parentid'], null, $comment['content'],
$comment['format'], qa_viewer_text($comment['content'], $comment['format']), null, $comment['categoryid']);
}
......@@ -1028,7 +1028,7 @@ function qa_answer_to_comment($oldanswer, $parentid, $content, $format, $text, $
if ($oldanswer['flagcount'])
qa_db_flaggedcount_update();
} elseif (($oldanswer['type'] == 'A') && ($question['type'] == 'Q') && (($parent['type'] == 'Q') || ($parent['type'] == 'A'))) // only if all fully visible
} elseif ($oldanswer['type'] == 'A' && $question['type'] == 'Q' && ($parent['type'] == 'Q' || $parent['type'] == 'A')) // only if all fully visible
qa_post_index($oldanswer['postid'], 'C', $question['postid'], $parentid, null, $content, $format, $text, null, $oldanswer['categoryid']);
if ($question['selchildid'] == $oldanswer['postid']) { // remove selected answer
......
......@@ -455,7 +455,7 @@ function qa_post_get_question_commentsfollows($questionid)
}
foreach ($achildposts as $postid => $post) {
if (($post['basetype'] == 'Q') || ($post['basetype'] == 'C'))
if ($post['basetype'] == 'Q' || $post['basetype'] == 'C')
$commentsfollows[$postid] = $post;
}
......@@ -486,7 +486,7 @@ function qa_post_get_answer_commentsfollows($answerid)
$childposts = qa_db_single_select(qa_db_full_child_posts_selectspec(null, $answerid));
foreach ($childposts as $postid => $post) {
if (($post['basetype'] == 'Q') || ($post['basetype'] == 'C'))
if ($post['basetype'] == 'Q' || $post['basetype'] == 'C')
$commentsfollows[$postid] = $post;
}
......
......@@ -303,9 +303,9 @@ function qa_recalc_perform_step(&$state)
if ($followonq)
$updatetype = QA_UPDATE_FOLLOWS;
elseif (($post['basetype'] == 'C') && (@$posts[$post['parentid']]['basetype'] == 'Q'))
elseif ($post['basetype'] == 'C' && @$posts[$post['parentid']]['basetype'] == 'Q')
$updatetype = QA_UPDATE_C_FOR_Q;
elseif (($post['basetype'] == 'C') && (@$posts[$post['parentid']]['basetype'] == 'A'))
elseif ($post['basetype'] == 'C' && @$posts[$post['parentid']]['basetype'] == 'A')
$updatetype = QA_UPDATE_C_FOR_A;
else
$updatetype = null;
......@@ -337,9 +337,11 @@ function qa_recalc_perform_step(&$state)
qa_sort_by($comments, 'created');
foreach ($comments as $comment) {
foreach ($keyuserids as $keyuserid => $dummy)
if (($keyuserid != $comment['userid']) && ($keyuserid != @$posts[$parentid]['userid']))
foreach ($keyuserids as $keyuserid => $dummy) {
if ($keyuserid != $comment['userid'] && $keyuserid != @$posts[$parentid]['userid']) {
qa_db_event_create_not_entity($keyuserid, $questionid, $comment['postid'], QA_UPDATE_FOLLOWS, $comment['userid'], $comment['created']);
}
}
if (isset($comment['userid']))
$keyuserids[$comment['userid']] = true;
......
......@@ -97,7 +97,7 @@ function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $o
else
$maxfilesize = qa_get_max_upload_size();
if (($filesize <= 0) || ($filesize > $maxfilesize)) { // if file was too big for PHP, $filesize will be zero
if ($filesize <= 0 || $filesize > $maxfilesize) { // if file was too big for PHP, $filesize will be zero
$result['error'] = qa_lang_sub('main/max_upload_size_x', qa_format_number($maxfilesize / 1048576, 1) . 'MB');
return $result;
}
......@@ -134,7 +134,7 @@ function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $o
$result['format'] = $format;
if ($onlyimage) {
if ((!$isimage) || !is_array($imagesize)) {
if (!$isimage || !is_array($imagesize)) {
$result['error'] = qa_lang_sub('main/image_not_read', 'GIF, JPG, PNG');
return $result;
}
......
......@@ -405,7 +405,7 @@ if (QA_FINAL_EXTERNAL_USERS) {
$sessioncode = trim($sessioncode); // trim to prevent passing in blank values to match uninitiated DB rows
// Try to recover session from the database if PHP session has timed out
if ((!isset($_SESSION['qa_session_userid_' . $suffix])) && (!empty($handle)) && (!empty($sessioncode))) {
if (!isset($_SESSION['qa_session_userid_' . $suffix]) && !empty($handle) && !empty($sessioncode)) {
require_once QA_INCLUDE_DIR . 'db/selects.php';
$userinfo = qa_db_single_select(qa_db_user_account_selectspec($handle, false)); // don't get any pending
......@@ -1282,7 +1282,7 @@ function qa_set_form_security_key()
global $qa_form_key_cookie_set;
if ((!qa_is_logged_in()) && !@$qa_form_key_cookie_set) {
if (!qa_is_logged_in() && !@$qa_form_key_cookie_set) {
$qa_form_key_cookie_set = true;
if (strlen(@$_COOKIE['qa_key']) != QA_FORM_KEY_LENGTH) {
......
......@@ -1001,13 +1001,13 @@ function qa_sanitize_html_hook_tag($element, $attributes = null)
if (!isset($attributes)) // it's a closing tag
return '</' . $element . '>';
if (($element == 'param') && (trim(strtolower(@$attributes['name'])) == 'allowscriptaccess'))
if ($element == 'param' && trim(strtolower(@$attributes['name'])) == 'allowscriptaccess')
$attributes['name'] = 'allowscriptaccess_denied';
if ($element == 'embed')
unset($attributes['allowscriptaccess']);
if (($element == 'a') && isset($attributes['href']) && $qa_sanitize_html_newwindow)
if ($element == 'a' && isset($attributes['href']) && $qa_sanitize_html_newwindow)
$attributes['target'] = '_blank';
$html = '<' . $element;
......@@ -1639,7 +1639,7 @@ function qa_q_path($questionid, $title, $absolute = false, $showtype = null, $sh
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
if ((($showtype == 'Q') || ($showtype == 'A') || ($showtype == 'C')) && isset($showid)) {
if (($showtype == 'Q' || $showtype == 'A' || $showtype == 'C') && isset($showid)) {
$params = array('show' => $showid); // due to pagination
$anchor = qa_anchor($showtype, $showid);
......@@ -1772,7 +1772,7 @@ function qa_retrieve_url($url)
$contents = @file_get_contents($url);
if ((!strlen($contents)) && function_exists('curl_exec')) { // try curl as a backup (if allow_url_fopen not set)
if (!strlen($contents) && function_exists('curl_exec')) { // try curl as a backup (if allow_url_fopen not set)
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
......@@ -1794,7 +1794,7 @@ function qa_opt($name, $value = null)
{
global $qa_options_cache;
if ((!isset($value)) && isset($qa_options_cache[$name]))
if (!isset($value) && isset($qa_options_cache[$name]))
return $qa_options_cache[$name]; // quick shortcut to reduce calls to qa_get_options()
require_once QA_INCLUDE_DIR . 'app/options.php';
......
......@@ -35,6 +35,10 @@ qa_report_process_stage('init_install');
if (!function_exists('qa_install_db_fail_handler')) {
/**
* Handler function for database failures during the installation process
* @param $type
* @param int $errno
* @param string $error
* @param string $query
*/
function qa_install_db_fail_handler($type, $errno=null, $error=null, $query=null)
{
......
......@@ -610,6 +610,8 @@ class qa_html_theme extends qa_html_theme_base
*
* @since Snow 1.4
* @version 1.0
* @param string $addon_class
* @param string $ids
*/
private function qam_search($addon_class = null, $ids = null)
{
......
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