Make plugin dependency checks case-insensitive (#4337)

Normalize the plugin identifier before lookup in the `hasPlugin` call, which should allow plugin dependencies to resolve if mis-cased in the Plugin `$require` property.

Credit to @tobias-kuendig.
This commit is contained in:
Tobias Kündig 2019-07-02 16:12:29 +02:00 committed by Ben Thomson
parent 5b80ad2501
commit 604f0d060d
2 changed files with 5 additions and 7 deletions

View File

@ -363,7 +363,9 @@ class PluginManager
{
$classId = $this->getIdentifier($namespace);
return isset($this->plugins[$classId]);
$normalized = $this->normalizeIdentifier($classId);
return isset($this->plugins[$normalized]);
}
/**
@ -707,13 +709,11 @@ class PluginManager
$loopCount = 0;
while (count($checklist)) {
if (++$loopCount > 999) {
throw new ApplicationException('Too much recursion');
}
foreach ($checklist as $code => $plugin) {
/*
* Get dependencies and remove any aliens
*/
@ -745,9 +745,7 @@ class PluginManager
array_push($result, $code);
unset($checklist[$code]);
}
}
return $result;
}

View File

@ -117,10 +117,10 @@ class PluginManagerTest extends TestCase
* Test case for https://github.com/octobercms/october/pull/4337
*/
$result = $this->manager->hasPlugin('dependencyTest\Wrongcase');
$this->assertFalse($result);
$this->assertTrue($result);
$result = $this->manager->hasPlugin('dependencyTest.Wrongcase');
$this->assertFalse($result);
$this->assertTrue($result);
}
public function testGetPluginNamespaces()