? Success

User tests: Successful: Unsuccessful:

avatar Fedik
Fedik
22 Sep 2014

Problem
Joomla! create a useless menu item for backend, when I create a simple component (with only a site part) that have no backend.

How to test this pull
Make a simple component, and try install it. Create folder com_hello, and put there two files hello.php (empty) and hello.xml

hello.xml content for test the component without backed:

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.3" method="upgrade">
   <name>com_hello</name>
   <author>Your Name</author>
   <authorEmail>your.email@example.com</authorEmail>
   <authorUrl>example.com</authorUrl>
   <creationDate>September 2014</creationDate>
   <license>GNU/GPL</license>
   <version>1.0.0</version>
   <description>Simple Hello component</description>

   <files folder="site">
      <file>hello.php</file>
   </files>

</extension>

hello.xml content for test the component with backed:

<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.3" method="upgrade">
   <name>com_hello</name>
   <author>Your Name</author>
   <authorEmail>your.email@example.com</authorEmail>
   <authorUrl>example.com</authorUrl>
   <creationDate>September 2014</creationDate>
   <license>GNU/GPL</license>
   <version>1.0.0</version>
   <description>Simple Hello component</description>

   <files folder="site">
      <file>hello.php</file>
   </files>

   <administration>
        <files />
    </administration>

</extension>

Pack this to archive and try install.
After installation, check the admin menu Components->com-hello. It should not exist when test with the first XML, and exist for a second.

avatar Fedik Fedik - open - 22 Sep 2014
avatar jissues-bot jissues-bot - change - 22 Sep 2014
Labels Added: ?
avatar Bakual
Bakual - comment - 22 Sep 2014

That's a bit controversial because using the <administration> tag is semantically the wrong tag to use to decide if there should be a menu or not.

We already have the <menu> tag which should be used for that. But that may not be B/C as we even don't use it in some of our core extensions manifests (like in com_content). So simply not creating a menu if the menu tag is not present would not work. But maybe if it is present but empty or with a special attribute it may work.

avatar Fedik
Fedik - comment - 22 Sep 2014

I agree, I thought about remove whole section:

// No menu element was specified, Let's make a generic menu item
else
{
   ....
}

but not sure about b/c, so made test by <administration>

586383e 22 Sep 2014 avatar Fedik cs
avatar Bakual
Bakual - comment - 22 Sep 2014

About a special attribute, if you mean something like

I think it not intuitive, but also not so bad idea :smiley:

I thought about either using <menu /> (empty) or <menu hidden="true" /> or similar. Something more intuitive than do-not-create-menu :smile:

I don't think there are many components which actually don't need a backend menu. Most do at least have some options and thus need a button somewhere to load the settings page. It's also good practice to have some information/license/help page in the backend so people can figure out what this component is supposed to do. I think even if you don't need list and edit views, you likely end up having at least a static page sooner than later.

Thus I don't think it needs to be a "prominent" feature for beginners. But it may be useful for more experienced developers.

avatar betweenbrain
betweenbrain - comment - 22 Sep 2014

As this is likely an edge case, I don't think it would pass the 80/20 rule. That being the case, why not simply use a post-install script to remove the menu entry?

avatar Fedik
Fedik - comment - 22 Sep 2014

I don't think there are many components which actually don't need a backend menu.

you forgot about people who do a lot small component just for specific cases and not for JED,
each time go to phpmyadmin and remove it there, this thing very annoying :cyclone:

As this is likely an edge case, I don't think it would pass the 80/20 rule.

I also have doubt, but I see no reason why Joomla! create a useless menu item and it should be not fixed

...why not simply use a post-install script to remove the menu entry?

Because this script need to write :smile: ... more simple just do not do the things that not requested by manifest file. And it sounds like "fix Joomla! yourself" :smirk:

avatar mbabker
mbabker - comment - 22 Sep 2014

In principle I agree totally that if the <menu> isn't specified then there shouldn't be an entry added. I'd even go so far as to add a sanity check and ensure the <administration> section is actually defined too. But, this is one of those instances where changing a default behavior like this could be an unexpected B/C break, even if it's for the benefit of others. FWIW I've been shipping an extension for 3 years where I've been removing the menu item through a post-install script, and though it feels like a hack (you have to put a menu item back in too during the uninstall routine or Joomla throws errors, at least it did in 2011, because it was trying to just delete the item without checking for its existence), it does get the job done. Even if we added this code today, I'd have to keep shipping my workaround code until I dropped support for every version of Joomla on the market today.

avatar betweenbrain
betweenbrain - comment - 22 Sep 2014

more simple just do not do the things that not requested by manifest file

That I completely agree with. Unfortunately, it seems like the current default behavior is different, as much as we wish it wasn't. At this point, we need to look at this as backwards compatibility issue.

avatar Fedik
Fedik - comment - 23 Sep 2014

@mbabker currently there no error when uninstall without menu, see component.php#L1487-L1522 @since 3.1

otherwise this pull would not work, but it works (at least for me) :wink:

I guess the force menu creation was made for newbie in component programing, or something related to the new component programing, when you start from administrator/com_example/ and add new stuff by needs...

ok, tricky

then what about @Bakual suggestion about <menu hidden="true" />, all agree that it will be good solution? :smile:

avatar Fedik
Fedik - comment - 24 Sep 2014

I changed to @Bakual suggestion,
the test info also updated

avatar zero-24 zero-24 - change - 26 Sep 2014
Category Administration Components
avatar nicksavov nicksavov - change - 16 Oct 2014
Labels Added: ?
avatar HangVTT
HangVTT - comment - 17 Oct 2014
  1. Test with first xml: after add component get: Warning Component Install: The XML file did not contain an administration element Message Error installing component.
  2. Test with second xml: OK: Components->com-hello exists.



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

avatar HangVTT
HangVTT - comment - 17 Oct 2014
  1. Test with first xml: after add component get: Warning Component Install: The XML file did not contain an administration element Message Error installing component.
  2. Test with second xml: OK: Components->com-hello exists.



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

avatar HangVTT HangVTT - test_item - 17 Oct 2014 - Tested unsuccessfully
avatar Fedik
Fedik - comment - 17 Oct 2014

ah, I forgot update the XML example, for testing... after last changes...

I already did update for the testing info, now should be good :smile:

avatar HangVTT
HangVTT - comment - 17 Oct 2014

@Fedik: I just updated XML file and test successfull.

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

avatar HangVTT HangVTT - test_item - 17 Oct 2014 - Tested successfully
avatar lunalars
lunalars - comment - 17 Oct 2014

@test success

backend menuitem is not created if menu is set to hidden="true"

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

avatar lunalars lunalars - test_item - 17 Oct 2014 - Tested successfully
avatar anibalsanchez
anibalsanchez - comment - 17 Oct 2014

@test OK,

To test I crafted a component replacing the administration with


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

avatar lunalars
lunalars - comment - 17 Oct 2014

just noticed: xml examples are different on github and the tracker

for my test i used the one on github containing menu hidden="true"

confused now :-)

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

avatar Fedik
Fedik - comment - 17 Oct 2014

@lunalars the right XML is on github ... on the tracker is old ... you did right test :wink:

avatar brianteeman
brianteeman - comment - 18 Oct 2014

@bakual @mbabker @betweenbrain Have the changes made resolved the issues you raised especially b/c

Setting to Needs Review - no point people testing this any more if its not going to go any further,

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

avatar brianteeman brianteeman - change - 18 Oct 2014
Status Pending Needs Review
avatar Fedik
Fedik - comment - 18 Oct 2014

@brianteeman here no b/c problem anymore, after last commit

avatar brianteeman
brianteeman - comment - 18 Oct 2014

As they were the ones that expressed B/C issues then I think they need to confirm that they have now been resolved.

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

avatar Bakual Bakual - change - 18 Oct 2014
Status Needs Review Ready to Commit
avatar Bakual
Bakual - comment - 18 Oct 2014

It is fine now, yes. Set to RTC.

avatar Bakual Bakual - change - 18 Oct 2014
Labels Added: ?
avatar phproberto phproberto - close - 23 Oct 2014
avatar phproberto phproberto - change - 23 Oct 2014
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2014-10-23 15:57:47
avatar zero-24 zero-24 - change - 14 Oct 2015
Labels Removed: ?

Add a Comment

Login with GitHub to post a comment