[wp-trac] [WordPress Trac] #13436: Wordpress class_exists() conflicts with __autoload() and php_auto_prepend
WordPress Trac
wp-trac at lists.automattic.com
Mon Oct 25 08:57:19 UTC 2010
#13436: Wordpress class_exists() conflicts with __autoload() and php_auto_prepend
----------------------------------------------------+-----------------------
Reporter: galbus | Owner:
Type: enhancement | Status: reopened
Priority: normal | Milestone:
Component: General | Version: 3.1
Severity: minor | Resolution:
Keywords: autoload class_exists php_auto_prepend |
----------------------------------------------------+-----------------------
Changes (by tychay):
* status: closed => reopened
* version: 3.0 => 3.1
* resolution: invalid =>
Comment:
Now that WordPress 3.2 will be dropping PHP 4 support, it's time we added
this patch back in for 3.2.
Here is the patchfile to be applied…
diff -crB b.orig/wp-admin/includes/class-wp-list-table.php b/wp-
admin/includes/class-wp-list-table.php
*** b.orig/wp-admin/includes/class-wp-list-table.php 2010-10-25
08:39:30.000000000 +0000
--- b/wp-admin/includes/class-wp-list-table.php 2010-10-25
08:34:40.000000000 +0000
***************
*** 831,837 ****
require_list_table( $class );
! if ( class_exists( $class ) )
return new $class;
return false;
}
--- 831,837 ----
require_list_table( $class );
! if ( class_exists( $class, false ) )
return new $class;
return false;
}
***************
*** 860,863 ****
return false;
}
! ?>
\ No newline at end of file
--- 860,863 ----
return false;
}
! ?>
diff -crB b.orig/wp-admin/includes/deprecated.php b/wp-
admin/includes/deprecated.php
*** b.orig/wp-admin/includes/deprecated.php 2010-10-25
08:39:30.000000000 +0000
--- b/wp-admin/includes/deprecated.php 2010-10-25 08:32:49.000000000
+0000
***************
*** 288,294 ****
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM
$wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
}
! if ( !class_exists('WP_User_Search') ) :
/**
* WordPress User Search class.
*
--- 288,294 ----
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM
$wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) );
}
! if ( !class_exists('WP_User_Search',false) ) :
/**
* WordPress User Search class.
*
diff -crB b.orig/wp-admin/includes/file.php b/wp-admin/includes/file.php
*** b.orig/wp-admin/includes/file.php 2010-10-25 08:39:30.000000000
+0000
--- b/wp-admin/includes/file.php 2010-10-25 08:31:58.000000000
+0000
***************
*** 552,558 ****
}
}
! if ( class_exists('ZipArchive') &&
apply_filters('unzip_file_use_ziparchive', true ) ) {
$result = _unzip_file_ziparchive($file, $to,
$needed_dirs);
if ( true === $result ) {
return $result;
--- 552,558 ----
}
}
! if ( class_exists('ZipArchive',false) &&
apply_filters('unzip_file_use_ziparchive', true ) ) {
$result = _unzip_file_ziparchive($file, $to,
$needed_dirs);
if ( true === $result ) {
return $result;
***************
*** 781,787 ****
if ( ! $method )
return false;
! if ( ! class_exists("WP_Filesystem_$method") ) {
$abstraction_file =
apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes
/class-wp-filesystem-' . $method . '.php', $method);
if ( ! file_exists($abstraction_file) )
return;
--- 781,787 ----
if ( ! $method )
return false;
! if ( ! class_exists("WP_Filesystem_$method",false) ) {
$abstraction_file =
apply_filters('filesystem_method_file', ABSPATH . 'wp-admin/includes
/class-wp-filesystem-' . $method . '.php', $method);
if ( ! file_exists($abstraction_file) )
return;
diff -crB b.orig/wp-admin/includes/misc.php b/wp-admin/includes/misc.php
*** b.orig/wp-admin/includes/misc.php 2010-10-25 08:39:30.000000000
+0000
--- b/wp-admin/includes/misc.php 2010-10-25 08:29:20.000000000
+0000
***************
*** 397,403 ****
* Lastly we make sure that PHP is running via FastCGI.
This is important because if it runs
* via ISAPI then pretty permalinks will not work.
*/
! $supports_permalinks = class_exists('DOMDocument') &&
isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi'
);
}
return apply_filters('iis7_supports_permalinks',
$supports_permalinks);
--- 397,403 ----
* Lastly we make sure that PHP is running via FastCGI.
This is important because if it runs
* via ISAPI then pretty permalinks will not work.
*/
! $supports_permalinks = class_exists('DOMDocument', false)
&& isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-
fcgi' );
}
return apply_filters('iis7_supports_permalinks',
$supports_permalinks);
***************
*** 414,420 ****
function iis7_rewrite_rule_exists($filename) {
if ( ! file_exists($filename) )
return false;
! if ( ! class_exists('DOMDocument') )
return false;
$doc = new DOMDocument();
--- 414,420 ----
function iis7_rewrite_rule_exists($filename) {
if ( ! file_exists($filename) )
return false;
! if ( ! class_exists('DOMDocument', false) )
return false;
$doc = new DOMDocument();
***************
*** 441,447 ****
if ( ! file_exists($filename) )
return true;
! if ( ! class_exists('DOMDocument') )
return false;
$doc = new DOMDocument();
--- 441,447 ----
if ( ! file_exists($filename) )
return true;
! if ( ! class_exists('DOMDocument', false) )
return false;
$doc = new DOMDocument();
***************
*** 471,477 ****
* @return bool
*/
function iis7_add_rewrite_rule($filename, $rewrite_rule) {
! if ( ! class_exists('DOMDocument') )
return false;
// If configuration file does not exist then we create one.
--- 471,477 ----
* @return bool
*/
function iis7_add_rewrite_rule($filename, $rewrite_rule) {
! if ( ! class_exists('DOMDocument',false) )
return false;
// If configuration file does not exist then we create one.
diff -crB b.orig/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-
menu.php
*** b.orig/wp-admin/includes/nav-menu.php 2010-10-25
08:39:30.000000000 +0000
--- b/wp-admin/includes/nav-menu.php 2010-10-25 08:32:22.000000000
+0000
***************
*** 1068,1074 ****
$walker_class_name = apply_filters(
'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
! if ( class_exists( $walker_class_name ) )
$walker = new $walker_class_name;
else
return new WP_Error( 'menu_walker_not_exist',
sprintf( __('The Walker class named <strong>%s</strong> does not exist.'),
$walker_class_name ) );
--- 1068,1074 ----
$walker_class_name = apply_filters(
'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
! if ( class_exists( $walker_class_name, false ) )
$walker = new $walker_class_name;
else
return new WP_Error( 'menu_walker_not_exist',
sprintf( __('The Walker class named <strong>%s</strong> does not exist.'),
$walker_class_name ) );
diff -crB b.orig/wp-content/plugins/akismet/akismet.php b/wp-
content/plugins/akismet/akismet.php
*** b.orig/wp-content/plugins/akismet/akismet.php 2010-10-25
08:39:46.000000000 +0000
--- b/wp-content/plugins/akismet/akismet.php 2010-10-25
08:33:11.000000000 +0000
***************
*** 420,426 ****
function akismet_get_user_roles($user_id ) {
$roles = false;
! if ( !class_exists('WP_User') )
return false;
if ( $user_id > 0 ) {
--- 420,426 ----
function akismet_get_user_roles($user_id ) {
$roles = false;
! if ( !class_exists('WP_User', false) )
return false;
if ( $user_id > 0 ) {
diff -crB b.orig/wp-includes/class-feed.php b/wp-includes/class-feed.php
*** b.orig/wp-includes/class-feed.php 2010-10-25 08:38:21.000000000
+0000
--- b/wp-includes/class-feed.php 2010-10-25 08:24:11.000000000
+0000
***************
*** 1,6 ****
<?php
! if ( !class_exists('SimplePie') )
require_once (ABSPATH . WPINC . '/class-simplepie.php');
class WP_Feed_Cache extends SimplePie_Cache {
--- 1,6 ----
<?php
! if ( !class_exists('SimplePie',false) )
require_once (ABSPATH . WPINC . '/class-simplepie.php');
class WP_Feed_Cache extends SimplePie_Cache {
***************
*** 100,103 ****
}
}
}
! }
\ No newline at end of file
--- 100,103 ----
}
}
}
! }
diff -crB b.orig/wp-includes/class-json.php b/wp-includes/class-json.php
*** b.orig/wp-includes/class-json.php 2010-10-25 08:38:44.000000000
+0000
--- b/wp-includes/class-json.php 2010-10-25 08:31:07.000000000
+0000
***************
*** 1,5 ****
<?php
! if ( !class_exists( 'Services_JSON' ) ) :
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
--- 1,5 ----
<?php
! if ( !class_exists( 'Services_JSON', false ) ) :
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
***************
*** 822,828 ****
*/
function isError($data, $code = null)
{
! if (class_exists('pear')) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) ==
'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
--- 822,828 ----
*/
function isError($data, $code = null)
{
! if (class_exists('pear', false)) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) ==
'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
***************
*** 833,839 ****
}
}
! if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
--- 833,839 ----
}
}
! if (class_exists('PEAR_Error',false)) {
class Services_JSON_Error extends PEAR_Error
{
diff -crB b.orig/wp-includes/class-simplepie.php b/wp-includes/class-
simplepie.php
*** b.orig/wp-includes/class-simplepie.php 2010-10-25
08:38:44.000000000 +0000
--- b/wp-includes/class-simplepie.php 2010-10-25 08:30:40.000000000
+0000
***************
*** 6447,6453 ****
$this->title = $title;
$this->type = $type;
$this->width = $width;
! if (class_exists('idna_convert'))
{
$idn =& new idna_convert;
$parsed = SimplePie_Misc::parse_url($link);
--- 6447,6453 ----
$this->title = $title;
$this->type = $type;
$this->width = $width;
! if (class_exists('idna_convert', false))
{
$idn =& new idna_convert;
$parsed = SimplePie_Misc::parse_url($link);
***************
*** 7645,7651 ****
function SimplePie_File($url, $timeout = 10, $redirects = 5,
$headers = null, $useragent = null, $force_fsockopen = false)
{
! if (class_exists('idna_convert'))
{
$idn =& new idna_convert;
$parsed = SimplePie_Misc::parse_url($url);
--- 7645,7651 ----
function SimplePie_File($url, $timeout = 10, $redirects = 5,
$headers = null, $useragent = null, $force_fsockopen = false)
{
! if (class_exists('idna_convert', false))
{
$idn =& new idna_convert;
$parsed = SimplePie_Misc::parse_url($url);
***************
*** 10797,10805 ****
}
elseif (is_string($class1) && is_string($class2))
{
! if (class_exists($class1))
{
! if (class_exists($class2))
{
$class2 = strtolower($class2);
while ($class1 =
strtolower(get_parent_class($class1)))
--- 10797,10805 ----
}
elseif (is_string($class1) && is_string($class2))
{
! if (class_exists($class1, false))
{
! if (class_exists($class2, false))
{
$class2 = strtolower($class2);
while ($class1 =
strtolower(get_parent_class($class1)))
diff -crB b.orig/wp-includes/class-snoopy.php b/wp-includes/class-
snoopy.php
*** b.orig/wp-includes/class-snoopy.php 2010-10-25 08:38:44.000000000
+0000
--- b/wp-includes/class-snoopy.php 2010-10-25 08:25:25.000000000
+0000
***************
*** 5,11 ****
*/
_deprecated_file( basename( __FILE__ ), '3.0', WPINC . '/http.php' );
! if ( !class_exists( 'Snoopy' ) ) :
/*************************************************
Snoopy - the PHP net client
--- 5,11 ----
*/
_deprecated_file( basename( __FILE__ ), '3.0', WPINC . '/http.php' );
! if ( !class_exists( 'Snoopy', false ) ) :
/*************************************************
Snoopy - the PHP net client
diff -crB b.orig/wp-includes/formatting.php b/wp-includes/formatting.php
*** b.orig/wp-includes/formatting.php 2010-10-25 08:38:44.000000000
+0000
--- b/wp-includes/formatting.php 2010-10-25 08:28:26.000000000
+0000
***************
*** 1578,1584 ****
function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {
preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})
([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
$tz = get_option('timezone_string');
! if( class_exists('DateTime') && $tz ) {
//PHP5
date_default_timezone_set( $tz );
$datetime = new DateTime( $string );
--- 1578,1584 ----
function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {
preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})
([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
$tz = get_option('timezone_string');
! if( class_exists('DateTime', false) && $tz ) {
//PHP5
date_default_timezone_set( $tz );
$datetime = new DateTime( $string );
diff -crB b.orig/wp-includes/pluggable.php b/wp-includes/pluggable.php
*** b.orig/wp-includes/pluggable.php 2010-10-25 08:38:44.000000000
+0000
--- b/wp-includes/pluggable.php 2010-10-25 08:34:34.000000000 +0000
***************
*** 6,12 ****
* @package WordPress
*/
! if ( !function_exists('wp_set_current_user') ) :
/**
* Changes the current user by ID or name.
*
--- 6,12 ----
* @package WordPress
*/
! if ( !function_exists( 'wp_set_current_user' ) ) :
/**
* Changes the current user by ID or name.
*
***************
*** 1713,1719 ****
$defaults = array( 'title' => '', 'title_left' => '',
'title_right' => '' );
$args = wp_parse_args( $args, $defaults );
! if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) )
require( ABSPATH . WPINC . '/wp-diff.php' );
$left_string = normalize_whitespace($left_string);
--- 1713,1719 ----
$defaults = array( 'title' => '', 'title_left' => '',
'title_right' => '' );
$args = wp_parse_args( $args, $defaults );
! if ( !class_exists( 'WP_Text_Diff_Renderer_Table', false ) )
require( ABSPATH . WPINC . '/wp-diff.php' );
$left_string = normalize_whitespace($left_string);
diff -crB b.orig/wp-includes/pomo/entry.php b/wp-includes/pomo/entry.php
*** b.orig/wp-includes/pomo/entry.php 2010-10-25 08:39:02.000000000
+0000
--- b/wp-includes/pomo/entry.php 2010-10-25 08:27:13.000000000
+0000
***************
*** 7,13 ****
* @subpackage entry
*/
! if ( !class_exists( 'Translation_Entry' ) ):
/**
* Translation_Entry class encapsulates a translatable string
*/
--- 7,13 ----
* @subpackage entry
*/
! if ( !class_exists( 'Translation_Entry', false ) ):
/**
* Translation_Entry class encapsulates a translatable string
*/
***************
*** 66,69 ****
return is_null($this->context)? $this->singular :
$this->context.chr(4).$this->singular;
}
}
! endif;
\ No newline at end of file
--- 66,69 ----
return is_null($this->context)? $this->singular :
$this->context.chr(4).$this->singular;
}
}
! endif;
diff -crB b.orig/wp-includes/pomo/mo.php b/wp-includes/pomo/mo.php
*** b.orig/wp-includes/pomo/mo.php 2010-10-25 08:39:02.000000000
+0000
--- b/wp-includes/pomo/mo.php 2010-10-25 08:27:48.000000000 +0000
***************
*** 10,16 ****
require_once dirname(__FILE__) . '/translations.php';
require_once dirname(__FILE__) . '/streams.php';
! if ( !class_exists( 'MO' ) ):
class MO extends Gettext_Translations {
var $_nplurals = 2;
--- 10,16 ----
require_once dirname(__FILE__) . '/translations.php';
require_once dirname(__FILE__) . '/streams.php';
! if ( !class_exists( 'MO', false ) ):
class MO extends Gettext_Translations {
var $_nplurals = 2;
***************
*** 228,231 ****
return $this->_nplurals;
}
}
! endif;
\ No newline at end of file
--- 228,231 ----
return $this->_nplurals;
}
}
! endif;
diff -crB b.orig/wp-includes/pomo/po.php b/wp-includes/pomo/po.php
*** b.orig/wp-includes/pomo/po.php 2010-10-25 08:39:02.000000000
+0000
--- b/wp-includes/pomo/po.php 2010-10-25 08:26:58.000000000 +0000
***************
*** 16,22 ****
/**
* Routines for working with PO files
*/
! if ( !class_exists( 'PO' ) ):
class PO extends Gettext_Translations {
--- 16,22 ----
/**
* Routines for working with PO files
*/
! if ( !class_exists( 'PO', false ) ):
class PO extends Gettext_Translations {
diff -crB b.orig/wp-includes/pomo/streams.php b/wp-
includes/pomo/streams.php
*** b.orig/wp-includes/pomo/streams.php 2010-10-25 08:39:02.000000000
+0000
--- b/wp-includes/pomo/streams.php 2010-10-25 08:30:06.000000000
+0000
***************
*** 8,14 ****
* @subpackage streams
*/
! if ( !class_exists( 'POMO_Reader' ) ):
class POMO_Reader {
var $endian = 'little';
--- 8,14 ----
* @subpackage streams
*/
! if ( !class_exists( 'POMO_Reader', false ) ):
class POMO_Reader {
var $endian = 'little';
***************
*** 102,108 ****
}
endif;
! if ( !class_exists( 'POMO_FileReader' ) ):
class POMO_FileReader extends POMO_Reader {
function POMO_FileReader($filename) {
parent::POMO_Reader();
--- 102,108 ----
}
endif;
! if ( !class_exists( 'POMO_FileReader', false ) ):
class POMO_FileReader extends POMO_Reader {
function POMO_FileReader($filename) {
parent::POMO_Reader();
***************
*** 142,148 ****
}
endif;
! if ( !class_exists( 'POMO_StringReader' ) ):
/**
* Provides file-like methods for manipulating a string instead
* of a physical file.
--- 142,148 ----
}
endif;
! if ( !class_exists( 'POMO_StringReader', false ) ):
/**
* Provides file-like methods for manipulating a string instead
* of a physical file.
***************
*** 182,188 ****
}
endif;
! if ( !class_exists( 'POMO_CachedFileReader' ) ):
/**
* Reads the contents of the file in the beginning.
*/
--- 182,188 ----
}
endif;
! if ( !class_exists( 'POMO_CachedFileReader', false ) ):
/**
* Reads the contents of the file in the beginning.
*/
***************
*** 197,203 ****
}
endif;
! if ( !class_exists( 'POMO_CachedIntFileReader' ) ):
/**
* Reads the contents of the file in the beginning.
*/
--- 197,203 ----
}
endif;
! if ( !class_exists( 'POMO_CachedIntFileReader', false ) ):
/**
* Reads the contents of the file in the beginning.
*/
***************
*** 206,209 ****
parent::POMO_CachedFileReader($filename);
}
}
! endif;
\ No newline at end of file
--- 206,209 ----
parent::POMO_CachedFileReader($filename);
}
}
! endif;
diff -crB b.orig/wp-includes/pomo/translations.php b/wp-
includes/pomo/translations.php
*** b.orig/wp-includes/pomo/translations.php 2010-10-25
08:39:02.000000000 +0000
--- b/wp-includes/pomo/translations.php 2010-10-25 08:33:55.000000000
+0000
***************
*** 9,15 ****
require_once dirname(__FILE__) . '/entry.php';
! if ( !class_exists( 'Translations' ) ):
class Translations {
var $entries = array();
var $headers = array();
--- 9,15 ----
require_once dirname(__FILE__) . '/entry.php';
! if ( !class_exists( 'Translations', false ) ):
class Translations {
var $entries = array();
var $headers = array();
***************
*** 205,211 ****
}
endif;
! if ( !class_exists( 'NOOP_Translations' ) ):
/**
* Provides the same interface as Translations, but doesn't do anything
*/
--- 205,211 ----
}
endif;
! if ( !class_exists( 'NOOP_Translations', false ) ):
/**
* Provides the same interface as Translations, but doesn't do anything
*/
diff -crB b.orig/wp-includes/wp-db.php b/wp-includes/wp-db.php
*** b.orig/wp-includes/wp-db.php 2010-10-25 08:38:44.000000000
+0000
--- b/wp-includes/wp-db.php 2010-10-25 08:25:47.000000000 +0000
***************
*** 1466,1472 ****
*/
function bail( $message, $error_code = '500' ) {
if ( !$this->show_errors ) {
! if ( class_exists( 'WP_Error' ) )
$this->error = new WP_Error($error_code,
$message);
else
$this->error = $message;
--- 1466,1472 ----
*/
function bail( $message, $error_code = '500' ) {
if ( !$this->show_errors ) {
! if ( class_exists( 'WP_Error', false ) )
$this->error = new WP_Error($error_code,
$message);
else
$this->error = $message;
diff -crB b.orig/wp-includes/wp-diff.php b/wp-includes/wp-diff.php
*** b.orig/wp-includes/wp-diff.php 2010-10-25 08:38:44.000000000
+0000
--- b/wp-includes/wp-diff.php 2010-10-25 08:24:59.000000000 +0000
***************
*** 8,14 ****
* @subpackage Diff
*/
! if ( !class_exists( 'Text_Diff' ) ) {
/** Text_Diff class */
require( dirname(__FILE__).'/Text/Diff.php' );
/** Text_Diff_Renderer class */
--- 8,14 ----
* @subpackage Diff
*/
! if ( !class_exists( 'Text_Diff', false ) ) {
/** Text_Diff class */
require( dirname(__FILE__).'/Text/Diff.php' );
/** Text_Diff_Renderer class */
--
Ticket URL: <http://core.trac.wordpress.org/ticket/13436#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list