? Success

User tests: Successful: Unsuccessful:

avatar Harmageddon
Harmageddon
30 Dec 2016

User MaxPowerHamburg reported that after renaming his administrator folder (and changing the JPATH_ADMINISTRATOR constant to point to the new directory), he is no longer able to create new menu items.
I'm aware that renaming the administrator folder is not recommended for various reasons, including problems with updating, extensions and paths stored in the database. But I don't see any reason against this change, because it is according to the usage of path constants all over the CMS.

Summary of Changes

This PR changes two occurrences of JPATH_ROOT . '/administrator' to JPATH_ADMINISTRATOR. For normal environments

Testing Instructions

  1. Rename your administrator folder to something else, e.g. adm.
  2. In includes/defines.php and adm/includes/defines.php, change the following line:
define('JPATH_ADMINISTRATOR', JPATH_ROOT . DIRECTORY_SEPARATOR . 'administrator');

to

define('JPATH_ADMINISTRATOR', JPATH_ROOT . DIRECTORY_SEPARATOR . 'adm');
  1. Login into your renamed administrator center. Navigate to "Menus" - "Some menu" - "Add New Menu Item".
  2. You should see a "Fatal error: Call to a member function xpath() on a non-object...".
  3. Apply this pull request (attention: change the files in your renamed folder, not in the administrator folder!).
  4. Repeat step 3, it should work now.

Unfortunately, the second change (administrator/components/com_contenthistory/models/history.php) can't really be tested, because the legacy JTableContent will be loaded if the other one can't be found. Maybe this can be merged by a maintainer on review?

Documentation Changes Required

None

avatar Harmageddon Harmageddon - open - 30 Dec 2016
avatar Harmageddon Harmageddon - change - 30 Dec 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 30 Dec 2016
Category Administration com_content com_contenthistory com_menus
avatar andrepereiradasilva
andrepereiradasilva - comment - 30 Dec 2016

while this change itself is correct be aware that as it is now there are more places that hardcode /administrator.
egrep -n -R "\/administrator\/" /path/to/joomla/ (in linux) will show a few of those.

avatar Harmageddon
Harmageddon - comment - 30 Dec 2016

@andrepereiradasilva That's right. I fixed the occurrences of JPATH_ROOT . '/administrator' I could find outside of the update files. The hardcoded reference to "administrator" is used in the update mechanism and in various other locations (e.g. in addfieldpath in XML files).

avatar mbabker
mbabker - comment - 30 Dec 2016

Everything in PHP files should be able to use constants consistently and anything that isn't is Doing It Wrong™. As has been explained about a bajillion times, there isn't handling to deal with it in non-PHP files.

avatar wilsonge wilsonge - reference | 7765af7 - 30 Dec 16
avatar wilsonge wilsonge - merge - 30 Dec 2016
avatar wilsonge wilsonge - close - 30 Dec 2016
avatar wilsonge wilsonge - close - 30 Dec 2016
avatar wilsonge wilsonge - merge - 30 Dec 2016
avatar wilsonge wilsonge - change - 30 Dec 2016
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-12-30 13:45:35
Closed_By wilsonge
Labels Added: ?
avatar wilsonge
wilsonge - comment - 30 Dec 2016

Merged on review. Thanks!

Add a Comment

Login with GitHub to post a comment