From 9d087b7d9c4e040087b14aaba2c171aa81d34603 Mon Sep 17 00:00:00 2001 From: Yahnis Elsts Date: Sun, 30 Dec 2018 13:36:24 +0200 Subject: [PATCH] Add a workaround for realpath() failing to process the mu-plugins path. Probably fixes #251 --- Puc/v4p5/Plugin/Package.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Puc/v4p5/Plugin/Package.php b/Puc/v4p5/Plugin/Package.php index 0296591..60db5af 100644 --- a/Puc/v4p5/Plugin/Package.php +++ b/Puc/v4p5/Plugin/Package.php @@ -160,9 +160,19 @@ if ( !class_exists('Puc_v4p5_Plugin_Package', false) ): static $cachedResult = null; if ( $cachedResult === null ) { + if ( !defined('WPMU_PLUGIN_DIR') || !is_string(WPMU_PLUGIN_DIR) ) { + $cachedResult = false; + return $cachedResult; + } + //Convert both paths to the canonical form before comparison. $muPluginDir = realpath(WPMU_PLUGIN_DIR); $pluginPath = realpath($this->pluginAbsolutePath); + //If realpath() fails, just normalize the syntax instead. + if (($muPluginDir === false) || ($pluginPath === false)) { + $muPluginDir = Puc_v4p5_Factory::normalizePath(WPMU_PLUGIN_DIR); + $pluginPath = Puc_v4p5_Factory::normalizePath($this->pluginAbsolutePath); + } $cachedResult = (strpos($pluginPath, $muPluginDir) === 0); }