[wp-trac] [WordPress Trac] #37707: Change the inclusion of 'plugins.php' to require_once

WordPress Trac noreply at wordpress.org
Thu Aug 18 04:23:35 UTC 2016


#37707: Change the inclusion of 'plugins.php' to require_once
----------------------------+-----------------------
 Reporter:  jorbin          |      Owner:
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  4.7
Component:  Bootstrap/Load  |    Version:
 Severity:  normal          |   Keywords:  has-patch
  Focuses:                  |
----------------------------+-----------------------
 This grew out of a twitter conversation between @andy and I.

 Right now, there are a small number of cases where access to the plugins
 API before the bootstrap process makes sense.  WP-CLI is one of these, and
 [https://twitter.com/skeltoac/status/764621528457580545 when auto-
 prepended files are needed]. Right now, that means directly interacting
 with the plugin global variables. If we switch to `require_once`,

 Common wisdom says that `require` is faster than `require_once`. But
 common wisdom can be wrong, so I [https://travis-ci.org/aaronjorbin
 /require-vs-require_once-vs-function_exists/builds/153096820 tested it].

 The time difference between `require` and `require_once` seems to be about
 0.01 milliseconds.  I think this slight slowdown is worth the flexibility
 that is gained. Local testing with an opcache enabled showed that there is
 essentially no difference with an opcache.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37707>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list