No Code Attached Yet bug
avatar simbunch
simbunch
27 Dec 2019

Steps to reproduce the issue

1: Enable Joomla SEF.

2: Create a simple system plugin, and inside onAfterRoute add the following code:

function onAfterRoute() {
	$uri = JURI::getInstance();
	$uriparams = JFactory::getApplication()->getRouter()->parse($uri);
            var_dump($uriparams);
    }

Go to any com_users link (eg. /index.php/component/users/registration)

Expected result

Display an array of URL query parameters.

Actual result

Throws an error from JROOT/libraries/src/Router/Router.php:153

System information (as much as possible)

Joomla 4 alpha12 PHP 7.3

Additional comments

The error happens only on links generated by com_users (com_content and my own extension links etc work).

It only happens when its SEF URL is used. eg https://www.domain.com/index.php/component/users/registration?Itemid=101

Accessing the page using non-SEF URL does not trigger the error. eg https://www.domain.com/index.php?option=com_users&view=registration&Itemid=101 works as expected.

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar simbunch simbunch - open - 27 Dec 2019
avatar joomla-cms-bot joomla-cms-bot - change - 27 Dec 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Dec 2019
avatar simbunch simbunch - change - 27 Dec 2019
The description was changed
avatar simbunch simbunch - edited - 27 Dec 2019
avatar simbunch simbunch - change - 27 Dec 2019
The description was changed
avatar simbunch simbunch - edited - 27 Dec 2019
avatar brianteeman
brianteeman - comment - 27 Dec 2019

Throws an error from JROOT/libraries/src/Router/Router.php:153

thats all? it just says error and the line - nothing else?

avatar simbunch
simbunch - comment - 27 Dec 2019

Hi Brian

image

Here is a screenshot of the 404 error thrown.

avatar Quy
Quy - comment - 27 Dec 2019

Please test the nightly builds to see if this is still an issue.
https://developer.joomla.org/nightly-builds.html

avatar simbunch
simbunch - comment - 27 Dec 2019

Hi Quy
Updated to the beta1-dev and the same error occurs. Also tried incognito mode and another browser to make sure it's not a session/cookie issue, same error too.

Really excited beta is next to release!

avatar alikon
alikon - comment - 28 Dec 2019

without much info about the 3dp plugin "parainvite" should be hard to guess

avatar simbunch
simbunch - comment - 28 Dec 2019

Hi Alikon
I stripped out everything in the plugin with just the code in the original post, it's still the same.

avatar HLeithner
HLeithner - comment - 28 Dec 2019

The reason for this is that the parse detects com_content based on Itemid 101 and ignores com_users and registration. is not part of com_content and the error occur...

The Url:
http://example.com/joomla-cms/index.php/component/users/remind?Itemid=101

Ends in:

object(Joomla\CMS\Uri\Uri)#125 (10) {
  ["uri":protected]=>
  string(76) "http://example.com/joomla-cms/index.php/component/users/remind?Itemid=101"
  ["scheme":protected]=>
  string(4) "http"
  ["host":protected]=>
  string(14) "example.com"
  ["port":protected]=>
  NULL
  ["user":protected]=>
  NULL
  ["pass":protected]=>
  NULL
  ["path":protected]=>
  string(6) "remind"
  ["query":protected]=>
  NULL
  ["fragment":protected]=>
  NULL
  ["vars":protected]=>
  array(3) {
    ["option"]=>
    string(11) "com_content"
    ["view"]=>
    string(8) "featured"
    ["Itemid"]=>
    int(101)
  }
}

After processParseRules in Router is called. Maybe @Hackwar can help here?

The Itemid with the menu item is higher rated then the override of the url, not sure if this is expected behavior, I don't think so

avatar HLeithner
HLeithner - comment - 28 Dec 2019

As mentioned the Itemid 101 is per default the menu item for featured articles. You see this in the 'vars' entry of the uri object.

If you create a menu item for com_users this should fix your problem too but not the root of the problem.

avatar simbunch
simbunch - comment - 28 Dec 2019

Hi HLeithner
So sorry I deleted my reply before I saw your reply. I found a link that's actually for com_content > featured, which is the default Home. I unpublished that but it didn't help. The next link on the menu threw the same error.

With regards to your reply, removing the Itemid parameter from the URL didn't help either. The registration link itself does not have a menu item attached to it, it's just using standard Joomla SEF rewrite.

avatar HLeithner
HLeithner - comment - 28 Dec 2019

Ok I hope that @Hackwar can help here.

avatar simbunch
simbunch - comment - 28 Dec 2019

If you create a menu item for com_users this should fix your problem too but not the root of the problem.

Yes you're right, I just tried it and it works. I understand the bug now. Without a menu item attached to the component, the Router overrides it with the Itemid of another menu item and assumes its path.

avatar richard67 richard67 - change - 27 Jan 2020
Status New Confirmed
avatar Hackwar
Hackwar - comment - 13 Jul 2020

Please test this again. I can not replicate this right now.

avatar brianteeman
brianteeman - comment - 9 Apr 2021

Based on comments above and the lack of response for a year I assume this is resolved?

avatar joomdonation
joomdonation - comment - 10 Apr 2021

The issue is still there in today Joomla 4 night build.

avatar Hackwar
Hackwar - comment - 1 Jun 2022

I looked into this again and the issue is, that after the initial parse, the active menu item is set to the default menu item. So now, when parse is called a second time on the component router, it simply looks up the active menu item and thus the default menu item is taken. That again means that the nomenu rule doesn't think it is responsible here and returns without parsing the URL.

Unfortunately there is next to nothing we can do about this. While the application router actually knows that it didn't find a menu item for this URL, the component router never gets this information and without a B/C break, we can't provide this to the component router.

We would have the possibility to throw quite a lot of code at this to get around this, requiring third party devs to update their routers as well if they want to get around this problem. All of this code would have to be deprecated right again as well, because we would have to fix this properly in 5.0 then. It would be a big headache for everyone. I'm against doing this.

For this specific situation here, the solution would actually be far simpler. Instead of parsing the current URL again, just do $uriparams = JFactory::getApplication()->getRouter()->getVars() and you got the result of that call for the current URL.

Long story short: I would vote to close this issue and mark it as "Needs review for 5.0".

avatar brianteeman
brianteeman - comment - 1 Jun 2022

At a minimum it should be documented as a known issue

avatar alexdwalker
alexdwalker - comment - 3 Nov 2022

I have just updated one of my oldest web sites first created in Joomla 1.5 and updated right through to 4. However, everything is working apart from when the Smart Search renders the articles, when I click on them I get the Requested page cannot be found. JROOT/libraries/src/Router/Router.php:153

My other issue if I may post here is in administrator > Joomla Update I get this error message: https://prnt.sc/rZuXhZ7C1vDl
To be so close to updating this site to Joomla 4 is very frustrating and any help would be appreciated. www.adventgroup.org.uk


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

avatar Hackwar Hackwar - change - 19 Feb 2023
Labels Added: No Code Attached Yet bug
Removed: ?
avatar Hackwar Hackwar - labeled - 19 Feb 2023
avatar Hackwar
Hackwar - comment - 14 Mar 2024

Can you check if #42989 fixes this for you?

avatar Hackwar Hackwar - close - 29 Mar 2024
avatar Hackwar
Hackwar - comment - 29 Mar 2024

#43118 is fixing this, so I'm closing the issue.

avatar Hackwar Hackwar - change - 29 Mar 2024
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2024-03-29 10:55:46
Closed_By Hackwar

Add a Comment

Login with GitHub to post a comment