Commit b9ccbef6 by Scott

Fix count() notices on PHP 7.2

Fixes #540
parent 84943773
......@@ -464,7 +464,7 @@ function qa_set_template($template)
* @param array $categoryids
* @return array
*/
function qa_content_prepare($voting = false, $categoryids = null)
function qa_content_prepare($voting = false, $categoryids = array())
{
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
......@@ -480,10 +480,12 @@ function qa_content_prepare($voting = false, $categoryids = null)
$navpages = qa_db_get_pending_result('navpages');
$widgets = qa_db_get_pending_result('widgets');
if (isset($categoryids) && !is_array($categoryids)) // accept old-style parameter
if (!is_array($categoryids)) {
// accept old-style parameter
$categoryids = array($categoryids);
}
$lastcategoryid = count($categoryids) ? end($categoryids) : null;
$lastcategoryid = count($categoryids) > 0 ? end($categoryids) : null;
$charset = 'utf-8';
$language = qa_opt('site_language');
$language = empty($language) ? 'en' : qa_html($language);
......
......@@ -65,7 +65,7 @@ return qa_q_list_page_content(
$countslugs ? $categories[$categoryid]['qcount'] : qa_opt('cache_qcount'), // total count
$sometitle, // title if some questions
$nonetitle, // title if no questions
QA_ALLOW_UNINDEXED_QUERIES ? $categories : null, // categories for navigation
QA_ALLOW_UNINDEXED_QUERIES ? $categories : array(), // categories for navigation
$categoryid, // selected category id
true, // show question counts in category navigation
QA_ALLOW_UNINDEXED_QUERIES ? 'hot/' : null, // prefix for links in category navigation (null if no navigation)
......
......@@ -122,7 +122,7 @@ $qa_content = qa_q_list_page_content(
@$count, // total count
$sometitle, // title if some questions
$nonetitle, // title if no questions
QA_ALLOW_UNINDEXED_QUERIES ? $categories : null, // categories for navigation (null if not shown on this page)
QA_ALLOW_UNINDEXED_QUERIES ? $categories : array(), // categories for navigation (null if not shown on this page)
QA_ALLOW_UNINDEXED_QUERIES ? $categoryid : null, // selected category id (null if not relevant)
false, // show question counts in category navigation
QA_ALLOW_UNINDEXED_QUERIES ? 'unanswered/' : null, // prefix for links in category navigation (null if no navigation)
......
......@@ -208,10 +208,11 @@ class qa_html_theme_base
*/
public function widgets($region, $place)
{
if (count(@$this->content['widgets'][$region][$place])) {
$widgetsHere = isset($this->content['widgets'][$region][$place]) ? $this->content['widgets'][$region][$place] : array();
if (is_array($widgetsHere) && count($widgetsHere) > 0) {
$this->output('<div class="qa-widgets-' . $region . ' qa-widgets-' . $region . '-' . $place . '">');
foreach ($this->content['widgets'][$region][$place] as $module) {
foreach ($widgetsHere as $module) {
$this->output('<div class="qa-widget-' . $region . ' qa-widget-' . $region . '-' . $place . '">');
$module->output_widget($region, $place, $this, $this->template, $this->request, $this->content);
$this->output('</div>');
......@@ -629,8 +630,10 @@ class qa_html_theme_base
(@$navlink['state'] ? (' qa-' . $class . '-' . $navlink['state']) : '') . ' qa-' . $class . '-' . $suffix . '">');
$this->nav_link($navlink, $class);
if (count(@$navlink['subnav']))
$this->nav_list($navlink['subnav'], $class, 1 + $level);
$subnav = isset($navlink['subnav']) ? $navlink['subnav'] : array();
if (is_array($subnav) && count($subnav) > 0) {
$this->nav_list($subnav, $class, 1 + $level);
}
$this->output('</li>');
}
......
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