WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#32274 closed enhancement (maybelater)

Works faster that use __DIR__ instead of dirname(__FILE__) .

Reported by: kmvan Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: performance Cc:
PR Number:

Description

We have better choice to improve performance.

Why not use __DIR__ instead of dirname(__FILE__) to improve performance? (require PHP5.3+)

I think we needn't to be compatible with PHP5.2, PHP5.2 is out-date and unsafe.

Please, it's time to use PHP5.3 or higher new features.

Change History (11)

#1 @knutsp
5 years ago

  • Resolution set to maybelater
  • Status changed from new to closed
  • Version trunk deleted

As long as WordPress requires PHP version 5.2.4 or greater this will have to wait.

#2 @kmvan
5 years ago

So disappointed :(

#3 @SergeyBiryukov
5 years ago

  • Milestone Awaiting Review deleted

Related: #30334

#4 @ocean90
4 years ago

#36963 was marked as a duplicate.

#5 follow-up: @nigro.simone
4 years ago

Very simple way for support old php version without __DIR__ (< 5.3.0) is add in index.php:

<?php
if( !defined('__DIR__') ){
    define('__DIR__', dirname(__FILE__));
}

and now is possible and safe replace everywhere dirname(__FILE__) with __DIR__

this work without problem (tested my self).

Last edited 4 years ago by nigro.simone (previous) (diff)

#6 @nigro.simone
4 years ago

  • Keywords 2nd-opinion added
  • Resolution maybelater deleted
  • Status changed from closed to reopened

#7 @SergeyBiryukov
4 years ago

  • Milestone set to Awaiting Review

#8 in reply to: ↑ 5 @jdgrimes
4 years ago

  • Keywords 2nd-opinion removed
  • Resolution set to maybelater
  • Status changed from reopened to closed

Replying to nigro.simone:

Very simple way for support old php version without __DIR__ (< 5.3.0) is add in index.php:

<?php
if( !defined('__DIR__') ){
    define('__DIR__', dirname(__FILE__));
}

and now is possible and safe replace everywhere dirname(__FILE__) with __DIR__

this work without problem (tested my self).

This will only work for files in that one directory. __DIR__ won't be magic, and so it is really not any use for us. We can already use ABSPATH or other constants. In fact, that's what we already do. The only place that we really use dirname( __FILE__ ) in core is in files that are entry-points of the application. We use that to include the bootstrap, and then use ABSPATH and other constants after that.

For plugins, the solution is for them to define their own constants if they don't want to use dirname( __FILE__ ) in every place.

Last edited 4 years ago by jdgrimes (previous) (diff)

#9 @nigro.simone
4 years ago

  • Resolution maybelater deleted
  • Status changed from closed to reopened
  • Type changed from enhancement to feature request

ok, this is a "maybelater" when minimal php version of wordpress will be PHP 5.3

Side note: PHP 5.2 is out-date and unsafe.

Last edited 4 years ago by nigro.simone (previous) (diff)

#10 @nigro.simone
4 years ago

  • Resolution set to maybelater
  • Status changed from reopened to closed

#11 @peterwilsoncc
4 years ago

  • Milestone Awaiting Review deleted
  • Type changed from feature request to enhancement
Note: See TracTickets for help on using tickets.