?
avatar tgv604
tgv604
24 Mar 2017

Steps to reproduce the issue

I'm not too sure actually how to reproduce, but the bug is pretty obvious. In my case search bots were hitting a non-existing link /2016-09-27-03-40-18/32-about/aboutus and getting Error 500 instead of 404, filling the error log with entries like this:

PHP Catchable fatal error: Argument 1 passed to Joomla\Utilities\ArrayHelper::sortObjects() must be of the type array, boolean given, called in /home/site/public_html/components/com_content/models/category.php on line 462 and defined in /home/site/public_html/libraries/vendor/joomla/utilities/src/ArrayHelper.php on line 486

Expected result

HTTP Error 404 "Category not found"

Actual result

HTTP Error 500 and above error_log entry

System information (as much as possible)

Joomla v3.6.5, PHP 5.4.45

Additional comments

in the getCategory() line 382 if a category is not found then $this->_children = false; down the track, in getChildren() line 456 there's a condition if (count($this->_children)) which returns 1 and causes the sorting block to execute and fail.

The simple solution is to fix the condition to be if ($this->_children), a bit smarter would be if (count($this->_children) > 1)

Reference: http://php.net/manual/en/function.count.php

Returns the number of elements in array_or_countable. If the parameter is not an array or not an object with implemented Countable interface, 1 will be returned.

avatar tgv604 tgv604 - open - 24 Mar 2017
avatar joomla-cms-bot joomla-cms-bot - labeled - 24 Mar 2017
avatar zero-24
zero-24 - comment - 24 Mar 2017

Hi,

can you send your changes as pull request against staging than?

avatar tgv604
tgv604 - comment - 28 Mar 2017

Not sure how, is there an instruction?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/14873.

avatar brianteeman
brianteeman - comment - 29 Mar 2017

Closing as we have a Pr #14982

avatar brianteeman brianteeman - close - 29 Mar 2017
avatar brianteeman brianteeman - change - 29 Mar 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-03-29 08:27:51
Closed_By brianteeman

Add a Comment

Login with GitHub to post a comment