? ? Pending

User tests: Successful: Unsuccessful:

avatar Spudley
Spudley
27 Feb 2017

Pull Request for Issue # n/a.

Summary of Changes

This is a simple PR to replace dirname(__FILE__) with __DIR__ across the codebase. I excluded the vendor folder as that's third-party code, but replaced all other instances.

DIR was introduced in PHP 5.3 to reduce the need for convoluted dirname(FILE) constructs.

The change is syntactically identical, but makes the code clearer - it is shorter, easier to read, and easier to understand.

It might also make things slightly quicker, it's one less function to call. But that going to be marginal at best; the real reason for doing this is to make the code easier to work with.

Testing Instructions

This change should have zero impact on the functionality. The new code is functionally identical; just a bit shorter and neater. Testing should just be a case of making sure it still works the same.

Expected result

No change.

Actual result

No change.

Documentation Changes Required

None required.

avatar Spudley Spudley - open - 27 Feb 2017
avatar Spudley Spudley - change - 27 Feb 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 27 Feb 2017
Category Administration com_joomlaupdate Installation External Library Libraries Unit Tests
avatar Spudley Spudley - change - 27 Feb 2017
The description was changed
avatar Spudley Spudley - edited - 27 Feb 2017
avatar mbabker
mbabker - comment - 27 Feb 2017

Please revert the changes in these files.

  • administrator/components/com_joomlaupdate/restore.php is third party code
  • installation/index.php needs to be parseable on PHP 5.2 to display a "your platform isn't supported" message versus a PHP fatal due to the engine being unable to parse the file
avatar Spudley
Spudley - comment - 27 Feb 2017

@mbabker: No problem; I hadn't spotted restore.php as being third-party, but fair enough.
Re installation/index.php -- the occurrence of __DIR__ appears after the 5.3 check and won't prevent it parsing, so I don't believe this one needs to be reverted. (I also note that the main /index.php file which has the same requirement already contains references to __DIR__).

Happy to revert, but can you confirm the latter before I do so? Thanks :)

avatar Spudley Spudley - change - 27 Feb 2017
Labels Added: ? ?
avatar mbabker
mbabker - comment - 27 Feb 2017

PHP will parse the entire file before executing it, it doesn't parse it line by line.

We should've not changed to using __DIR__ in the administrator/index.php or index.php files for the same reason. It's actually really inconsistent there because there's a comment that explicitly says "use define('FOO', 'bar') instead of const FOO = 'bar'".

avatar joomla-cms-bot joomla-cms-bot - change - 27 Feb 2017
Category Administration com_joomlaupdate Installation External Library Libraries Unit Tests Installation External Library Libraries Unit Tests
avatar joomla-cms-bot joomla-cms-bot - change - 27 Feb 2017
Category Installation External Library Libraries Unit Tests External Library Libraries Unit Tests
avatar Spudley
Spudley - comment - 27 Feb 2017

Okay. I've reverted it. :)

avatar mbabker
mbabker - comment - 27 Feb 2017

Looks fine to me.

Whomever merges this, please merge to staging instead of the 3.8 branch. Don't see any reason why it should only apply there.

avatar N6REJ
N6REJ - comment - 27 Feb 2017

@mbabker me'n thomas just undid all that a year or so ago. Why are we bringing it back?

avatar mbabker
mbabker - comment - 27 Feb 2017

Bringing what back?

avatar N6REJ
N6REJ - comment - 27 Feb 2017

if you recall starting around 1.7 we removed DIR from all of J!.. was a HUGE undertaking and didn't go smoothly. Why are we reverting?

avatar mbabker
mbabker - comment - 27 Feb 2017

The DS constant was removed. Joomla can't remove __DIR__, it's a PHP language feature.

avatar N6REJ
N6REJ - comment - 28 Feb 2017

ah, thats right.. ok.. sorry for confusion ?

avatar RonakParmar
RonakParmar - comment - 3 Apr 2017

Not able to apply this PR, please see attached screen-shot.
PHP Version : 5.6.30-7+deb.sury.org~precise+1
Web Server : Apache/2.4.25 (Ubuntu)
screen shot 2017-04-03 at 04 11 36


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

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 3 Apr 2017

Confirming @RonakParmar Comment.

avatar brianteeman
brianteeman - comment - 3 Apr 2017

Looks like @Spudley deleted his repository so the fork is no longer present for you to apply using patchtester

avatar Spudley
Spudley - comment - 3 Apr 2017

@brianteeman Yes I did. Sorry about that. It was a while ago now! However the patch itself is pretty trivial. If you like I'll re-create it. I guess that'll mean submitting a new PR.

avatar Bakual
Bakual - comment - 3 Apr 2017

I'm just going to merge by review.
The only change in a productive file is in libraries/fof/view/view.php, all other changes are in unit tests and since those passed it should be fine.

avatar Bakual Bakual - change - 3 Apr 2017
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-04-03 09:58:39
Closed_By Bakual
avatar Bakual Bakual - close - 3 Apr 2017
avatar Bakual Bakual - merge - 3 Apr 2017
avatar Spudley
Spudley - comment - 3 Apr 2017

Thank you @Bakual. :)

Add a Comment

Login with GitHub to post a comment