User tests: Successful: Unsuccessful:
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.
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.
<menu link='index.php?option=com_helloworlds'>Hello World!</menu>
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.
Category | ⇒ | Libraries |
Status | New | ⇒ | Pending |
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC after two successful tests.
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
.
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?
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.
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&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.
Labels |
Added:
?
|
Status | Ready to Commit | ⇒ | Pending |
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-03-10 20:21:33 |
Closed_By | ⇒ | roland-d |
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.