[wp-trac] [WordPress Trac] #17092: use dirname(__file__).'/file.php' instead of './file' for includes

WordPress Trac wp-trac at lists.automattic.com
Mon Apr 11 00:51:34 UTC 2011


#17092: use dirname(__file__).'/file.php' instead of './file' for includes
-----------------------------------+------------------------------
 Reporter:  ketwaroo               |       Owner:
     Type:  enhancement            |      Status:  new
 Priority:  normal                 |   Milestone:  Awaiting Review
Component:  General                |     Version:  3.1.1
 Severity:  minor                  |  Resolution:
 Keywords:  has-patch 2nd-opinion  |
-----------------------------------+------------------------------

Comment (by sivel):

 We absolutely should not be doing {{{dirname( __FILE__ )}}} for every
 include, include_once, require, require_once.

 My tests show that if you do it for the roughly 200 places that !WordPress
 uses ./ that it increases memory usage by 0.087MB and increases execution
 time by 0.000830888748169 seconds.

 These figures seem small, but as core grows, and added on top of other
 things these changes only add to inefficiency.

 If we were to do this at all we need to start utilizing ABSPATH, that we
 use for most of the other includes, especially for files within wp-
 includes.

 In general I am -1 for this, but if we do it, we should rely on already in
 use file path constants from core, and not add new vars/constants or run
 dirname for every include/require.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17092#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list