#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: |
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
@
10 years ago
- Resolution set to maybelater
- Status changed from new to closed
- Version trunk deleted
#5
follow-up:
↓ 8
@
9 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).
#6
@
9 years ago
- Keywords 2nd-opinion added
- Resolution maybelater deleted
- Status changed from closed to reopened
#8
in reply to:
↑ 5
@
9 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.
As long as WordPress requires PHP version 5.2.4 or greater this will have to wait.