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

[4.0] Joomla 4 Error with Joomla\CMS\Router only for Joomla's registration page #27356

Closed
simbunch opened this issue Dec 27, 2019 · 19 comments
Closed

Comments

@simbunch
Copy link

simbunch commented Dec 27, 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.

@brianteeman
Copy link
Contributor

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

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

@simbunch
Copy link
Author

Hi Brian

image

Here is a screenshot of the 404 error thrown.

@Quy
Copy link
Contributor

Quy commented Dec 27, 2019

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

@simbunch
Copy link
Author

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!

@alikon
Copy link
Contributor

alikon commented Dec 28, 2019

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

@simbunch
Copy link
Author

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

@HLeithner
Copy link
Member

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

@HLeithner
Copy link
Member

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.

@simbunch
Copy link
Author

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.

@HLeithner
Copy link
Member

Ok I hope that @Hackwar can help here.

@simbunch
Copy link
Author

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.

@Hackwar
Copy link
Member

Hackwar commented Jul 13, 2020

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

@brianteeman
Copy link
Contributor

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

@joomdonation
Copy link
Contributor

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

@Hackwar
Copy link
Member

Hackwar commented Jun 1, 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".

@brianteeman
Copy link
Contributor

At a minimum it should be documented as a known issue

@alexdwalker
Copy link

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.

@Hackwar Hackwar added the bug label Feb 19, 2023
@Hackwar
Copy link
Member

Hackwar commented Mar 14, 2024

Can you check if #42989 fixes this for you?

@Hackwar
Copy link
Member

Hackwar commented Mar 29, 2024

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

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

9 participants