Fix fatal error "Call to a member function isMuPlugin() on null"

In certain configurations, PUC could call a method that uses the $package property before calling the parent class constructor that initialises that property. This has now been fixed by moving the parent constructor call a few lines up.

Fixes #335
This commit is contained in:
Yahnis Elsts 2020-01-24 19:05:40 +02:00
parent 8212c5235e
commit 760225bbfe
1 changed files with 2 additions and 2 deletions

View File

@ -56,6 +56,8 @@ if ( !class_exists('Puc_v4p8_Plugin_UpdateChecker', false) ):
}
add_filter($slugCheckFilter, array($this, 'getAbsolutePath'));
parent::__construct($metadataUrl, dirname($this->pluginFile), $slug, $checkPeriod, $optionName);
//Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume
//it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir).
if ( (strpbrk($this->pluginFile, '/\\') === false) && $this->isUnknownMuPlugin() ) {
@ -66,8 +68,6 @@ if ( !class_exists('Puc_v4p8_Plugin_UpdateChecker', false) ):
//Details: https://github.com/YahnisElsts/plugin-update-checker/issues/138#issuecomment-335590964
add_action('uninstall_' . $this->pluginFile, array($this, 'removeHooks'));
parent::__construct($metadataUrl, dirname($this->pluginFile), $slug, $checkPeriod, $optionName);
$this->extraUi = new Puc_v4p8_Plugin_Ui($this);
}