[wp-trac] [WordPress Trac] #21612: wp-settings loads plugins before pluggable.php is included

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 16 19:00:52 UTC 2012


#21612: wp-settings loads plugins before pluggable.php is included
--------------------------+-----------------------------
 Reporter:  kingjeffrey   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  3.4.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 When manually initializing WordPress (like in a page that handles AJAX
 requests) to access all WordPress functions, it is typical to begin the
 file with:

 `
         define('WP_USE_THEMES', FALSE);
         require($_SERVER['DOCUMENT_ROOT'] . '/wp-blog-header.php');
 `

 However, if a plugin calls the `get_userdata()` function, the page will
 deliver this fatal error:

 `
         Fatal error: Call to undefined function get_userdata() in
 [...]/wp-includes/user.php on line 1402
 `

 The "Maintenance" plugin is an example of one that causes this issue.

 When the plugin is loaded in `wp-settings.php` line 198, it calls the
 `get_userdata()` function. But the `get_userdata()` function is not
 defined until `wp-includes/pluggable.php` is included on line 202 of `wp-
 settings`.

 So this issue is not limited to calling `get_userdata()`, but any function
 defined in `wp-includes/pluggable.php`.

 A simple fix to this, assuming `wp-includes/pluggable.php` does not depend
 on the plugins being loaded (which it very may well), is to swap the order
 of loading in `wp-settings.php`

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


More information about the wp-trac mailing list