? Failure

User tests: Successful: Unsuccessful:

avatar roland-d
roland-d
28 Aug 2017

Pull Request for Issue #9892 .

Just copying what was in the original issue as it is complete and elaborate. Merely making the PR compatible with the new codebase.

Issue

The link attribute in the parent administrator
element of a component XML manifest is currently completely ignored on installation; it isn't used anywhere. Instead the link is built using a value derived from the undocumented, therefore typically not present, element. As there is usually not a value set for this it defaults to using the component's , causing issues if you want to have the component named slightly differently from any desired URLs.

I'm assuming the link attribute should do something on parent menus, as it's included in all the core component manifests, as well as the 3.x MVC Component tutorial and the manifest files docs (where it doesn't state the attribute is for submenu use only).
Summary of Changes

Created a new method, getMenuLinkOption(), in JInstallerAdapter. This is executed in the getElement() method in the same class. If the admin menu element's link attribute is set it returns a filtered string matching all text after 'option='.

If a string is returned it becomes the extension's element attribute, otherwise the element value defaults to the element from the manifest as usual.

Testing Instructions

  1. Download the MVC Component tutorial archive.
  2. In the component's XML manifest file change value of the element to com_helloworlds so it looks like <menu link='index.php?option=com_helloworlds'>Hello World!</menu>
  3. Install the component
  4. Under Components -> Hello World, notice that the link goes to option=com_helloworld
  5. Uninstall the component
  6. Apply the patch
  7. Install the component
  8. Under Components -> Hello World, notice that the link goes to option=com_helloworlds

Additional Comments

I originally started out changing _buildAdminMenus in JInstallerAdapterComponent. The $option variable used to build all the admin menu links is the value of the manifest's element. This isn't set in any XML manifest I've found and the only reference to it in the code is in the JUpdate class where it doesn't seem to do anything. Rather than modifying _buildAdminMenus, it was far neater to create a new method in JInstallerAdapter and set the element to the menu link's option. Setting the element attribute this way seems to make more sense given what it's used for anyway.

The new method maintains compatibility should anyone have used in a manifest. It will also function as normal and default to the element's value if a menu link is not set. If the link attribute's option is changed without a clean install of the component you'll get the same errors you would by changing the component's .
Look for these lines in the XML:

JCE

Currently link="option=com_jce" is completely redundant, it isn't used anywhere. Instead admin menu links are built using:

$data['link'] = 'index.php?option=' . $option;

in the _buildAdminMenus() method in JInstallerAdapterComponent. That value, $option, is initialised like this at the start of the method:

$option = $this->get('element');

This then executes the getElement() method from JInstallerAdapter (which is what I've changed).

In any manifest without tags, which is probably all of them, this line always returns null:

$element = (string) $this->getManifest()->element;

Consequently $element always defaults to the value of , and in turn the value of $data['link'] = 'index.php?option=' . $option; will always be the same as $data['link'] = 'index.php?option=jce, regardless of how the link option is set in the manifest.

If, for any reason, you decided to set link="option=com_jceditor", for example, it wouldn't work - that link attribute is completely pointless at the moment.

avatar joomla-cms-bot joomla-cms-bot - change - 28 Aug 2017
Category Libraries
avatar roland-d roland-d - open - 28 Aug 2017
avatar roland-d roland-d - change - 28 Aug 2017
Status New Pending
avatar alikon alikon - test_item - 29 Aug 2017 - Tested successfully
avatar alikon
alikon - comment - 29 Aug 2017

I have tested this item successfully on ac71286


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

avatar sanderpotjer sanderpotjer - test_item - 31 Aug 2017 - Tested successfully
avatar sanderpotjer
sanderpotjer - comment - 31 Aug 2017

I have tested this item successfully on ac71286


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

avatar franz-wohlkoenig franz-wohlkoenig - change - 1 Sep 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 1 Sep 2017

RTC after two successful tests.

avatar mbabker
mbabker - comment - 1 Sep 2017

If the admin menu element's link attribute is set it returns a filtered string matching all text after 'option='.

Something about this isn't right because it doesn't do anything to account for if someone puts additional query variables in that tag. So by this, it would be possible for the element to be com_content&view=articles.

avatar roland-d
roland-d - comment - 1 Sep 2017

@mbabker

So by this, it would be possible for the element to be com_content&view=articles.

If you do that, the code will ignore and use the default we have now. So using your URL it would be that the link would become view=com_content.

I used this element <menu link='com_helloworlds'>Hello World!</menu> and the URL is ?option=com_helloworld

So I don't see the problem you are seeing. It doesn't work like that when you tested it?

avatar mbabker
mbabker - comment - 1 Sep 2017

Just reading it from a practical perspective. If the link attribute is parsed and it finds index.php?option=com_content&view=articles then the extension element value would be com_content&view=articles (or whatever it ends up as after going through the string filter; point is it does not look like that value would result in com_content being what is returned). There is no validation performed on the attribute's value, https://github.com/joomla/joomla-cms/pull/17749/files#diff-b903237ad7a58b5419ff61fe6cb1126cR420 simply takes all of the text it finds after option= and uses that.

avatar roland-d
roland-d - comment - 1 Sep 2017

Ok, now I see your point. I understood your previous message in a different way, that way is that people would only put com_content&view=articles as the full link.

Testing this with 'index.php?option=com_helloworld&amp;view=hello' it results in ?option=com_helloworldviewhello so that is something that needs fixing. This scenario didn't come up in the original PR. I will check it and fix it.

avatar roland-d roland-d - change - 1 Sep 2017
Labels Added: ?
avatar mbabker mbabker - change - 3 Sep 2017
Status Ready to Commit Pending
avatar roland-d roland-d - change - 10 Mar 2019
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2019-03-10 20:21:33
Closed_By roland-d
avatar roland-d roland-d - close - 10 Mar 2019

Add a Comment

Login with GitHub to post a comment