Pass `false` as the 2nd argument to `class_exists()` to disable autoloading and to not cause problems for those who define `__autoload()`.

Fixes #20523.

Built from https://develop.svn.wordpress.org/trunk@34348


git-svn-id: http://core.svn.wordpress.org/trunk@34312 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-09-20 03:52:25 +00:00
parent 82709c30d9
commit 84da11d918
25 changed files with 41 additions and 37 deletions

View File

@ -1165,7 +1165,7 @@ function wp_ajax_add_menu_item() {
/** This filter is documented in wp-admin/includes/nav-menu.php */ /** This filter is documented in wp-admin/includes/nav-menu.php */
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] ); $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $_POST['menu'] );
if ( ! class_exists( $walker_class_name ) ) if ( ! class_exists( $walker_class_name, false ) )
wp_die( 0 ); wp_die( 0 );
if ( ! empty( $menu_items ) ) { if ( ! empty( $menu_items ) ) {

View File

@ -316,7 +316,7 @@ function get_nonauthor_user_ids() {
return $wpdb->get_col( $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value = '0'", $level_key) ); 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') ) : if ( ! class_exists( 'WP_User_Search', false ) ) :
/** /**
* WordPress User Search class. * WordPress User Search class.
* *
@ -757,7 +757,7 @@ function wp_tiny_mce( $teeny = false, $settings = false ) {
static $num = 1; static $num = 1;
if ( ! class_exists('_WP_Editors' ) ) if ( ! class_exists( '_WP_Editors', false ) )
require_once( ABSPATH . WPINC . '/class-wp-editor.php' ); require_once( ABSPATH . WPINC . '/class-wp-editor.php' );
$editor_id = 'content' . $num++; $editor_id = 'content' . $num++;

View File

@ -559,7 +559,7 @@ function unzip_file($file, $to) {
* *
* @param bool $ziparchive Whether to use ZipArchive. Default true. * @param bool $ziparchive Whether to use ZipArchive. Default true.
*/ */
if ( class_exists( 'ZipArchive' ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) { if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) {
$result = _unzip_file_ziparchive($file, $to, $needed_dirs); $result = _unzip_file_ziparchive($file, $to, $needed_dirs);
if ( true === $result ) { if ( true === $result ) {
return $result; return $result;
@ -848,7 +848,7 @@ function WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_own
if ( ! $method ) if ( ! $method )
return false; return false;
if ( ! class_exists("WP_Filesystem_$method") ) { if ( ! class_exists( "WP_Filesystem_$method", false ) ) {
/** /**
* Filter the path for a specific filesystem method class file. * Filter the path for a specific filesystem method class file.

View File

@ -2974,7 +2974,7 @@ function wp_read_video_metadata( $file ) {
$metadata = array(); $metadata = array();
if ( ! class_exists( 'getID3' ) ) if ( ! class_exists( 'getID3', false ) )
require( ABSPATH . WPINC . '/ID3/getid3.php' ); require( ABSPATH . WPINC . '/ID3/getid3.php' );
$id3 = new getID3(); $id3 = new getID3();
$data = $id3->analyze( $file ); $data = $id3->analyze( $file );
@ -3029,7 +3029,7 @@ function wp_read_audio_metadata( $file ) {
return false; return false;
$metadata = array(); $metadata = array();
if ( ! class_exists( 'getID3' ) ) if ( ! class_exists( 'getID3', false ) )
require( ABSPATH . WPINC . '/ID3/getid3.php' ); require( ABSPATH . WPINC . '/ID3/getid3.php' );
$id3 = new getID3(); $id3 = new getID3();
$data = $id3->analyze( $file ); $data = $id3->analyze( $file );

View File

@ -454,8 +454,9 @@ function set_screen_options() {
function iis7_rewrite_rule_exists($filename) { function iis7_rewrite_rule_exists($filename) {
if ( ! file_exists($filename) ) if ( ! file_exists($filename) )
return false; return false;
if ( ! class_exists('DOMDocument') ) if ( ! class_exists( 'DOMDocument', false ) ) {
return false; return false;
}
$doc = new DOMDocument(); $doc = new DOMDocument();
if ( $doc->load($filename) === false ) if ( $doc->load($filename) === false )
@ -481,8 +482,9 @@ function iis7_delete_rewrite_rule($filename) {
if ( ! file_exists($filename) ) if ( ! file_exists($filename) )
return true; return true;
if ( ! class_exists('DOMDocument') ) if ( ! class_exists( 'DOMDocument', false ) ) {
return false; return false;
}
$doc = new DOMDocument(); $doc = new DOMDocument();
$doc->preserveWhiteSpace = false; $doc->preserveWhiteSpace = false;
@ -511,8 +513,9 @@ function iis7_delete_rewrite_rule($filename) {
* @return bool * @return bool
*/ */
function iis7_add_rewrite_rule($filename, $rewrite_rule) { function iis7_add_rewrite_rule($filename, $rewrite_rule) {
if ( ! class_exists('DOMDocument') ) if ( ! class_exists( 'DOMDocument', false ) ) {
return false; return false;
}
// If configuration file does not exist then we create one. // If configuration file does not exist then we create one.
if ( ! file_exists($filename) ) { if ( ! file_exists($filename) ) {

View File

@ -875,7 +875,7 @@ function wp_get_nav_menu_to_edit( $menu_id = 0 ) {
*/ */
$walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id );
if ( class_exists( $walker_class_name ) ) if ( class_exists( $walker_class_name, false ) )
$walker = new $walker_class_name; $walker = new $walker_class_name;
else else
return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) ); return new WP_Error( 'menu_walker_not_exist', sprintf( __('The Walker class named <strong>%s</strong> does not exist.'), $walker_class_name ) );

View File

@ -1910,7 +1910,7 @@ function _wp_admin_html_begin() {
* @return WP_Screen Screen object. * @return WP_Screen Screen object.
*/ */
function convert_to_screen( $hook_name ) { function convert_to_screen( $hook_name ) {
if ( ! class_exists( 'WP_Screen' ) ) { if ( ! class_exists( 'WP_Screen', false ) ) {
_doing_it_wrong( 'convert_to_screen(), add_meta_box()', __( "Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead." ), '3.3' ); _doing_it_wrong( 'convert_to_screen(), add_meta_box()', __( "Likely direct inclusion of wp-admin/includes/template.php in order to use add_meta_box(). This is very wrong. Hook the add_meta_box() call into the add_meta_boxes action instead." ), '3.3' );
return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' ); return (object) array( 'id' => '_invalid', 'base' => '_are_belong_to_us' );
} }

View File

@ -37,7 +37,7 @@ function _wp_admin_bar_init() {
* @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'. * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'.
*/ */
$admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' ); $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' );
if ( class_exists( $admin_bar_class ) ) if ( class_exists( $admin_bar_class, false ) )
$wp_admin_bar = new $admin_bar_class; $wp_admin_bar = new $admin_bar_class;
else else
return false; return false;

View File

@ -1,6 +1,6 @@
<?php <?php
if ( !class_exists('SimplePie') ) if ( ! class_exists( 'SimplePie', false ) )
require_once( ABSPATH . WPINC . '/class-simplepie.php' ); require_once( ABSPATH . WPINC . '/class-simplepie.php' );
class WP_Feed_Cache extends SimplePie_Cache { class WP_Feed_Cache extends SimplePie_Cache {

View File

@ -489,7 +489,7 @@ class WP_oEmbed {
* @return object|false * @return object|false
*/ */
private function _parse_xml_body( $response_body ) { private function _parse_xml_body( $response_body ) {
if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument' ) ) if ( ! function_exists( 'simplexml_import_dom' ) || ! class_exists( 'DOMDocument', false ) )
return false; return false;
$dom = new DOMDocument; $dom = new DOMDocument;

View File

@ -1,5 +1,5 @@
<?php <?php
if ( ! class_exists( 'SimplePie' ) ) : if ( ! class_exists( 'SimplePie', false ) ) :
// Load classes we will need. // Load classes we will need.
require ABSPATH . WPINC . '/SimplePie/Misc.php'; require ABSPATH . WPINC . '/SimplePie/Misc.php';

View File

@ -5,7 +5,7 @@
*/ */
_deprecated_file( basename( __FILE__ ), '3.0', WPINC . '/http.php' ); _deprecated_file( basename( __FILE__ ), '3.0', WPINC . '/http.php' );
if ( !class_exists( 'Snoopy' ) ) : if ( ! class_exists( 'Snoopy', false ) ) :
/************************************************* /*************************************************
Snoopy - the PHP net client Snoopy - the PHP net client

View File

@ -48,7 +48,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
public static function test( $args = array() ) { public static function test( $args = array() ) {
// First, test Imagick's extension and classes. // First, test Imagick's extension and classes.
if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick' ) || ! class_exists( 'ImagickPixel' ) ) if ( ! extension_loaded( 'imagick' ) || ! class_exists( 'Imagick', false ) || ! class_exists( 'ImagickPixel', false ) )
return false; return false;
if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) ) if ( version_compare( phpversion( 'imagick' ), '2.2.0', '<' ) )

View File

@ -3690,7 +3690,7 @@ function iis7_supports_permalinks() {
* Lastly we make sure that PHP is running via FastCGI. This is important because if it runs * 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. * via ISAPI then pretty permalinks will not work.
*/ */
$supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( PHP_SAPI == 'cgi-fcgi' ); $supports_permalinks = class_exists( 'DOMDocument', false ) && isset($_SERVER['IIS_UrlRewriteModule']) && ( PHP_SAPI == 'cgi-fcgi' );
} }
/** /**

View File

@ -2580,7 +2580,7 @@ function wp_default_editor() {
* @param array $settings See _WP_Editors::editor(). * @param array $settings See _WP_Editors::editor().
*/ */
function wp_editor( $content, $editor_id, $settings = array() ) { function wp_editor( $content, $editor_id, $settings = array() ) {
if ( ! class_exists( '_WP_Editors' ) ) if ( ! class_exists( '_WP_Editors', false ) )
require( ABSPATH . WPINC . '/class-wp-editor.php' ); require( ABSPATH . WPINC . '/class-wp-editor.php' );
_WP_Editors::editor($content, $editor_id, $settings); _WP_Editors::editor($content, $editor_id, $settings);

View File

@ -178,7 +178,7 @@ endif;
* *
* @link https://wordpress.org/plugins/atom-publishing-protocol/ * @link https://wordpress.org/plugins/atom-publishing-protocol/
*/ */
if ( ! class_exists( 'wp_atom_server' ) ) { if ( ! class_exists( 'wp_atom_server', false ) ) {
class wp_atom_server { class wp_atom_server {
public function __call( $name, $arguments ) { public function __call( $name, $arguments ) {
_deprecated_function( __CLASS__ . '::' . $name, '3.5', 'the Atom Publishing Protocol plugin' ); _deprecated_function( __CLASS__ . '::' . $name, '3.5', 'the Atom Publishing Protocol plugin' );

View File

@ -2387,7 +2387,7 @@ function wp_text_diff( $left_string, $right_string, $args = null ) {
$defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' ); $defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' );
$args = wp_parse_args( $args, $defaults ); $args = wp_parse_args( $args, $defaults );
if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) ) if ( ! class_exists( 'WP_Text_Diff_Renderer_Table', false ) )
require( ABSPATH . WPINC . '/wp-diff.php' ); require( ABSPATH . WPINC . '/wp-diff.php' );
$left_string = normalize_whitespace($left_string); $left_string = normalize_whitespace($left_string);

View File

@ -7,7 +7,7 @@
* @subpackage entry * @subpackage entry
*/ */
if ( !class_exists( 'Translation_Entry' ) ): if ( ! class_exists( 'Translation_Entry', false ) ):
/** /**
* Translation_Entry class encapsulates a translatable string * Translation_Entry class encapsulates a translatable string
*/ */

View File

@ -10,7 +10,7 @@
require_once dirname(__FILE__) . '/translations.php'; require_once dirname(__FILE__) . '/translations.php';
require_once dirname(__FILE__) . '/streams.php'; require_once dirname(__FILE__) . '/streams.php';
if ( !class_exists( 'MO' ) ): if ( ! class_exists( 'MO', false ) ):
class MO extends Gettext_Translations { class MO extends Gettext_Translations {
var $_nplurals = 2; var $_nplurals = 2;

View File

@ -16,7 +16,7 @@ ini_set('auto_detect_line_endings', 1);
/** /**
* Routines for working with PO files * Routines for working with PO files
*/ */
if ( !class_exists( 'PO' ) ): if ( ! class_exists( 'PO', false ) ):
class PO extends Gettext_Translations { class PO extends Gettext_Translations {
var $comments_before_headers = ''; var $comments_before_headers = '';
@ -355,7 +355,7 @@ class PO extends Gettext_Translations {
/** /**
* @staticvar string $last_line * @staticvar string $last_line
* @staticvar boolean $use_last_line * @staticvar boolean $use_last_line
* *
* @param resource $f * @param resource $f
* @param string $action * @param string $action
* @return boolean * @return boolean

View File

@ -8,7 +8,7 @@
* @subpackage streams * @subpackage streams
*/ */
if ( !class_exists( 'POMO_Reader' ) ): if ( ! class_exists( 'POMO_Reader', false ) ):
class POMO_Reader { class POMO_Reader {
var $endian = 'little'; var $endian = 'little';
@ -134,7 +134,7 @@ class POMO_Reader {
} }
endif; endif;
if ( !class_exists( 'POMO_FileReader' ) ): if ( ! class_exists( 'POMO_FileReader', false ) ):
class POMO_FileReader extends POMO_Reader { class POMO_FileReader extends POMO_Reader {
/** /**
@ -204,7 +204,7 @@ class POMO_FileReader extends POMO_Reader {
} }
endif; endif;
if ( !class_exists( 'POMO_StringReader' ) ): if ( ! class_exists( 'POMO_StringReader', false ) ):
/** /**
* Provides file-like methods for manipulating a string instead * Provides file-like methods for manipulating a string instead
* of a physical file. * of a physical file.
@ -267,7 +267,7 @@ class POMO_StringReader extends POMO_Reader {
} }
endif; endif;
if ( !class_exists( 'POMO_CachedFileReader' ) ): if ( ! class_exists( 'POMO_CachedFileReader', false ) ):
/** /**
* Reads the contents of the file in the beginning. * Reads the contents of the file in the beginning.
*/ */
@ -292,7 +292,7 @@ class POMO_CachedFileReader extends POMO_StringReader {
} }
endif; endif;
if ( !class_exists( 'POMO_CachedIntFileReader' ) ): if ( ! class_exists( 'POMO_CachedIntFileReader', false ) ):
/** /**
* Reads the contents of the file in the beginning. * Reads the contents of the file in the beginning.
*/ */

View File

@ -9,7 +9,7 @@
require_once dirname(__FILE__) . '/entry.php'; require_once dirname(__FILE__) . '/entry.php';
if ( !class_exists( 'Translations' ) ): if ( ! class_exists( 'Translations', false ) ):
class Translations { class Translations {
var $entries = array(); var $entries = array();
var $headers = array(); var $headers = array();
@ -272,7 +272,7 @@ class Gettext_Translations extends Translations {
} }
endif; endif;
if ( !class_exists( 'NOOP_Translations' ) ): if ( ! class_exists( 'NOOP_Translations', false ) ):
/** /**
* Provides the same interface as Translations, but doesn't do anything * Provides the same interface as Translations, but doesn't do anything
*/ */

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-34347'; $wp_version = '4.4-alpha-34348';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -2993,10 +2993,11 @@ class wpdb {
*/ */
public function bail( $message, $error_code = '500' ) { public function bail( $message, $error_code = '500' ) {
if ( !$this->show_errors ) { if ( !$this->show_errors ) {
if ( class_exists( 'WP_Error' ) ) if ( class_exists( 'WP_Error', false ) ) {
$this->error = new WP_Error($error_code, $message); $this->error = new WP_Error($error_code, $message);
else } else {
$this->error = $message; $this->error = $message;
}
return false; return false;
} }
wp_die($message); wp_die($message);

View File

@ -8,7 +8,7 @@
* @subpackage Diff * @subpackage Diff
*/ */
if ( !class_exists( 'Text_Diff' ) ) { if ( ! class_exists( 'Text_Diff', false ) ) {
/** Text_Diff class */ /** Text_Diff class */
require( dirname(__FILE__).'/Text/Diff.php' ); require( dirname(__FILE__).'/Text/Diff.php' );
/** Text_Diff_Renderer class */ /** Text_Diff_Renderer class */