[wp-trac] [WordPress Trac] #19921: always use require_once for wp-load.php (fixes "ABSPATH defined multiple times")

WordPress Trac wp-trac at lists.automattic.com
Sun Jan 29 18:09:47 UTC 2012


#19921: always use require_once for wp-load.php (fixes "ABSPATH defined multiple
times")
--------------------------+----------------------------------------------
 Reporter:  convissor     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  3.3.1
 Severity:  normal        |   Keywords:  require_once require wp-load.php
--------------------------+----------------------------------------------
 The `wp-load.php` file should always be included via `require_once`.  This
 allows developers to include files when necessary with having to run into
 the "ABSPATH defined multiple times" notice (let alone waste time
 processing the file).

 In trunk, require_once is already used in the majority of cases for `wp-
 load.php`:
     * 24 require_once
     * 8 require
     * 1 include

 This has come up because of a situation in a plugin where it is necessary
 to manually include the `wp-login.php`.  But then `wp-login.php` calls
 `require wp-load.php` and the constant re-declaration notice arises.

 In two cases, the patch changes relative paths (eg `./` to
 `dirname(__FILE__)`) to avoid safe mode problems and improve the ability
 to run files from anywhere(1), which is helpful for testing from the
 command line.

 (1) Paths in PHP are relative to the present working directory, not the
 directory the file is in.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/19921>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list