Summary


Seems to me there is a bug in the code for function countMenuChildren() in libraries/joomla/document/html/html.php line 479
Is use this function in my template to adjust the layout, since 2.5.9 it reports an error.
code
$query->getQuery(true);
$query->select('COUNT(*)');
$query->from('#__menu');
$query->where('parent_id = ' . $active->id);
$query->where('published = 1');
$children = $query->loadResult();
should be
$query = $dbo->getQuery(true);
$query->select('COUNT(*)');
$query->from('#__menu');
$query->where('parent_id = ' . $active->id);
$query->where('published = 1');
$dbo->setQuery($query);
$children = $dbo->loadResult();
I think
Opened On:
6 Feb 2013, 7:39 by Murray Hair
Closed On:
8 Oct 2014, 6:50
Status:
Duplicate Report

Filed Under

  • Apache 2.2.x
  • CMS Libraries
  • Firefox Other
  • First
  • MySQL 5.2.x
  • No Platform Implications
  • PHP 5.3.x

Responses

Posted on 22 Apr 2013, 10:30 by Valentin Despa
What is exactly the bug? Can you provide a test scenario?
Posted on 23 Apr 2013, 4:41 by Murray Hair
When I place code $this->countMenuChildren(); in a template I get the following error:

Fatal error: Call to a member function getQuery() on a non-object in /website.com/libraries/joomla/document/html/html.php on line 491

Unfortunately I can't setup a test joomla install at this moment.
Posted on 6 May 2013, 15:16 by Valentin Despa
There is a pull request

https://github.com/joomla/joomla-cms/pull/1109

https://github.com/joomla/joomla-cms/pull/1109.diff

Please test.
Posted on 8 May 2013, 4:22 by Roberto Segura
This query requires a setQuery() to work:

$query = $dbo->getQuery(true);
$query->select('COUNT(*)');
$query->from('#__menu');
$query->where('parent_id = ' . $active->id);
$query->where('published = 1');

$children = $dbo->loadResult();
Posted on 8 May 2013, 14:36 by Valentin Despa
Fixed the problem with setQuery. Thanks for your feedback.
Posted on 20 Aug 2013, 17:29 by Don Cranford

@Test.

Tested. It works for me.

Thanks,

Don
Posted on 8 Oct 2014, 6:50 by George Wilson

Closed as duplicate as fixed in other commits to both staging and 2.5.x