From 760225bbfefd7c01969a4cc480b4448613752d85 Mon Sep 17 00:00:00 2001 From: Yahnis Elsts Date: Fri, 24 Jan 2020 19:05:40 +0200 Subject: [PATCH] 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 --- Puc/v4p8/Plugin/UpdateChecker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Puc/v4p8/Plugin/UpdateChecker.php b/Puc/v4p8/Plugin/UpdateChecker.php index 49d01ef1..85b5cf7f 100644 --- a/Puc/v4p8/Plugin/UpdateChecker.php +++ b/Puc/v4p8/Plugin/UpdateChecker.php @@ -56,6 +56,8 @@ public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod } 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 @@ public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod //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); }