[wp-trac] [WordPress Trac] #20298: Change requires to require_once
WordPress Trac
wp-trac at lists.automattic.com
Sun Mar 25 23:34:58 UTC 2012
#20298: Change requires to require_once
-------------------------+------------------------------
Reporter: pp3345 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.3.1
Severity: normal | Resolution:
Keywords: |
-------------------------+------------------------------
Comment (by nacin):
Well, one, require_once() is indeed a performance difference. It's not
much, but those few lines end up checking include_path and does a hash
table lookup. The include graph for WordPress is something like 100 files
so it will definitely be worse for performance, even if barely measurable.
Additionally, if we change this, we then have to agree to maintain the use
of require_once always. That kind of commitment (when it doesn't benefit
us) is difficult to agree to or maintain.
More importantly, though, I disagree that require_once is an increase in
code quality. It can hide problems, silly code, and errors; and indicates
to me a decrease in quality, if anything.
> Why take a performance hit when none is needed. If the include files get
moved around, a require_once won't fix that anyway. Always using
require_once calls is just a bad habit as far as I am concerned. There may
be a few common files that are prone to multiple inclusion in a complex
application, but most shouldn't be included multiple times and if you are
including them multiple times you'd probably want to know about it and not
just ignore it the way the _once functions do.
That's directly from Rasmus Lerdorf. Reference:
http://toys.lerdorf.com/archives/34-Flickr-API-Fun.html#c3019.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20298#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list