Hopefully fixed a fatal error related to Debug Bar
Apparently, upgrading a plugin that uses PUC 4.9 to a version that uses PUC 4.10 may trigger two fatal errors, one of which happens inside the Debug Bar extension. Cause is unclear and the errors are not reproduced, but I suspect it has to do with PUC trying to set up a Debug Bar panel after the currently active PUC version has already been replaced. This patch should fix that.
This commit is contained in:
parent
08a2836c88
commit
8c4a998c63
|
|
@ -142,6 +142,15 @@ if ( !class_exists('Puc_v4p9_DebugBar_Extension', false) ):
|
||||||
@ini_set('display_errors', 'On');
|
@ini_set('display_errors', 'On');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove hooks that were added by this extension.
|
||||||
|
*/
|
||||||
|
public function removeHooks() {
|
||||||
|
remove_filter('debug_bar_panels', array($this, 'addDebugBarPanel'));
|
||||||
|
remove_action('debug_bar_enqueue_scripts', array($this, 'enqueuePanelDependencies'));
|
||||||
|
remove_action('wp_ajax_puc_v4_debug_check_now', array($this, 'ajaxCheckNow'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filePath
|
* @param string $filePath
|
||||||
* @return string
|
* @return string
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,11 @@ if ( !class_exists('Puc_v4p9_UpdateChecker', false) ):
|
||||||
*/
|
*/
|
||||||
protected $cachedMetadataHost = 0;
|
protected $cachedMetadataHost = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Puc_v4p9_DebugBar_Extension|null
|
||||||
|
*/
|
||||||
|
protected $debugBarExtension = null;
|
||||||
|
|
||||||
public function __construct($metadataUrl, $directoryName, $slug = null, $checkPeriod = 12, $optionName = '') {
|
public function __construct($metadataUrl, $directoryName, $slug = null, $checkPeriod = 12, $optionName = '') {
|
||||||
$this->debugMode = (bool)(constant('WP_DEBUG'));
|
$this->debugMode = (bool)(constant('WP_DEBUG'));
|
||||||
$this->metadataUrl = $metadataUrl;
|
$this->metadataUrl = $metadataUrl;
|
||||||
|
|
@ -168,6 +173,10 @@ if ( !class_exists('Puc_v4p9_UpdateChecker', false) ):
|
||||||
if ( $this->scheduler ) {
|
if ( $this->scheduler ) {
|
||||||
$this->scheduler->removeHooks();
|
$this->scheduler->removeHooks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $this->debugBarExtension ) {
|
||||||
|
$this->debugBarExtension->removeHooks();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -925,7 +934,7 @@ if ( !class_exists('Puc_v4p9_UpdateChecker', false) ):
|
||||||
*/
|
*/
|
||||||
public function maybeInitDebugBar() {
|
public function maybeInitDebugBar() {
|
||||||
if ( class_exists('Debug_Bar', false) && file_exists(dirname(__FILE__) . '/DebugBar') ) {
|
if ( class_exists('Debug_Bar', false) && file_exists(dirname(__FILE__) . '/DebugBar') ) {
|
||||||
$this->createDebugBarExtension();
|
$this->debugBarExtension = $this->createDebugBarExtension();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue