[wp-trac] [WordPress Trac] #32274: Works faster that use __DIR__ instead of dirname(__FILE__) .

WordPress Trac noreply at wordpress.org
Sat May 28 12:10:36 UTC 2016


#32274: Works faster that use __DIR__ instead of dirname(__FILE__) .
-------------------------+------------------------------
 Reporter:  kmvan        |       Owner:
     Type:  enhancement  |      Status:  closed
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  General      |     Version:
 Severity:  normal       |  Resolution:  maybelater
 Keywords:               |     Focuses:  performance
-------------------------+------------------------------
Changes (by jdgrimes):

 * keywords:  2nd-opinion =>
 * status:  reopened => closed
 * resolution:   => maybelater


Comment:

 Replying to [comment:5 nigro.simone]:
 > Very simple way for support old php version without {{{ __DIR__ }}}(<
 5.3.0) is add in index.php:
 >
 > {{{#!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 the
 don't want to use `dirname( __FILE__ )` in every place.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/32274#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list