From 317a45dc45a47ff5a591bd505819d614370cac8a Mon Sep 17 00:00:00 2001 From: Yahnis Elsts Date: Wed, 17 Jun 2015 12:30:05 +0300 Subject: [PATCH] Prevent class_exists() from calling autoloaders. The update checker uses class_exists in several ways: - As a guard clause around `class Whatever` definitions. This ensures we don't try to define a class that has already been loaded by a different plugin. In this case, autoloading is not necessary because we already know how to load the class. Also, we *want to* load our version of that class if possible - the version that gets loaded by somebody else's autoloader might be different and incompatible. - As a guard clause before `require` statements that include a class. This is conceptually the same as the previous example. - To enable optional features if Debug Bar is active. The latest compatible version of Debug Bar doesn't use autoloading, so it would again be unnecessary in this case. --- debug-bar-panel.php | 2 +- debug-bar-plugin.php | 4 ++-- github-checker.php | 6 +++--- plugin-update-checker.php | 16 ++++++++-------- vendor/readme-parser.php | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/debug-bar-panel.php b/debug-bar-panel.php index 35b56cd..f379163 100644 --- a/debug-bar-panel.php +++ b/debug-bar-panel.php @@ -1,6 +1,6 @@ updateChecker); } return $panels; diff --git a/github-checker.php b/github-checker.php index 62f9acd..720c631 100644 --- a/github-checker.php +++ b/github-checker.php @@ -1,6 +1,6 @@ debugBarPlugin = new PucDebugBarPlugin($this); } @@ -854,7 +854,7 @@ class PluginUpdateChecker_2_0 { endif; -if ( !class_exists('PluginInfo_2_0') ): +if ( !class_exists('PluginInfo_2_0', false) ): /** * A container class for holding and transforming various plugin metadata. @@ -984,7 +984,7 @@ class PluginInfo_2_0 { endif; -if ( !class_exists('PluginUpdate_2_0') ): +if ( !class_exists('PluginUpdate_2_0', false) ): /** * A simple container class for holding information about an available update. @@ -1100,7 +1100,7 @@ class PluginUpdate_2_0 { endif; -if ( !class_exists('PucFactory') ): +if ( !class_exists('PucFactory', false) ): /** * A factory that builds instances of other classes from this library. @@ -1201,14 +1201,14 @@ PucFactory::addVersion('PucGitHubChecker', 'PucGitHubChecker_2_0', '2.0'); * Create non-versioned variants of the update checker classes. This allows for backwards * compatibility with versions that did not use a factory, and it simplifies doc-comments. */ -if ( !class_exists('PluginUpdateChecker') ) { +if ( !class_exists('PluginUpdateChecker', false) ) { class PluginUpdateChecker extends PluginUpdateChecker_2_0 { } } -if ( !class_exists('PluginUpdate') ) { +if ( !class_exists('PluginUpdate', false) ) { class PluginUpdate extends PluginUpdate_2_0 {} } -if ( !class_exists('PluginInfo') ) { +if ( !class_exists('PluginInfo', false) ) { class PluginInfo extends PluginInfo_2_0 {} } diff --git a/vendor/readme-parser.php b/vendor/readme-parser.php index bdcd358..5e3c9ce 100644 --- a/vendor/readme-parser.php +++ b/vendor/readme-parser.php @@ -237,7 +237,7 @@ Class PucReadmeParser { $text = call_user_func( array( __CLASS__, 'code_trick' ), $text, $markdown ); // A better parser than Markdown's for: backticks -> CODE if ( $markdown ) { // Parse markdown. - if ( !class_exists('Parsedown') ) { + if ( !class_exists('Parsedown', false) ) { require_once(dirname(__FILE__) . '/Parsedown.php'); } $instance = Parsedown::instance();