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

New view based routing fails with raw links #9950

Closed
joeforjoomla opened this issue Apr 16, 2016 · 12 comments
Closed

New view based routing fails with raw links #9950

joeforjoomla opened this issue Apr 16, 2016 · 12 comments

Comments

@joeforjoomla
Copy link
Contributor

joeforjoomla commented Apr 16, 2016

Steps to reproduce the issue

For components implementing the new routing linked to menu items, all menu items links are broken when executing Joomla with raw URLs or URLs not routed to any menu items such as 'component/contact'

Expected result

Opening a Joomla link such as http://www.domain.com/component/contact, http://www.domain.com/component/tags or using a raw link such as a link to generate a sitemap http://www.mysite.com/index.php?option=com_osmap&view=xml&tmpl=component&id=1
will result in all Joomla menu items links broken if the linked component implements the new view based router.

Actual result

All links are broken, they don't stay the same as when clicking on a menu item having an alias.
Appending a casual alias before the raw link, even if a not existent alias, all links are generated again correctly.
http://www.mysite.com/randomstringalias/index.php?option=com_osmap&view=xml&tmpl=component&id=1

System information (as much as possible)

Testing Joomla 3.6 dev branch

Additional comments

@chrisdavenport
Copy link
Contributor

I can't seem to reproduce this issue. Can you give me the exact steps you took, starting from a fresh install with default sample data, that lead to getting broken links?

@chrisdavenport
Copy link
Contributor

@joomlajoe See #9953

Is that the problem you are reporting here?

@roland-d
Copy link
Contributor

@joomlajoe Is this using the 3.6 branch?

Notifying @Hackwar

@joeforjoomla
Copy link
Contributor Author

joeforjoomla commented Apr 17, 2016

Yes i found the exact line to fix the issue.

It's happening in the JComponentRouterRulesMenu preprocess function.
Code at line 125 set the default Itemid overwriting the one in $query array already present:

    if (!empty($default->id))
    {
        $query['Itemid'] = $default->id;
    }

to fix the issue this should be changed as following:

    if (!empty($default->id) && empty($query['Itemid']))
    {
        $query['Itemid'] = $default->id;
    }

Please notify @Hackwar

To reproduce this it's easy, i just installed a 3.6 branch with few sample data. Navigating menu and observing menu links everything is ok.
Trying to open a link such as http://test36/component/contact, etc and observing menu links you will notice they are broken in most cases, for example always pointing to the home page or: http://test36/en/component/users/?Itemid=101

@brianteeman brianteeman added this to the Joomla 3.7.0 milestone May 10, 2016
@crazynex
Copy link

crazynex commented Jul 9, 2016

Hi In my joomla 3.5.1 error logs I too get the following.
PHP Warning: array_merge(): Argument #2 is not an array in public_html/libraries/cms/router/router.php on line 350
PHP Fatal error: Unsupported operand types in public_html/libraries/cms/router/router.php on line 234
Is the above code a fix for this error and if so where exactly does it go.

@Hackwar
Copy link
Member

Hackwar commented Jul 10, 2016

@crazynex No, this has nothing to do with your issue. That code is not active yet and your issue will have a different source.

@joeforjoomla The code is the same as we have in Joomla right now. The issue looks more like a configuration issue on your end.

@wilsonge
Copy link
Contributor

I can no longer replicate this on the 3.7 branch. On my local copy going to http://localhost/~george/joomla-cms/component/content and http://localhost/~george/joomla-cms/component/tags and both perfectly accessible

I can also access http://localhost/~george/joomla-cms/index.php?option=com_content&view=article&id=1 without issues

I'm going to close this issue. If you can replicate it please feel free to and provide a bit more information!

@joeforjoomla
Copy link
Contributor Author

joeforjoomla commented Sep 11, 2016

I currently tested again but the issue is still there in the 3.7 dev https://developer.joomla.org/nightlies/Joomla_3.7.0-dev-Development-Full_Package.zip
Let me know if i should test another branch.

By the way the problem is not about accessing pages as you say; http://localhost/~george/joomla-cms/component/tags

The problem is that if a page link is not routed to any menu item all links from components using the new router or even not using the new router generated by Joomla menus are broken.

See self explaining screenshots below, accessing normal page link with a routed menu item alias like http://joomla37/en/about you see that the log out menu item has correct link: http://joomla37/en/log-out
broken_links1

Accessing normal page link without a routed menu item alias like http://joomla37/en/component/tags you see that the log out menu item has broken link: http://joomla37/en/component/users/?Itemid=101
broken_links2

Let me know if i should test another branch, also notice that i provided a fix for this issue months ago.

@wilsonge wilsonge reopened this Sep 11, 2016
@wilsonge
Copy link
Contributor

Ahh ok I understand now. Thanks for the screenshots! That helps a lot!

@joeforjoomla
Copy link
Contributor Author

joeforjoomla commented Sep 11, 2016

You are welcome George, happy to help if possible :)
I just tested again everything and i can confirm that the issue is still there!
PS: should be marked as release blocked i think

@joeforjoomla
Copy link
Contributor Author

A couple of other screenshots that my be helpful too, routed page link for xmap/osmap sitemap all links ok:
links ok

Not routed page link, several links go wrong:
links ko

@wilsonge
Copy link
Contributor

OK PR #12020 - this is effectively your code change but slightly further up the file

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

7 participants