fix: preserve running kernel cache during archive updates
This commit is contained in:
1 parent
c82a37643b
commit
7c1c86b864
9 files changed
+176
-19
No files matched your search
@@ -70,10 +70,12 @@ final class ArchiveUpdateTest extends TestCase
|
||||
public function testAnUpdateReplacesTheApplicationAndLeavesTheInstallationUntouched(): void
|
||||
{
|
||||
$this->releases->release(self::BASE, self::API, '1.1.0', $this->archive('1.1.0'));
|
||||
$this->write('var/cache/prod/running-service.php', '<?php // Still needed by this request.');
|
||||
|
||||
$ergebnis = $this->updater()->run();
|
||||
|
||||
self::assertTrue($ergebnis['ok'], $this->explain($ergebnis));
|
||||
self::assertFileExists($this->root.'/var/cache/prod/running-service.php', 'The update request still loads compiled services after replacing files.');
|
||||
self::assertTrue($ergebnis['migrate'] ?? false, 'Nach dem Ersetzen fehlen noch die Migrationen.');
|
||||
self::assertSame(
|
||||
['Fassung ermitteln', 'Sicherung', 'Archiv laden', 'Prüfsumme', 'Entpacken', 'Wartungszustand', 'Dateien ersetzen', 'Zwischenspeicher', 'Dateien sind ersetzt'],
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests;
|
||||
|
||||
use App\Kernel;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class KernelCacheTest extends TestCase
|
||||
{
|
||||
public function testAnUpdateKeepsTheRunningCacheAndSelectsANewOneForTheNextRequest(): void
|
||||
{
|
||||
$root = sys_get_temp_dir().'/kant-cache-'.bin2hex(random_bytes(6));
|
||||
mkdir($root);
|
||||
$kernel = static fn (): Kernel => new class($root) extends Kernel {
|
||||
public function __construct(private string $root)
|
||||
{
|
||||
parent::__construct('prod', false);
|
||||
}
|
||||
|
||||
public function getProjectDir(): string
|
||||
{
|
||||
return $this->root;
|
||||
}
|
||||
};
|
||||
try {
|
||||
file_put_contents($root.'/VERSION', "1.10.1\n");
|
||||
$running = $kernel();
|
||||
$old = $running->getCacheDir();
|
||||
self::assertSame($old, $kernel()->getCacheDir());
|
||||
file_put_contents($root.'/VERSION', "1.10.2\n");
|
||||
self::assertSame($old, $running->getCacheDir(), 'The active request retains its cache even after VERSION changes.');
|
||||
self::assertNotSame($old, $kernel()->getCacheDir(), 'A new kernel must not reuse the previous compiled container or Twig templates.');
|
||||
} finally {
|
||||
unlink($root.'/VERSION');
|
||||
rmdir($root);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user