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

JInstallerAdapterComponent bug fixes related to admin menu build #5499

Merged
merged 7 commits into from
Dec 24, 2014
Merged

JInstallerAdapterComponent bug fixes related to admin menu build #5499

merged 7 commits into from
Dec 24, 2014

Conversation

nikosdion
Copy link
Contributor

As requested by @wilsonge by email

Executive summary

This patch for JInstallerAdapterComponent deals with issues manifesting themselves as "Can't build admin menus".

The following intertwined bug fixes are applied:

  • If building admin menus failed the #__menus table was left broken (inconsistent lft/rgt) because rebuild() never ran against it.
  • Failed installations without rollback (e.g. due to timeout) can leave behind rubbish #__extensions and #__menus entries leading to inability to reinstall the component
  • A failure in _removeAdminMenus –presumably because of the issue above– would make it impossible to install the component.
  • Just do not create the menu if $menuElement not exist (it was a TODO item for as long as I remember developing for Joomla!)
  • The extension ID was passed to _buildAdminMenus but completely ignored!
  • If a submenu already existed with the same parent item the installation would fail. Now we try removing it first, just like we do for the root menu item.

Backwards compatibility

The protected _removeAdminMenus method has a different signature. To the best of my knowledge nobody extends JInstallerAdapterComponent directly, therefore the impact is non-existent.

Translation impact

None

Testing instructions

As I explained to @wislonge the problems only manifest themselves on bad hosting and when several things go wrong. As a result there is no way to do positive tests which reproduce the bugs. These are "blind" fixes. That said, I've been tracking down these issues since 2007 and applying workarounds on my own extensions ever since. I am pretty darn sure that my code DOES fix these issues.

As a result the only possible testing you can do is regression testing. Try applying this patch and install as many different components as you can on your site (but don't try my extensions, especially the pre-release versions, some have experimental fixes which will not work properly and override this patch in any case!). The installation should succeed and the components should be perfectly usable.

Nicholas K. Dionysopoulos added 5 commits December 23, 2014 16:44
Changes:
* Pass only the extension ID, not the entire extension row. After all, only the ID is used!
* Always run rebuild() on the menus table, preventing broken nested sets on this table (now you know why this table breaks all the time)
Changes:
* Type hinting for $table
* There can be more than one root menu items for a single component if the installation previously failed without rollback (e.g. timeout error)
* The extension ID must always be fetched from the #__extensions table, not the old menu items for the same reasons as above
* Just do not create the menu if $menuElement not exist (it was a TODO item for as long as I remember developing for Joomla!)
* Unnecessary code duplication creating the root menu item
* Refactored the code, moving the actual menu item creation in the _createAdminMenuItem method
* If a submenu already existed with the same parent item the installation would fail. Now we try removing it first, just like we do for the root menu item.
If there's a timeout or PHP fatal error during a component's installation there are invalid records left behind in #__extensions and #__menus which prevent further installations. We now detect them and remove them to let the installation proceed.
zero-24 and others added 2 commits December 23, 2014 19:20
Hi @nikosdion

this should make travis happy here: #5499

```
FILE: ...s/build/joomla/joomla-cms/libraries/cms/installer/adapter/component.php
--------------------------------------------------------------------------------
FOUND 8 ERROR(S) AFFECTING 8 LINE(S)
--------------------------------------------------------------------------------
 1141 | ERROR | Tabs must be used to indent lines; spaces are not allowed
 1142 | ERROR | Tabs must be used to indent lines; spaces are not allowed
 1143 | ERROR | Tabs must be used to indent lines; spaces are not allowed
 1255 | ERROR | Tabs must be used to indent lines; spaces are not allowed
 1256 | ERROR | Tabs must be used to indent lines; spaces are not allowed
 1257 | ERROR | Tabs must be used to indent lines; spaces are not allowed
 1258 | ERROR | Tabs must be used to indent lines; spaces are not allowed
 1878 | ERROR | Expected 2 spaces after the longest type
--------------------------------------------------------------------------------
```
@wilsonge
Copy link
Contributor

<3

@wilsonge
Copy link
Contributor

@test Installed a variety of 3rd party extensions (CB 2.0, widgetkit, chronoforms, nonumber extension manager and a custom one of mine) without any issues. 1 more tester needed (@roland-d ?)

@roland-d
Copy link
Contributor

@wilsonge Thanks for the ping. Going to test it now.

@roland-d
Copy link
Contributor

@test: Did a variety of testing with components, modules, plugins, and packages from 3rd parties and custom extensions. All installed and uninstalled as expected.


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

@nikosdion
Copy link
Contributor Author

I guess we can set this RTC... or does it need a PLT discussion first?

@roland-d
Copy link
Contributor

Moving to RTC, we have 2 successful tests.


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

wilsonge added a commit that referenced this pull request Dec 24, 2014
JInstallerAdapterComponent bug fixes related to admin menu build
@wilsonge wilsonge merged commit 87837ed into joomla:staging Dec 24, 2014
@wilsonge
Copy link
Contributor

Merged. Thanks so much for this Nic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants