mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 00:46:07 +02:00
@@ -81,7 +81,7 @@ date_default_timezone_set(@date_default_timezone_get());
|
||||
@ini_set('default_charset', 'UTF-8');
|
||||
mb_internal_encoding('UTF-8');
|
||||
|
||||
$recoveryFlag = __DIR__ . '/system/recovery.flag';
|
||||
$recoveryFlag = __DIR__ . '/user/data/recovery.flag';
|
||||
if (PHP_SAPI !== 'cli' && is_file($recoveryFlag)) {
|
||||
require __DIR__ . '/system/recovery.php';
|
||||
return 0;
|
||||
|
||||
@@ -116,7 +116,7 @@ header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
<?php if (!$authenticated): ?>
|
||||
<p>This site is running in recovery mode because Grav detected a fatal error.</p>
|
||||
<p>Locate the recovery token in <code>system/recovery.flag</code> and enter it below.</p>
|
||||
<p>Locate the recovery token in <code>user/data/recovery.flag</code> and enter it below.</p>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" value="authenticate">
|
||||
<label for="token">Recovery token</label>
|
||||
|
||||
@@ -156,6 +156,7 @@ class RecoveryManager
|
||||
public function activate(array $context): void
|
||||
{
|
||||
$flag = $this->flagPath();
|
||||
Folder::create(dirname($flag));
|
||||
if (empty($context['token'])) {
|
||||
$context['token'] = $this->generateToken();
|
||||
}
|
||||
@@ -294,7 +295,7 @@ class RecoveryManager
|
||||
*/
|
||||
private function flagPath(): string
|
||||
{
|
||||
return $this->rootPath . '/system/recovery.flag';
|
||||
return $this->userPath . '/data/recovery.flag';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -418,7 +418,7 @@ class SafeUpgradeService
|
||||
*/
|
||||
public function clearRecoveryFlag(): void
|
||||
{
|
||||
$flag = $this->rootPath . '/system/recovery.flag';
|
||||
$flag = $this->rootPath . '/user/data/recovery.flag';
|
||||
if (is_file($flag)) {
|
||||
@unlink($flag);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ class RecoveryManagerTest extends \Codeception\TestCase\Test
|
||||
$this->tmpDir = sys_get_temp_dir() . '/grav-recovery-' . uniqid('', true);
|
||||
Folder::create($this->tmpDir);
|
||||
Folder::create($this->tmpDir . '/user');
|
||||
Folder::create($this->tmpDir . '/user/data');
|
||||
Folder::create($this->tmpDir . '/system');
|
||||
}
|
||||
|
||||
@@ -59,7 +60,7 @@ class RecoveryManagerTest extends \Codeception\TestCase\Test
|
||||
$manager->markUpgradeWindow('core-upgrade', ['scope' => 'core']);
|
||||
$manager->handleShutdown();
|
||||
|
||||
$flag = $this->tmpDir . '/system/recovery.flag';
|
||||
$flag = $this->tmpDir . '/user/data/recovery.flag';
|
||||
self::assertFileExists($flag);
|
||||
$context = json_decode(file_get_contents($flag), true);
|
||||
self::assertSame('Fatal failure', $context['message']);
|
||||
@@ -87,12 +88,12 @@ class RecoveryManagerTest extends \Codeception\TestCase\Test
|
||||
|
||||
$manager->handleShutdown();
|
||||
|
||||
self::assertFileDoesNotExist($this->tmpDir . '/system/recovery.flag');
|
||||
self::assertFileDoesNotExist($this->tmpDir . '/user/data/recovery.flag');
|
||||
}
|
||||
|
||||
public function testClearRemovesFlag(): void
|
||||
{
|
||||
$flag = $this->tmpDir . '/system/recovery.flag';
|
||||
$flag = $this->tmpDir . '/user/data/recovery.flag';
|
||||
file_put_contents($flag, 'flag');
|
||||
|
||||
$manager = new RecoveryManager($this->tmpDir);
|
||||
@@ -130,7 +131,7 @@ class RecoveryManagerTest extends \Codeception\TestCase\Test
|
||||
$manager = new RecoveryManager($this->tmpDir);
|
||||
$manager->disablePlugin('problem', ['message' => 'Manual disable']);
|
||||
|
||||
$flag = $this->tmpDir . '/system/recovery.flag';
|
||||
$flag = $this->tmpDir . '/user/data/recovery.flag';
|
||||
self::assertFileDoesNotExist($flag);
|
||||
|
||||
$configFile = $this->tmpDir . '/user/config/plugins/problem.yaml';
|
||||
|
||||
@@ -186,7 +186,7 @@ PHP;
|
||||
public function testClearRecoveryFlagRemovesFile(): void
|
||||
{
|
||||
[$root] = $this->prepareLiveEnvironment();
|
||||
$flag = $root . '/system/recovery.flag';
|
||||
$flag = $root . '/user/data/recovery.flag';
|
||||
Folder::create(dirname($flag));
|
||||
file_put_contents($flag, 'flag');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user