Make WordPress Core

Opened 10 years ago

Closed 9 years ago

#6936 closed defect (bug) (invalid)

upgrade process fails with WP_User_Search class not found error if __autoload defined

Reported by: ithinkihaveacat Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.5.1
Component: Administration Keywords:
Focuses: Cc:


If autoload is defined, the upgrade process fails with a WP_User_Search class not found error. This is because wp-admin/includes/user.php does:

if ( !class_exists('WP_User_Search') ) :
class WP_User_Search {
	var $results;
        // ...

If WP_User_Search doesn't exist and autoload is defined autoload is invoked to define the class, which fails. The fix is to include an optional second argument to class_exists:

if ( !class_exists('WP_User_Search', false) ) :
class WP_User_Search {
	var $results;
        // ...

(A patch is attached.)

Attachments (1)

user.patch (362 bytes) - added by ithinkihaveacat 10 years ago.

Download all attachments as: .zip

Change History (5)

#1 @ithinkihaveacat
10 years ago

  • Cc mjs@… added

#2 @DD32
10 years ago

  • Milestone set to 2.6

Seems like Stupid PHP to me.. Calling the autoload function is fair enough, but surely it should check again to see if the class was loaded before returning..

Anyway, The $autoload parameter for class_exists was introduced with PHP 5.0.0, I'm not sure what warnings are triggered by calling a function with extra arguements(If any indeed..).

#3 @konsty
9 years ago

Any progress on this? Of course once can cure it with something like that:

function __autoload($class_name)
  if ($class_name != 'WP_User_Search')

But it is not elegant...

#4 @jacobsantos
9 years ago

  • Milestone 2.9 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Actually, if you don't want to do that, then you can use SPL autoload functionality and create a separate function that handles this.

This is not a WordPress issue that needs to be address in WordPress. It would be if WordPress used autoload functionality, but it does not.

Note: See TracTickets for help on using tickets.