diff --git a/modules/system/classes/PluginManager.php b/modules/system/classes/PluginManager.php
index 50e6977828..b38f90cd2d 100644
--- a/modules/system/classes/PluginManager.php
+++ b/modules/system/classes/PluginManager.php
@@ -50,6 +50,11 @@ class PluginManager
*/
protected $replacementMap = [];
+ /**
+ * @var array A map of plugins that are currently replaced [Original.Plugin => Replacement.Plugin]
+ */
+ protected $activeReplacementMap = [];
+
/**
* @var bool Flag to indicate that all plugins have had the register() method called by registerAll() being called on this class.
*/
@@ -686,6 +691,19 @@ public function getReplacementMap()
return $this->replacementMap;
}
+ /**
+ * Returns the actively replaced plugins defined in $this->activeReplacementMap
+ * @param string $pluginIdentifier Plugin code/namespace
+ * @return array|null
+ */
+ public function getActiveReplacementMap(string $pluginIdentifier = null)
+ {
+ if (!$pluginIdentifier) {
+ return $this->activeReplacementMap;
+ }
+ return $this->activeReplacementMap[$pluginIdentifier] ?? null;
+ }
+
/**
* Evaluates and initializes the plugin replacements defined in $this->replacementMap
*
@@ -710,6 +728,8 @@ public function registerReplacedPlugins()
$this->aliasPluginAs($replacement, $target);
$this->disablePlugin($target);
$this->enablePlugin($replacement);
+ // Register this plugin as actively replaced
+ $this->activeReplacementMap[$target] = $replacement;
} else {
$this->disablePlugin($replacement);
$this->enablePlugin($target);
diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php
index 830f95cf6d..eb5916b8c2 100644
--- a/modules/system/classes/UpdateManager.php
+++ b/modules/system/classes/UpdateManager.php
@@ -186,9 +186,11 @@ public function update()
// Set replacement warning messages
foreach ($this->pluginManager->getReplacementMap() as $alias => $plugin) {
- $this->addMessage($plugin, Lang::get('system::lang.updates.update_warnings_plugin_replace_cli', [
+ if ($this->pluginManager->getActiveReplacementMap($alias)) {
+ $this->addMessage($plugin, Lang::get('system::lang.updates.update_warnings_plugin_replace_cli', [
'alias' => '' . $alias . ''
- ]));
+ ]));
+ }
}
// Print messages returned by migrations / seeders
diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php
index 765873dc2a..0314171bb0 100644
--- a/modules/system/controllers/Updates.php
+++ b/modules/system/controllers/Updates.php
@@ -247,10 +247,12 @@ protected function getWarnings()
$replacementMap = PluginManager::instance()->getReplacementMap();
foreach ($replacementMap as $alias => $plugin) {
- $warnings[] = Lang::get('system::lang.updates.update_warnings_plugin_replace', [
- 'plugin' => '' . $plugin . '',
- 'alias' => '' . $alias . ''
- ]);
+ if (PluginManager::instance()->getActiveReplacementMap($alias)) {
+ $warnings[] = Lang::get('system::lang.updates.update_warnings_plugin_replace', [
+ 'plugin' => '' . $plugin . '',
+ 'alias' => '' . $alias . ''
+ ]);
+ }
}
return $warnings;
diff --git a/tests/unit/system/classes/PluginManagerTest.php b/tests/unit/system/classes/PluginManagerTest.php
index 8197f0deff..8fe3a02a33 100644
--- a/tests/unit/system/classes/PluginManagerTest.php
+++ b/tests/unit/system/classes/PluginManagerTest.php
@@ -280,4 +280,14 @@ public function testReplaceVersion()
$this->assertTrue($replacementPlugin->canReplacePlugin('Winter.Original', '1.0'));
$this->assertFalse($replacementPlugin->canReplacePlugin('Winter.Original', '2.0.1'));
}
+
+ public function testActiveReplacementMap()
+ {
+ $map = $this->manager->getActiveReplacementMap();
+ $this->assertArrayHasKey('Winter.Original', $map);
+ $this->assertEquals('Winter.Replacement', $map['Winter.Original']);
+
+ $this->assertEquals('Winter.Replacement', $this->manager->getActiveReplacementMap('Winter.Original'));
+ $this->assertNull($this->manager->getActiveReplacementMap('Winter.InvalidReplacement'));
+ }
}