From e8fbafc9e1e97986fcbe9ddb6dc73bce61bf299a Mon Sep 17 00:00:00 2001 From: robert dennis <31261583+robertdrakedennis@users.noreply.github.com> Date: Sun, 11 Oct 2026 03:11:29 -0400 Subject: [PATCH] extension enable check --- app/Services/Extensions/ExtensionCompatibility.php | 10 +++++++--- .../Extensions/ExtensionCompatibilityTest.php | 13 +++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/Services/Extensions/ExtensionCompatibility.php b/app/Services/Extensions/ExtensionCompatibility.php index bcb719d26..ebb820bb6 100644 --- a/app/Services/Extensions/ExtensionCompatibility.php +++ b/app/Services/Extensions/ExtensionCompatibility.php @@ -60,9 +60,13 @@ final class ExtensionCompatibility /** @param Collection $enabled */ public function assertCompatible(ExtensionManifest $manifest, Collection $enabled): void { - $errors = $this->resolve((clone $enabled)->put($manifest->id, $manifest))['errors']; - // A claim both sides make is reported from the side of the extension being checked. - $reason = $errors[$manifest->id] ?? reset($errors); + $before = $this->resolve($enabled)['errors']; + $after = $this->resolve((clone $enabled)->put($manifest->id, $manifest))['errors']; + // An extension that was already failing does not hold this one back: only a failure + // of its own, or one it causes in another extension, does. A claim both sides make + // is reported from the side of the extension being checked. + $caused = array_diff_key($after, $before); + $reason = $after[$manifest->id] ?? reset($caused); throw_if($reason !== false, InvalidExtensionException::class, $reason); $this->assertDistinctAutoloader($manifest, $enabled); } diff --git a/tests/Unit/Services/Extensions/ExtensionCompatibilityTest.php b/tests/Unit/Services/Extensions/ExtensionCompatibilityTest.php index 30ae4f2b9..a840460fc 100644 --- a/tests/Unit/Services/Extensions/ExtensionCompatibilityTest.php +++ b/tests/Unit/Services/Extensions/ExtensionCompatibilityTest.php @@ -65,6 +65,19 @@ test('rejects upgrades and disabling that would break an enabled dependent', fun $compatibility->assertCanDisable('child', $enabled); }); +test('an extension that is already failing does not stop another from being enabled', function (): void { + $enabled = collect([ + 'future' => manifest('future', ['panel' => '^3.0']), + 'orphan' => manifest('orphan', ['extensions' => ['gone' => '*']]), + ]); + $compatibility = resolve(ExtensionCompatibility::class); + + $compatibility->assertCompatible(manifest('healthy'), $enabled); + + expect(fn () => $compatibility->assertCompatible(manifest('dependent', ['extensions' => ['future' => '*']]), $enabled)) + ->toThrow(InvalidExtensionException::class, 'Extension "dependent" requires unavailable extension "future".'); +}); + /** @param list $components */ function presentation(string $id, array $components): ExtensionManifest {