diff --git a/system/src/Grav/Common/Recovery/RecoveryManager.php b/system/src/Grav/Common/Recovery/RecoveryManager.php index 2e59ab2af..e1da99d53 100644 --- a/system/src/Grav/Common/Recovery/RecoveryManager.php +++ b/system/src/Grav/Common/Recovery/RecoveryManager.php @@ -124,9 +124,6 @@ class RecoveryManager $file = $error['file'] ?? ''; $plugin = $this->detectPluginFromPath($file); - if (!$plugin) { - return; - } $context = [ 'created_at' => time(), diff --git a/tests/unit/Grav/Common/Recovery/RecoveryManagerTest.php b/tests/unit/Grav/Common/Recovery/RecoveryManagerTest.php index 24f8f3884..fb76dfc44 100644 --- a/tests/unit/Grav/Common/Recovery/RecoveryManagerTest.php +++ b/tests/unit/Grav/Common/Recovery/RecoveryManagerTest.php @@ -77,6 +77,49 @@ class RecoveryManagerTest extends \Codeception\TestCase\Test self::assertArrayHasKey('bad', $decoded); } + public function testHandleShutdownCreatesFlagWithoutPlugin(): void + { + $manager = new class($this->tmpDir) extends RecoveryManager { + protected $error; + public function __construct(string $rootPath) + { + parent::__construct($rootPath); + $this->error = [ + 'type' => E_ERROR, + 'file' => $this->getRootPathValue() . '/system/index.php', + 'message' => 'Core failure', + 'line' => 13, + ]; + } + + protected function resolveLastError(): ?array + { + return $this->error; + } + + private function getRootPathValue(): string + { + $prop = new \ReflectionProperty(RecoveryManager::class, 'rootPath'); + $prop->setAccessible(true); + + return $prop->getValue($this); + } + }; + + $manager->markUpgradeWindow('core-upgrade', ['scope' => 'core']); + $manager->handleShutdown(); + + $flag = $this->tmpDir . '/user/data/recovery.flag'; + self::assertFileExists($flag); + $context = json_decode(file_get_contents($flag), true); + self::assertArrayHasKey('plugin', $context); + self::assertNull($context['plugin']); + self::assertSame('Core failure', $context['message']); + + $quarantine = $this->tmpDir . '/user/data/upgrades/quarantine.json'; + self::assertFileDoesNotExist($quarantine); + } + public function testHandleShutdownIgnoresNonFatalErrors(): void { $manager = new class($this->tmpDir) extends RecoveryManager {