mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 08:18:31 +08:00
fix: dont ignore optional dependencies on disabled extensions. (#3352)
There is a check in the ExtensionManager::resolveExtensionOrder function that ignores optional dependencies on extensions that don't exist in the system. This is sufficient for resolution purposes. The filter removed in this PR would ignore optional dependencies on non-enabled extensions, so when such an extension was enabled, dependency resolution would run incorrectly.
This commit is contained in:
parent
45aba446b3
commit
431ba30434
@ -219,7 +219,7 @@ class Extension implements Arrayable
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function calculateDependencies($extensionSet, $enabledIds)
|
||||
public function calculateDependencies($extensionSet)
|
||||
{
|
||||
$this->extensionDependencyIds = (new Collection(Arr::get($this->composerJson, 'require', [])))
|
||||
->keys()
|
||||
@ -235,9 +235,6 @@ class Extension implements Arrayable
|
||||
->map(function ($key) {
|
||||
return static::nameToId($key);
|
||||
})
|
||||
->filter(function ($key) use ($enabledIds) {
|
||||
return array_key_exists($key, $enabledIds);
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
@ -87,9 +87,7 @@ class ExtensionManager
|
||||
// We calculate and store a set of composer package names for all installed Flarum extensions,
|
||||
// so we know what is and isn't a flarum extension in `calculateDependencies`.
|
||||
// Using keys of an associative array allows us to do these checks in constant time.
|
||||
// We do the same for enabled extensions, for optional dependencies.
|
||||
$installedSet = [];
|
||||
$enabledIds = array_flip($this->getEnabled());
|
||||
|
||||
foreach ($installed as $package) {
|
||||
if (Arr::get($package, 'type') != 'flarum-extension' || empty(Arr::get($package, 'name'))) {
|
||||
@ -113,7 +111,7 @@ class ExtensionManager
|
||||
}
|
||||
|
||||
foreach ($extensions as $extension) {
|
||||
$extension->calculateDependencies($installedSet, $enabledIds);
|
||||
$extension->calculateDependencies($installedSet);
|
||||
}
|
||||
|
||||
$needsReset = false;
|
||||
|
@ -26,7 +26,7 @@ class ExtensionDependencyResolutionTest extends TestCase
|
||||
$this->missing = new FakeExtension('flarum-missing', ['this-does-not-exist', 'flarum-tags', 'also-not-exists']);
|
||||
$this->circular1 = new FakeExtension('circular1', ['circular2']);
|
||||
$this->circular2 = new FakeExtension('circular2', ['circular1']);
|
||||
$this->optionalDependencyCategories = new FakeExtension('flarum-categories', ['flarum-tags'], ['flarum-tag-backgrounds']);
|
||||
$this->optionalDependencyCategories = new FakeExtension('flarum-categories', ['flarum-tags'], ['flarum-tag-backgrounds', 'non-existent-optional-dependency']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
Loading…
x
Reference in New Issue
Block a user