This repository has been archived by the owner on Nov 26, 2017. It is now read-only.
Joomla CMS [#26863] countMenuChildren has incorrect column reference and generates 1054 error when debug turned on #393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm using countMenuChildren in my template (using Joomla 1.7.0). It seems to work fine except when I turned on error reporting / debug. It gave me the following error message:
JDatabaseMySQL::query: 1054 - Unknown column 'parent' in 'where clause' SQL=SELECT COUNT(*) FROM hc5wg_menu WHERE parent = 101 AND published = 1
The page gives a 500 error and has the following backtrace:
Function Location
1 JSite->render() /.../index.php:49
2 JDocumentHTML->parse() /.../includes/application.php:249
3 JDocumentHTML->_fetchTemplate() /.../libraries/joomla/document/html/html.php:378
4 JDocumentHTML->_loadTemplate() /.../libraries/joomla/document/html/html.php:547
5 require() /.../libraries/joomla/document/html/html.php:488
6 JDocumentHTML->countMenuChildren() /.../templates/hp1/index.php:112
7 JDatabase->loadResult() /.../libraries/joomla/document/html/html.php:455
8 JDatabaseMySQLi->query() /.../libraries/joomla/database/database.php:1008
9 JError::raiseError() /.../libraries/joomla/database/database/mysqli.php:535
10 JError::raise() /.../libraries/joomla/error/error.php:215
Line 112 in my template is where I call $this->countMenuChildren()
I looked in the database and there is not a field called 'parent' in the #__menu table. However, there is a field called "parent_id"
The libraries/joomla/document/html/html.php file on line 499 (line 452 in current library used in Joomla 1.7.0) is:
$where[] = 'parent = ' . $active->id;
but I think it should be:
$where[] = 'parent_id = ' . $active->id;
Whenever I make that change, everything seems to work fine.