From e41772e52a7954be975ff7ce7df9f941f582a7d1 Mon Sep 17 00:00:00 2001 From: Jack Wilkinson Date: Wed, 22 Jun 2022 15:57:47 +0100 Subject: [PATCH] Added replaced plugins to the normalize map to ensure classloader namespace aliasing detects replacements --- modules/system/classes/PluginManager.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php index a613302385..3581bae167 100644 --- a/modules/system/classes/PluginManager.php +++ b/modules/system/classes/PluginManager.php @@ -181,7 +181,12 @@ public function loadPlugin(string $namespace, string $path): ?PluginBase $replaces = $pluginObj->getReplaces(); if ($replaces) { foreach ($replaces as $replace) { - $this->replacementMap[strtolower($replace)] = $lowerClassId; + $lowerReplace = strtolower($replace); + $this->replacementMap[$lowerReplace] = $lowerClassId; + + if (!isset($this->normalizedMap[$lowerReplace])) { + $this->normalizedMap[$lowerReplace] = $replace; + } } } @@ -745,6 +750,11 @@ protected function detectPluginReplacements(): void protected function registerPluginReplacements(): void { foreach ($this->replacementMap as $target => $replacement) { + list($target, $replacement) = array_map( + fn($plugin) => $this->normalizeIdentifier($plugin), + [$target, $replacement] + ); + // Alias the replaced plugin to the replacing plugin $this->aliasPluginAs($replacement, $target);