? ? Pending

User tests: Successful: Unsuccessful:

avatar csthomas
csthomas
29 Nov 2017

Pull Request for Issue #18923

Summary of Changes

  1. Always add prefix /component/[COMPONENT_NAME]/ if menu item component is not equal to query[option].
  2. Optimise code, remove a code that set again $query['Itemid'].
    I removed a way when the build rule can change menu route by changing value in query['Itemid'].
    This example describe old way that I removed.
// Store Itemid in other variable
$itemID    = empty($query['Itemid']) ? null : $query['Itemid'];

$crouter   = $this->getComponentRouter($component);
// Now build rule can change query['Itemid']
$parts     = $crouter->build($query);

// Restore Itemid if deleted
if (empty($query['Itemid']) && $itemID)
{
	$query['Itemid'] = $itemID;
}

// After that we load menu item
$item = empty($query['Itemid']) ? null : $this->menu->getItem($query['Itemid']);

Testing Instructions

See issue and code review.

Expected result

SEF links is build in correct way.

Note:
IMO similar PR also can be applied to J.3.x

avatar csthomas csthomas - open - 29 Nov 2017
avatar csthomas csthomas - change - 29 Nov 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 29 Nov 2017
Category Libraries
avatar infograf768
infograf768 - comment - 30 Nov 2017

Tested this patch, it solves the issue of creating a new account from the module when we do not have a Registration Menu item.

avatar csthomas
csthomas - comment - 30 Nov 2017

Thanks, I will change one more line, replace isset() to empty(), then almost everything will be done, there is still problem with unit tests.

avatar csthomas csthomas - change - 30 Nov 2017
Labels Added: ?
avatar csthomas csthomas - change - 30 Nov 2017
The description was changed
avatar csthomas csthomas - edited - 30 Nov 2017
avatar csthomas csthomas - change - 30 Nov 2017
The description was changed
avatar csthomas csthomas - edited - 30 Nov 2017
avatar csthomas csthomas - edited - 1 Dec 2017
avatar csthomas csthomas - change - 1 Dec 2017
The description was changed
avatar joomdonation
joomdonation - comment - 2 Dec 2017

Could you please explain why you get $item from $query['Itemid'] before component router build process? Look like this change the original logic of the routing

As I understand, the original code give component router a chance to find correct Itemid (logical to me) for the routing, so we should try to get $item after component build process rater than before. So the change like this 4.0-dev...joomdonation:patch-2 seems more safe?

avatar csthomas
csthomas - comment - 2 Dec 2017

Could you please explain why you get $item from $query['Itemid'] before component router build process? Look like this change the original logic of the routing

In general, build URL process is split into 3 stages: (preprocess, build and postprecess).

Itemid is set up in preprocess stage, ex: MenuRules::preprocess()
SiteRouter::buildSefRoute() is called in build stage and calls StandardRules::build().

Maybe you would agree with me that StandardRules::build() or NomenuRules::build() should not change $query[Itemid] to different valid value.

Non SEF process does not call build stage.
IMO allowed option to change Itemid in build stage is wrong.

avatar joomdonation
joomdonation - comment - 2 Dec 2017

Thanks for explanation @csthomas , it is clear to me now (and makes sense, too). I can mark this PR as success but would like to see @Hackwar confirm this change doesn't cause any potential issues?

avatar Bakual Bakual - test_item - 2 Dec 2017 - Tested successfully
avatar Bakual
Bakual - comment - 2 Dec 2017

I have tested this item successfully on d55cd2a

This solves my issues reported in #18952.
Imho this is a very important fix as otherwise we will see issues arise with a lot of sites where there are no specific menuitems for a given component.


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

avatar infograf768 infograf768 - test_item - 3 Dec 2017 - Not tested
avatar infograf768
infograf768 - comment - 3 Dec 2017

I have not tested this item.


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

avatar joomdonation joomdonation - test_item - 3 Dec 2017 - Tested successfully
avatar joomdonation
joomdonation - comment - 3 Dec 2017

I have tested this item successfully on d55cd2a

The PR solves the reported issue. I also did a code review, too


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

avatar franz-wohlkoenig franz-wohlkoenig - change - 3 Dec 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 3 Dec 2017

Ready to Commit after two successful tests.

avatar Anu1601CS Anu1601CS - test_item - 4 Dec 2017 - Tested successfully
avatar Anu1601CS
Anu1601CS - comment - 4 Dec 2017

I have tested this item successfully on d55cd2a

With PR . I have tested this item successfully.


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

avatar Hackwar
Hackwar - comment - 5 Dec 2017

The code change looks good and the logic is correct. I would sign off on this. 😉

avatar joomdonation
joomdonation - comment - 2 Feb 2018

@wilsonge This PR should be merged, please

avatar wilsonge wilsonge - change - 2 Feb 2018
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2018-02-02 01:04:20
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 2 Feb 2018
avatar wilsonge wilsonge - merge - 2 Feb 2018
avatar wilsonge
wilsonge - comment - 2 Feb 2018

Thanks :)

avatar joeforjoomla
joeforjoomla - comment - 4 Mar 2018

This code breaks several components logic out there that rely on the router to find an Itemid #19829

avatar csthomas
csthomas - comment - 5 Mar 2018

@joeforjoomla Yes, this PR breaks it.

When you build a URL you can add your own Itemid to the query, otherwise core rules MenuRules will do it for you based on match to menu items.

Before (3.x) you could re-change Itemid again in SEF build method of your component router.

My purpose was:

  • SEF and non SEF build should return the same Itemid
  • the component router rule build is to build path in component, not to repair menu item id.

Add a Comment

Login with GitHub to post a comment