Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notice: Undefined index: id in ... /components/com_content/helpers/legacyrouter.php on line 97 since Joomla 3.7 #15823

Closed
Vednier opened this issue May 5, 2017 · 9 comments

Comments

@Vednier
Copy link

Vednier commented May 5, 2017

Steps to reproduce the issue

Install or update Joomla! to version 3.7

Expected result

Everything is fine

Actual result

A lot of Notice: Undefined index: id in ... /components/com_content/helpers/legacyrouter.php on line 97 strings in server ErrorLog
If Notice frontend reporting is not disabled they fill site pages as well, like here - http://www.degtyarsk.ru/component/content/featured.html?start=180

System information (as much as possible)

Ubuntu 16.04, Apache 2.4.18, php 7.0.15, MySQL 5.7.18
Personally i use Flexicontent 3.1.1 but i still have this problem

Additional comments

I made some search over internet and it looks that this problem is fairly common - https://duckduckgo.com/?q=com_content%2Fhelpers%2Flegacyrouter.php+on+line+97&t=midori&ia=web
All sites showing this problem have README.txt with Joomla 3.7 version. They dont seem to use Flexi so i think problem within Joomla itself.

@Vednier
Copy link
Author

Vednier commented May 5, 2017

Example of problem screen shot 2017-05-05 at 00 28 18


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

@ggppdk
Copy link
Contributor

ggppdk commented May 5, 2017

The bug is totally unrelated to FLEXIcontent

It is a known joomla bug,
and it is not new to J3.7 it existed before, just it occured in a different file (the code producing it was moved to another file)

The com_content (legacy) router under some cases (the view variable matches, etc) tries to "examine" menu items that belong to other components !!

In the end these menu items are not selected but in the middle of the code they are examined as if they are com_content menu items
... and you get these notices

Quick solution: disable error reporting in global config you do not need / should not enable it in a live site

See a long discussion here
#6488

A bug that should have been fixed when that PR was still good
Still a simpler / easy fix is possible, with no risk for break (just for the sake of not changing the broken code) by using an isset statement on the id index of the menu

@ggppdk
Copy link
Contributor

ggppdk commented May 5, 2017

And to make it clear, it is always not a harmless bug, if a menu item of different component is found that has a matching number in the id then it will be selected, to be used for creating a com_content URL using a menu item of different component

@piotr-cz
Copy link
Contributor

piotr-cz commented May 5, 2017

The original patch is here: 64f5ac9 just the file is called now legacyrouter.php

@Vednier to check if that fixes the issue you may try to apply patch manually

@Vednier
Copy link
Author

Vednier commented May 5, 2017

@piotr-cz - yes, this little fix stop notices from appearing in ErrorLog. Thanks.


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

@brianteeman
Copy link
Contributor

Closed as there is a PR for testing

@guidedwebsitedesign
Copy link

I accidentally caused this error to display on my own site when I copied the url of an existing page on my site and used it in a menu item of type URL. I published the menu item and I removed the symptom.

@impressionestudio
Copy link

I use Joomla 3.8.3 and I have the same problem. The problem appeared when I created many menu items of the type "Menu Item Alias" that point to other menu items of the type "Articles » Single Article".

I managed to fix the problem by changing the line 95 in "components\com_content\helpers\legacyrouter.php" from:

if ($menuItem !== null
&& $menuItem->query['view'] == $query['view']
&& isset($menuItem->query['id'], $query['id'])
&& $menuItem->query['id'] == (int) $query['id'])

to:

if ($menuItem !== null
&& isset($menuItem->query['view'])
&& $menuItem->query['view'] == $query['view']
&& isset($menuItem->query['id'], $query['id'])
&& $menuItem->query['id'] == (int) $query['id'])

Actually I added the line:
&& isset($menuItem->query['view'])

It seems that they forgot to check the existence of the variable $menuItem->query['view'].


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

@Quy
Copy link
Contributor

Quy commented Jan 27, 2018

@impressionestudio There is a closed PR #18757 to fix this. Please provide exact steps/instructions on how to reproduce it in v3.8.3 so that it can be tested/merged. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants