User tests: Successful: Unsuccessful:
This is very simple bugfix to check whether menu item query id has been set, at the moment I'm getting this:
Notice: Undefined index: id in ..\components\com_content\router.php on line 69
I can't say how/ when it started to pop up, but there are are lots of other sites out there with same problem (see google)
Similiar checks are performed in other components:
I'm using Featured articles on home page and a VirtualDomains extension,
query variable contains just this:
[option] => com_content
[view] => featured
Labels |
Added:
?
|
Labels |
Added:
?
|
Title |
|
Status | Pending | ⇒ | Information Required |
Can't say for sure what triggers the problem ($query variable without an id key). If you look into the commit, you'll see there's just added a missing check for variable.
Testing instructions:
Notice: Undefined index: id in ..\components\com_content\router.php on line 69
)Status | Information Required | ⇒ | Pending |
Easy | No | ⇒ | Yes |
Category | ⇒ | Front End Router / SEF |
@piotr-cz
About testing instructions: "Set php error log reporting to max" you are talking about joomla debug mode level or server confiuration?
I have tested this item unsuccessfully on fc28dea
Can't reproduce the error in my environment.
I have tested this item unsuccessfully on fc28dea
As I write before I can't reproduce this error
Status | Pending | ⇒ | Needs Review |
Closed as not reproducible
Status | Needs Review | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-04-12 23:29:34 |
Closed_By | ⇒ | wilsonge |
I have seen this notice get printed, (i will need to do some digging to find the exact scenario to reproduce it)
in configurations, that it does occur, usually it goes undetected or ignored, because error_reporting is usually off
in any case the check should have been there in the first place
i don't understand how this can not be defined - and until I understand I'm reluctant to merge code when it may just be masking the symptom of a bigger problem. If you can give me a reproducible case where this comes up I'm more than happy to reconsider :)
hhmm i will spend time to search (sooner or later)
but can anyone here provide proof that it is always set ?
Hello
i don't understand how this can not be defined
please re-open this, ... although the fix proposed here is incomplete and needs to be updated
Because in some cases the router **will try to use and possible even use the active menu item even of it belongs to a different component,
I have replicated it and i also have an explanation of why it is happening:
see this line:
https://github.com/joomla/joomla-cms/blob/staging/components/com_content/router.php#L45
// We need a menu item. Either the one specified in the query, or the current active one if none specified
if (empty($query['Itemid']))
{
$menuItem = $this->menu->getActive();
$menuItemGiven = false;
}
then this line will not exclude active menu even if it belongs to a different component, because it checks "menuItemGiven" variable
https://github.com/joomla/joomla-cms/blob/staging/components/com_content/router.php#L55
Thus if the currently active menu item that can belong to any component
A. if does not have the 'id' variable
B. if 'id' for the menu item is set and it is also the same value as the URL being built
e.g. example for you get PHP notice,
*The active menu item *
stdClass Object
(
[id] => 750
[menutype] => mainmenu
[title] => Home Page
[alias] => home-page
[note] =>
[route] => home-page
[link] => index.php?option=com_flexicontent&view=category&cid=19
[type] => component
[level] => 1
[language] => *
[browserNav] => 0
[access] => 1
...
Is compared the currently URL being built:
Array
(
[option] => com_content
[view] => category
[id] => 240
[lang] => en-GB
)
Re-opened as requested
Status | Closed | ⇒ | New |
Closed_Date | 2016-04-12 23:29:32 | ⇒ | |
Closed_By | wilsonge | ⇒ |
Status | New | ⇒ | Pending |
Thanks
The current implementation of the router
Now about the fix , i think it is in this line:
https://github.com/joomla/joomla-cms/blob/staging/components/com_content/router.php#L55
Replacing:
if ($menuItemGiven && isset($menuItem) && $menuItem->component != 'com_content')
with
if ( !empty($menuItem) && $menuItem->component != 'com_content' )
i am guessing because the isset($menuItem) was not enough, someone had added:
$menuItemGiven && isset($menuItem)
$menuItem = $this->menu->getActive();
...
$menuItem = $this->menu->getItem($query['Itemid']);
have returned a menu item
No, my suggestion is incomplete,
i will post back a proper fix little later, when i will have time to look at it
Proper fix is to replace lines:
https://github.com/joomla/joomla-cms/blob/staging/components/com_content/router.php#L55-L59
with:
// Check again
if ( !empty($menuItem) && $menuItem->component != 'com_content')
{
// Clear active menu item, because later code uses it without checking: $menuItemGiven
$menuItem = null;
$menuItemGiven = false;
unset($query['Itemid']);
}
@piotr-cz Could you update this PR with the provided code changes by @ggppdk? People can re-test the PR and we can move this forward. Thanks
This PR has received new commits.
This PR has received new commits.
Still not clear how to reproduce this issue
@pete-rosseti
thanks for your interest, i described the circumstances above
but a quicker / simpler way to reproduce should be
NOTE:
I have tested this code that i proposed, if you look at it, you see that
in particular this (later) code DOES NOT CHECK 'option'=='com_content':
if (($menuItem instanceof stdClass)
&& $menuItem->query['view'] == $query['view']
&& isset($query['id'])
&& $menuItem->query['id'] == (int) $query['id'])
Because it assumes that menuitem was cleared if it was non-content !!, but current code is bogus and does not do it
Hello,
I can not reproduce this issue. I have followed instructions provided in above comment. I have tested this in Joomla! 3.5.1 clean installation and unpublished home menu (com_content default menu item) and assigned featured contacts as the homepage, then added latest articles module on home page. When I viewed the home page, I did not get any error message (error reporting was set to development and SEF was on).
Please see the screen-shot given below.
it is ok, others have seen this issue,
i have seen it, in several occasions, maybe i have missed a step above or maybe you have
here is another way to reproduce it:
#10721
out of curiosity do the created article SEF links have a menu item ? , can you copy paste one of them here ? thanks
Articles SEF do have menu item link, it takes the menu item of the homepage (in my case it is featured contacts page). I have tested it in my local so I will not be able to paste the URL here.
I have tested it in my local so I will not be able to paste the URL here.
you can paste the URLs here,
because i am not interested to see the 'localhost' domain neither i want to click any link,
you can copy paste the part of the created article SEF URLs that is immediately after "localhost"
Here is the SEF URL : index.php/component/content/article/2-uncategorised/1-test-article1?Itemid=103
What is the type of menu item with id 103 ?
open it and paste its "link" here
As mentioned earlier, Its the home page menu item of type 'featured contacts'.
Is this php version specific ?
Am unable to reproduce on
PHP Version 5.5.28
I was referred over to the issue list from the CMS forum (google group) for this issue. I have been getting this error since upgrading to 3.6.0 on our live site.
The error in the error log is:
PHP Notice: Undefined index: view in /.../public_html/components/com_content/router.php on line 73
The error is being triggered by the following request
journeywithjesus.net/component/content/article?id=434comprehensive-index-of-book-reviews&Itemid=118
The menu 118 is an menu item alias pointing to the home page (screen shot below)
I would be willing to try temporarily installing the patched router files but I am not sure which ones to use (I don't usually use github) - please advise
Changes you can see at:
https://github.com/joomla/joomla-cms/pull/6488/files
Download file from https://raw.githubusercontent.com/piotr-cz/joomla-cms/64f5ac9ed1a1d98f0ab20246bf8a2b55b90bf526/components/com_content/router.php
and copy it to /libraries/cms/router/site.php
[UPDATED]
/components/com_content/router.php
Then test you request as you mentioned at #6488 (comment)
Check also whether urls generated on that page are correct.
I tried the pull request and it didn't work. Left comments here but can't find them so not sure if I clicked 'comment' correctly (new to this). I was able to replicate on local version of site so can reproduce if there are other changes needing testing. Please advise
OK. That appears to work OK with my test case.
I reverted the libraries/cms/router/site.php to its original version
I changed /components/com_content/router.php to the new version
When I went to the URL that had previously created the error condition and it displays without errors now
I won't have time to install this change on the live site until tomorrow.
I noticed that the libraries/cms.../site.php was also changed in your pull request that you originally referred to .. do I need to install that new version also (it appeared to have two areas that were changed). From my simple test it seems that the change to the com_content/router.php file fixed the immediate issue.
I noticed that the libraries/cms.../site.php was also changed in your pull request that you originally referred to .. do I need to install that new version also
No, my PR is for some other case and may be change later.
Category | Front End Router / SEF | ⇒ | Front End Components Router / SEF |
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-07-31 20:48:35 |
Closed_By | ⇒ | roland-d | |
Rel_Number | 0 | ⇒ | 6488 |
Relation Type | ⇒ | Related to |
I am closing this in favor of #6488 as that is now the active pull request. Thank you for your contribution.
Rel_Number | 6488 | ⇒ | 11343 |
@wilsonge Correct, it is supposed to be #11343
comment about being being related, was later corrected to say it is not related
This PR prevents com_content router,
from trying to compare query variables to the query variables of menu item that is of a different component
Status | Closed | ⇒ | Pending |
Closed_Date | 2016-07-31 20:48:40 | ⇒ | |
Closed_By | roland-d | ⇒ | |
Rel_Number | 11343 | ⇒ | 0 |
Relation Type | Related to | ⇒ |
Re-opened as this is not related to the other PR. Thanks for the heads-up.
I have tested this item
Tried multiple approaches before adding the patch to trigger the warning. Also added the Home Alias Menu Item. Dont get this error.
Also added the Home Alias Menu Item. Dont get this error.
sorry we're currently working on joomla from the web development weeks. I didnt know there was a button for "could not reproduce"
i already set error_reporting to all and display errors to on. Original error didnt appear in unmodified joomla staging.
to be honest,
I would rather see an unsuccessful test than see no tests happening
I have not tested this item.
didn't find the arror message @icampus
@schmidtpaddy @wmchris Please test again with the new instructions. Thanks.
I have tested this item
@roland-d wrote a component to test this issue. We could reproduce the issue and applying the patch fixed the issue.
I have tested this item
Tested with the component from @roland-d . Successful tested!
I've tried to rebase but the router file has been rewritten from ground up and it's not possible to resolve conflicts.
We need a confirmation that the issue is still present on latest staging branch and if so, probably address it other way
Legacy routing uses exactly the same code. The file just got moved to https://github.com/joomla/joomla-cms/blob/staging/components/com_content/helpers/route.php so if this is an issue then it just needs the same PR but at the new file
Category | Front End Router / SEF Components | ⇒ | Repository Unit Tests Administration Components SQL Postgresql Router / SEF |
Actually the file has been moved here: https://github.com/joomla/joomla-cms/blob/staging/components/com_content/helpers/legacyrouter.php
I've done rebase, which was effectively a reset to latest commit of staging branch and readded original commit changes to legacyrouter.php.
But the router.php hasn't just moved to legacyrouter.php, there are quite few changes and I think we need at least one more test.
Labels | |||
Easy | Yes | ⇒ | No |
Labels |
Removed:
?
?
|
Category | Router / SEF Components Repository Unit Tests Administration SQL Postgresql | ⇒ | Repository Unit Tests Administration com_admin SQL Postgresql Router / SEF Components |
This PR is very unclear when I look at files changes or commits.
Maybe removing last merging commit and clean merge can help.
git reset --hard HEAD~1
git merge upstream/staging
git push -f
This PR is completely broken and considering that the routers are basically rewritten in 3.7, I'm asking for this PR to be closed.
It wasn't broken back in 2015 when I created it.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-03-08 17:47:31 |
Closed_By | ⇒ | piotr-cz |
I understand and it is not good that this PR rotted around like this.
Yes, the bug is still present as J 3.7 is still using exactly same router.
Please provide some test instructions and describe how to reproduce the actual issue.
This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6488.