Skip to content

Commit

Permalink
Fix fatal error "Call to a member function isMuPlugin() on null"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
YahnisElsts committed Jan 24, 2020
1 parent 8212c52 commit 760225b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Puc/v4p8/Plugin/UpdateChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() ) {
Expand All @@ -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);
}

Expand Down

0 comments on commit 760225b

Please sign in to comment.