fix(core): 코어 업데이트 spawn 자식의 config 캐시 오판 3건 수정 + 컨테이너 보존 래퍼 전수
7.0.9 클린 설치본에서 7.0.10 으로 올리자 업그레이드 스텝 단계가 "부모 메모리 stale" 로 중단됐다. 스텝 자식은 부모가 비우지 않은 이전 버전 config 캐시로 부팅해 env APP_VERSION 오버라이드와 신버전 config/app.php 의 update 목록을 모두 보지 못한다. 이전 릴리즈에서는 자식 진입부의 config:cache 가 전역 Container 를 일회용 앱으로 바꿔 놓는 부수효과로 가드가 우연히 침묵했고, 그 부수효과를 걷어낸 withPreservedContainer 가 잠복 결함을 드러냈다. - stale 가드는 CoreVersionChecker::getCoreVersion(env 우선) 으로 판독 - 부모는 spawn 직전 config 캐시를 비우고, 자식은 캐시 파일이 있으면 디스크 config 를 직접 읽는다 (7.0.10 이 추가한 public/build/ext 쓰기 권한 정상화 누락 차단) - route:cache 도 같은 부수효과를 남기므로 RouteCacheHelper·optimizeSystem 을 보존 래퍼로 감쌌다 (단독 스텝 재실행·시스템 최적화 뒤 정적 재게시 예약 소실) - 과거 업그레이드 사고 14부류를 7.0.10 변경과 대조 — 재발 조건은 위 3건뿐 - audit 룰 fresh-app-artisan-call-outside-cache-helper + 픽스처, 회귀 테스트 6건(수정 전 red)
This commit is contained in:
1 parent
b79e082ca3
commit
67cae00dd8
15 files changed
+477
-10
No files matched your search
@@ -183,6 +183,65 @@ class ExecuteUpgradeStepsStandaloneTest extends TestCase
|
||||
$this->assertSame(0, $exitCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 자식이 이전 버전 config 캐시로 부팅했으면(구버전 부모는 spawn 전에 캐시를 비우지 않는다)
|
||||
* `config('app.update.restore_ownership_group_writable')` 은 옛 목록이다. 이때는 디스크의
|
||||
* `config/app.php` 를 직접 읽어 신버전이 추가한 디렉토리까지 권한 정상화 대상에 넣는다
|
||||
* (7.0.9→7.0.10 서버 실측: `public/build/ext` 누락).
|
||||
*
|
||||
* @effects execute_upgrade_steps_child_reads_update_config_from_disk_when_config_is_cached
|
||||
*/
|
||||
public function test_config_캐시로_부팅한_자식은_쓰기권한_목록을_디스크_config_에서_읽는다(): void
|
||||
{
|
||||
[$service, $module, $plugin, $template, $langPack] = $this->bindMocks();
|
||||
|
||||
config(['app.update.restore_ownership_group_writable' => ['stale/only']]);
|
||||
|
||||
$service->shouldReceive('freshDiskUpdateConfig')
|
||||
->once()
|
||||
->with('restore_ownership_group_writable', [])
|
||||
->andReturn(['fresh/dir']);
|
||||
$service->shouldReceive('ensureWritableDirectories')
|
||||
->once()
|
||||
->withArgs(fn (array $paths) => $paths === ['fresh/dir']);
|
||||
$service->shouldReceive('runUpgradeSteps')->once();
|
||||
|
||||
// 상대 경로 — Application::normalizeCachePath 는 `/`·`\` 로 시작하지 않는 값을 basePath 기준으로
|
||||
// 해석하므로 Windows 절대 경로는 어긋난다.
|
||||
$relativeCachePath = 'storage/framework/testing/child-config-cache-'.uniqid().'.php';
|
||||
$cachePath = base_path($relativeCachePath);
|
||||
File::ensureDirectoryExists(dirname($cachePath));
|
||||
File::put($cachePath, "<?php return [];\n");
|
||||
|
||||
$originalCacheEnv = $_ENV['APP_CONFIG_CACHE'] ?? null;
|
||||
$_ENV['APP_CONFIG_CACHE'] = $relativeCachePath;
|
||||
$_SERVER['APP_CONFIG_CACHE'] = $relativeCachePath;
|
||||
putenv('APP_CONFIG_CACHE='.$relativeCachePath);
|
||||
$originalEnv = getenv('G7_UPDATE_IN_PROGRESS');
|
||||
putenv('G7_UPDATE_IN_PROGRESS=1');
|
||||
|
||||
try {
|
||||
$this->assertSame($cachePath, $this->app->getCachedConfigPath(), '전제: APP_CONFIG_CACHE 가 캐시 경로를 정한다');
|
||||
$this->assertFileExists($cachePath, '전제: 자식 시점에 config 캐시 파일이 존재한다');
|
||||
$this->assertSame(0, $this->runCommand([]));
|
||||
} finally {
|
||||
if ($originalEnv === false) {
|
||||
putenv('G7_UPDATE_IN_PROGRESS');
|
||||
} else {
|
||||
putenv('G7_UPDATE_IN_PROGRESS='.$originalEnv);
|
||||
}
|
||||
if ($originalCacheEnv === null) {
|
||||
unset($_ENV['APP_CONFIG_CACHE'], $_SERVER['APP_CONFIG_CACHE']);
|
||||
putenv('APP_CONFIG_CACHE');
|
||||
} else {
|
||||
$_ENV['APP_CONFIG_CACHE'] = $originalCacheEnv;
|
||||
$_SERVER['APP_CONFIG_CACHE'] = $originalCacheEnv;
|
||||
putenv('APP_CONFIG_CACHE='.$originalCacheEnv);
|
||||
}
|
||||
File::delete($cachePath);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_spawn_child_env_bypasses_all_pre_and_post_steps_without_skip_options(): void
|
||||
{
|
||||
// 구버전 부모(beta.5) 가 신버전 자식(beta.6+) 을 spawn 할 때 `--skip-*` 옵션을 모르므로
|
||||
@@ -342,6 +401,9 @@ class ExecuteUpgradeStepsStandaloneTest extends TestCase
|
||||
private function bindMocks(): array
|
||||
{
|
||||
$service = Mockery::mock(CoreUpdateService::class);
|
||||
// 종료부의 root 산출물 소유권 정상화(#615 도입)는 모든 경로에서 호출되며 본 테스트의 관심사가
|
||||
// 아니다 — 기본 허용으로 두어 각 케이스가 자기 단계만 단언하게 한다.
|
||||
$service->shouldReceive('normalizeRuntimeOwnershipAfterRootRun')->andReturnNull()->byDefault();
|
||||
$module = Mockery::mock(ModuleManager::class);
|
||||
$plugin = Mockery::mock(PluginManager::class);
|
||||
$template = Mockery::mock(TemplateManager::class);
|
||||
|
||||
@@ -37,12 +37,20 @@ class CoreUpdateCommandSpawnFailureTest extends TestCase
|
||||
|
||||
private string $silentStepPath;
|
||||
|
||||
private ?string $originalEnvVersion = null;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->failingStepPath = base_path('upgrades/Upgrade_0_0_1_test_spawn_failure_fail.php');
|
||||
$this->silentStepPath = base_path('upgrades/Upgrade_0_0_1_test_spawn_failure_silent.php');
|
||||
|
||||
// stale 가드는 spawn 자식이 받는 env APP_VERSION 을 먼저 읽는다 (config 캐시가 있으면
|
||||
// config('app.version') 은 캐시에 박힌 구버전이라 신뢰할 수 없다 — 7.0.9→7.0.10 실사례).
|
||||
// 각 테스트가 부모/자식 시나리오에 맞춰 env 를 직접 세우도록 원값을 보관하고 비운다.
|
||||
$this->originalEnvVersion = $_ENV['APP_VERSION'] ?? null;
|
||||
$this->setEnvVersion(null);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
@@ -53,9 +61,30 @@ class CoreUpdateCommandSpawnFailureTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
$this->setEnvVersion($this->originalEnvVersion);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로세스 env 의 APP_VERSION 을 세우거나(문자열) 비운다(null).
|
||||
*
|
||||
* @param string|null $version 세울 버전. null 이면 세 채널($_ENV/$_SERVER/putenv) 모두 제거
|
||||
*/
|
||||
private function setEnvVersion(?string $version): void
|
||||
{
|
||||
if ($version === null) {
|
||||
unset($_ENV['APP_VERSION'], $_SERVER['APP_VERSION']);
|
||||
putenv('APP_VERSION');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$_ENV['APP_VERSION'] = $version;
|
||||
$_SERVER['APP_VERSION'] = $version;
|
||||
putenv('APP_VERSION='.$version);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function fail_spawn_with_mode_abort_모드는_upgrade_handoff_exception_을_throw_한다(): void
|
||||
{
|
||||
@@ -348,6 +377,8 @@ PHP);
|
||||
#[Test]
|
||||
public function run_upgrade_steps_stale_메모리_감지_시_abort_throw_한다(): void
|
||||
{
|
||||
// 부모 in-process fallback 시나리오: .env 의 APP_VERSION 은 아직 fromVersion (Step 11 전).
|
||||
$this->setEnvVersion('7.0.0-beta.3');
|
||||
config(['app.version' => '7.0.0-beta.3']);
|
||||
config(['app.update.spawn_failure_mode' => 'abort']);
|
||||
|
||||
@@ -367,6 +398,7 @@ PHP);
|
||||
#[Test]
|
||||
public function run_upgrade_steps_stale_메모리_감지_시_fallback_은_경고_후_진행한다(): void
|
||||
{
|
||||
$this->setEnvVersion('7.0.0-beta.3');
|
||||
config(['app.version' => '7.0.0-beta.3']);
|
||||
config(['app.update.spawn_failure_mode' => 'fallback']);
|
||||
|
||||
@@ -382,6 +414,7 @@ PHP);
|
||||
#[Test]
|
||||
public function run_upgrade_steps_memory_가_target_과_동일하면_가드_미발동(): void
|
||||
{
|
||||
$this->setEnvVersion('7.0.0-beta.5');
|
||||
config(['app.version' => '7.0.0-beta.5']);
|
||||
config(['app.update.spawn_failure_mode' => 'abort']);
|
||||
|
||||
@@ -393,6 +426,103 @@ PHP);
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 7.0.9 → 7.0.10 실사례 (2026-09-06): 7.0.9 설치본에는 `bootstrap/cache/config.php` 가 있고
|
||||
* 부모는 spawn 전에 그 캐시를 비우지 않는다. 자식은 env `APP_VERSION=toVersion` 을 받지만
|
||||
* 캐시로 부팅하므로 `config('app.version')` 은 캐시에 박힌 fromVersion 이다. 가드가 config 만
|
||||
* 읽으면 정상 spawn 자식을 stale 부모로 오판해 abort 한다 — 스텝 0건 릴리즈에서도 중단된다.
|
||||
*/
|
||||
#[Test]
|
||||
public function run_upgrade_steps_spawn_자식은_config_캐시가_stale_해도_env_버전으로_가드를_통과한다(): void
|
||||
{
|
||||
// 자식이 받는 env 는 toVersion, 캐시로 부팅한 config 는 fromVersion.
|
||||
$this->setEnvVersion('7.0.10');
|
||||
config(['app.version' => '7.0.9']);
|
||||
config(['app.update.spawn_failure_mode' => 'abort']);
|
||||
|
||||
$service = app(CoreUpdateService::class);
|
||||
|
||||
$discovered = null;
|
||||
$service->runUpgradeSteps('7.0.9', '7.0.10', null, false, function (int $count) use (&$discovered): void {
|
||||
$discovered = $count;
|
||||
});
|
||||
|
||||
// 가드를 지나 스텝 발견 단계까지 도달했다 (throw 시 여기 미도달).
|
||||
$this->assertNotNull($discovered, 'env APP_VERSION=toVersion 인 spawn 자식은 stale 가드를 통과해야 한다');
|
||||
}
|
||||
|
||||
/**
|
||||
* 부모는 spawn 직전에 config 캐시를 비운다 — 자식이 이전 버전 캐시로 부팅하면 env `APP_VERSION`
|
||||
* 오버라이드와 신버전 `config/app.php` 의 update 목록(쓰기 권한 디렉토리 등)이 모두 무시된다.
|
||||
* 캐시 파일 위치는 `APP_CONFIG_CACHE` 로 격리한다 (자식도 같은 env 를 물려받는다). 부모가 지우지
|
||||
* 않으면 자식은 이 불완전한 캐시로 부팅해 비정상 종료한다.
|
||||
*
|
||||
* @effects spawnUpgradeStepsProcess_clears_config_cache_before_proc_open
|
||||
*/
|
||||
#[Test]
|
||||
public function spawn_전에_config_캐시_파일을_지워_자식이_디스크_config_로_부팅하게_한다(): void
|
||||
{
|
||||
if (! function_exists('proc_open')) {
|
||||
$this->markTestSkipped('proc_open 미지원 환경');
|
||||
}
|
||||
|
||||
config(['app.update.spawn_failure_mode' => 'abort']);
|
||||
|
||||
// 상대 경로로 지정한다 — Application::normalizeCachePath 는 `/`·`\` 로 시작하지 않는 값을
|
||||
// basePath 기준 상대 경로로 해석하므로 Windows 절대 경로(`C:\…`)는 어긋난다. 자식도 같은
|
||||
// basePath(cwd) 에서 부팅하므로 같은 파일을 가리킨다.
|
||||
$relativeCachePath = 'storage/framework/testing/stale-config-cache-'.uniqid().'.php';
|
||||
$cachePath = base_path($relativeCachePath);
|
||||
File::ensureDirectoryExists(dirname($cachePath));
|
||||
File::put($cachePath, "<?php return ['app' => ['version' => '0.0.0']];\n");
|
||||
|
||||
$originalCacheEnv = $_ENV['APP_CONFIG_CACHE'] ?? null;
|
||||
$_ENV['APP_CONFIG_CACHE'] = $relativeCachePath;
|
||||
$_SERVER['APP_CONFIG_CACHE'] = $relativeCachePath;
|
||||
putenv('APP_CONFIG_CACHE='.$relativeCachePath);
|
||||
|
||||
try {
|
||||
$this->assertSame($cachePath, $this->app->getCachedConfigPath(), '전제: APP_CONFIG_CACHE 가 캐시 경로를 정한다');
|
||||
$this->assertFileExists($cachePath, '전제: 부모 시점에 config 캐시 파일이 존재한다');
|
||||
|
||||
$command = $this->makeCommandWithDummyIo();
|
||||
$method = new \ReflectionMethod(CoreUpdateCommand::class, 'spawnUpgradeStepsProcess');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$result = $method->invoke($command, '9.9.8', '9.9.9', true, fn () => null);
|
||||
|
||||
$this->assertFileDoesNotExist($cachePath, 'spawn 전에 config 캐시를 비워야 자식이 디스크 config + env 로 부팅한다');
|
||||
$this->assertTrue($result, '캐시가 비워졌으면 자식은 정상 부팅해 스텝 0건 통과');
|
||||
} finally {
|
||||
if ($originalCacheEnv === null) {
|
||||
unset($_ENV['APP_CONFIG_CACHE'], $_SERVER['APP_CONFIG_CACHE']);
|
||||
putenv('APP_CONFIG_CACHE');
|
||||
} else {
|
||||
$_ENV['APP_CONFIG_CACHE'] = $originalCacheEnv;
|
||||
$_SERVER['APP_CONFIG_CACHE'] = $originalCacheEnv;
|
||||
putenv('APP_CONFIG_CACHE='.$originalCacheEnv);
|
||||
}
|
||||
if (File::exists($cachePath)) {
|
||||
File::delete($cachePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* env 가 비어 있으면(운영자 단독 실행 등) 종전처럼 config('app.version') 으로 판정한다.
|
||||
*/
|
||||
#[Test]
|
||||
public function run_upgrade_steps_env_부재_시_config_버전으로_stale_을_판정한다(): void
|
||||
{
|
||||
$this->setEnvVersion(null);
|
||||
config(['app.version' => '7.0.9']);
|
||||
config(['app.update.spawn_failure_mode' => 'abort']);
|
||||
|
||||
$this->expectException(UpgradeHandoffException::class);
|
||||
|
||||
app(CoreUpdateService::class)->runUpgradeSteps('7.0.9', '7.0.10');
|
||||
}
|
||||
|
||||
/**
|
||||
* CoreUpdateCommand 를 OutputStyle 주입 없이 리플렉션 호출 가능한 형태로 준비.
|
||||
*/
|
||||
|
||||
@@ -22,6 +22,18 @@ class RunUpgradeStepsAbstractGuardTest extends TestCase
|
||||
{
|
||||
private array $stubStepFiles = [];
|
||||
|
||||
private ?string $originalEnvVersion = null;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// stale 메모리 가드는 env APP_VERSION 을 먼저 읽는다 (spawn 자식 계약). 테스트 프로세스의
|
||||
// .env.testing 값이 target 판정에 끼어들지 않도록 비우고, 각 테스트가 직접 세운다.
|
||||
$this->originalEnvVersion = $_ENV['APP_VERSION'] ?? null;
|
||||
$this->setMemoryVersion(null);
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
foreach ($this->stubStepFiles as $file) {
|
||||
@@ -29,13 +41,34 @@ class RunUpgradeStepsAbstractGuardTest extends TestCase
|
||||
File::delete($file);
|
||||
}
|
||||
}
|
||||
$this->setMemoryVersion($this->originalEnvVersion);
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 가드가 읽는 "메모리 버전" 을 env 와 config 양쪽에 세운다 (null 이면 env 만 비운다).
|
||||
*
|
||||
* @param string|null $version 세울 버전
|
||||
*/
|
||||
private function setMemoryVersion(?string $version): void
|
||||
{
|
||||
if ($version === null) {
|
||||
unset($_ENV['APP_VERSION'], $_SERVER['APP_VERSION']);
|
||||
putenv('APP_VERSION');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$_ENV['APP_VERSION'] = $version;
|
||||
$_SERVER['APP_VERSION'] = $version;
|
||||
putenv('APP_VERSION='.$version);
|
||||
config(['app.version' => $version]);
|
||||
}
|
||||
|
||||
public function test_throws_when_beta5_step_does_not_extend_abstract(): void
|
||||
{
|
||||
// stale 메모리 가드 우회를 위해 메모리 버전을 target 이상으로
|
||||
config(['app.version' => '7.9.9']);
|
||||
$this->setMemoryVersion('7.9.9');
|
||||
|
||||
// 7.9.9-test.guard.a 는 7.0.0-beta.5 보다 명확히 큼 (version_compare 의 pre-release
|
||||
// 해석에 영향 받지 않음). stub 은 AbstractUpgradeStep 미상속 → fatal 가드 발동.
|
||||
@@ -66,7 +99,7 @@ PHP);
|
||||
|
||||
public function test_passes_when_beta5_step_extends_abstract(): void
|
||||
{
|
||||
config(['app.version' => '7.9.9']);
|
||||
$this->setMemoryVersion('7.9.9');
|
||||
|
||||
$version = '7_9_9_test_guard_b';
|
||||
$className = 'Upgrade_'.$version;
|
||||
@@ -100,7 +133,7 @@ PHP);
|
||||
public function test_legacy_pre_beta5_step_bypasses_guard(): void
|
||||
{
|
||||
// legacy beta.4 이하 step 은 AbstractUpgradeStep 미상속이어도 통과 (호환)
|
||||
config(['app.version' => '7.0.0-beta.5']);
|
||||
$this->setMemoryVersion('7.0.0-beta.5');
|
||||
|
||||
$version = '7_0_0_beta_4_test_guard_legacy';
|
||||
$className = 'Upgrade_'.$version;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Services;
|
||||
|
||||
use App\Services\CoreUpdateService;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* spawn 자식은 부모가 비우지 않은 이전 버전 config 캐시로 부팅할 수 있다. 그 상태에서
|
||||
* `config('app.update.*')` 는 캐시에 박힌 옛 목록이라, 신버전이 추가한 쓰기 권한 디렉토리
|
||||
* (7.0.10 의 `public/build/ext`) 가 자식의 권한 정상화에서 빠진다 (2026-09-06 서버 실측).
|
||||
* `freshDiskUpdateConfig()` 는 디스크의 `config/app.php` 를 직접 읽어 그 목록을 돌려준다.
|
||||
*/
|
||||
class CoreUpdateServiceFreshDiskConfigTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @effects execute_upgrade_steps_child_reads_update_config_from_disk_when_config_is_cached
|
||||
*/
|
||||
#[Test]
|
||||
public function 메모리_config_가_stale_해도_디스크의_update_목록을_돌려준다(): void
|
||||
{
|
||||
config(['app.update.restore_ownership_group_writable' => ['stale-only']]);
|
||||
|
||||
$fresh = app(CoreUpdateService::class)->freshDiskUpdateConfig('restore_ownership_group_writable');
|
||||
|
||||
$this->assertNotSame(['stale-only'], $fresh);
|
||||
$this->assertContains('public/build/ext', $fresh, '디스크 config/app.php 의 목록을 읽어야 한다');
|
||||
$this->assertContains('bootstrap/cache', $fresh);
|
||||
}
|
||||
|
||||
/**
|
||||
* @effects execute_upgrade_steps_child_reads_update_config_from_disk_when_config_is_cached
|
||||
*/
|
||||
#[Test]
|
||||
public function 없는_키는_기본값을_돌려준다(): void
|
||||
{
|
||||
$this->assertSame(['x'], app(CoreUpdateService::class)->freshDiskUpdateConfig('no_such_key_'.uniqid(), ['x']));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Support;
|
||||
|
||||
use App\Services\SettingsService;
|
||||
use App\Support\RouteCacheHelper;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* `route:cache` 도 `config:cache` 와 같은 부수효과를 남긴다 — 새 Application 을 부팅하며 전역
|
||||
* `Container` 인스턴스를 일회용 앱으로 바꿔 놓는다. 되돌리지 않으면 그 뒤에 등록되는
|
||||
* `app()->terminating()` 이 종료되지 않는 앱에 걸려 실행되지 않는다(정적 재게시 예약 소실).
|
||||
* 단독 실행 `core:execute-upgrade-steps` 가 라우트 캐시 재생성 **뒤에** 캐시 버전을 올리므로
|
||||
* 그 경로에서 실제로 새어 나갔다 (2026-09-06 전수조사).
|
||||
*
|
||||
* 테스트 환경은 `route:cache` 자체를 스킵하므로 소스 구조로 잠근다(`ConfigCacheHelperContainerTest` 와 동형).
|
||||
*/
|
||||
class RouteCacheHelperContainerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @effects route_cache_rebuild_preserves_container_instance
|
||||
*/
|
||||
#[Test]
|
||||
public function rebuild_는_route_cache_를_보존_래퍼로_감싼다(): void
|
||||
{
|
||||
$body = $this->methodBody(RouteCacheHelper::class, 'rebuild');
|
||||
|
||||
$this->assertStringContainsString("withPreservedContainer(static fn () => Artisan::call('route:cache'))", $body);
|
||||
$this->assertStringNotContainsString("\n Artisan::call('route:cache');", $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 관리자 「시스템 최적화」 도 같은 두 명령을 부르므로 같은 래퍼를 거친다.
|
||||
*
|
||||
* @effects route_cache_rebuild_preserves_container_instance
|
||||
*/
|
||||
#[Test]
|
||||
public function optimize_system_은_config_route_cache_를_보존_래퍼로_감싼다(): void
|
||||
{
|
||||
$body = $this->methodBody(SettingsService::class, 'optimizeSystem');
|
||||
|
||||
$this->assertStringContainsString('withPreservedContainer(', $body);
|
||||
$this->assertStringNotContainsString("\n Artisan::call('config:cache');", $body);
|
||||
$this->assertStringNotContainsString("\n Artisan::call('route:cache');", $body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 새 Application 을 부팅하는 Artisan 명령은 두 헬퍼 밖에서 직접 호출되지 않는다.
|
||||
*
|
||||
* 모집단은 `app/` 전체 PHP 파일에서 파생한다 — 헬퍼를 우회하는 호출이 하나라도 생기면
|
||||
* 그 자리 뒤의 `terminating` 예약이 조용히 사라진다.
|
||||
*
|
||||
* @effects route_cache_rebuild_preserves_container_instance
|
||||
*/
|
||||
#[Test]
|
||||
public function 새_앱을_부팅하는_artisan_호출은_헬퍼_밖에서_직접_부르지_않는다(): void
|
||||
{
|
||||
$allowed = [
|
||||
realpath(app_path('Support/ConfigCacheHelper.php')),
|
||||
realpath(app_path('Support/RouteCacheHelper.php')),
|
||||
realpath(app_path('Services/SettingsService.php')),
|
||||
];
|
||||
$pattern = "/(?:Artisan::call|->call)\(\s*'(?:config:cache|route:cache|event:cache|optimize)'/";
|
||||
|
||||
$files = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(app_path(), \FilesystemIterator::SKIP_DOTS)));
|
||||
$offenders = [];
|
||||
$scanned = 0;
|
||||
foreach ($files as $file) {
|
||||
if ($file->getExtension() !== 'php') {
|
||||
continue;
|
||||
}
|
||||
$scanned++;
|
||||
$content = (string) file_get_contents($file->getPathname());
|
||||
if (! preg_match($pattern, $content)) {
|
||||
continue;
|
||||
}
|
||||
if (in_array(realpath($file->getPathname()), $allowed, true)) {
|
||||
continue;
|
||||
}
|
||||
$offenders[] = str_replace(base_path().DIRECTORY_SEPARATOR, '', $file->getPathname());
|
||||
}
|
||||
|
||||
$this->assertGreaterThan(100, $scanned, '모집단이 비었다 — app/ 스캔 실패');
|
||||
$this->assertSame([], $offenders, '새 Application 을 부팅하는 Artisan 명령은 ConfigCacheHelper/RouteCacheHelper 를 경유한다 (컨테이너 보존)');
|
||||
}
|
||||
|
||||
/**
|
||||
* 메서드 본문 소스를 돌려준다.
|
||||
*/
|
||||
private function methodBody(string $class, string $method): string
|
||||
{
|
||||
$ref = new \ReflectionMethod($class, $method);
|
||||
$lines = file($ref->getFileName()) ?: [];
|
||||
|
||||
return implode('', array_slice($lines, $ref->getStartLine() - 1, $ref->getEndLine() - $ref->getStartLine() + 1));
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,7 @@ effects:
|
||||
- ExecuteUpgradeStepsCommand_skips_bundled_updates_when_spawn_env_flag_present_without_skip_options
|
||||
- ExecuteUpgradeStepsCommand_env_guard_dominates_over_force_flag_for_post_steps
|
||||
- ExecuteUpgradeStepsCommand_standalone_invocation_without_env_runs_all_five_steps_intact
|
||||
- execute_upgrade_steps_child_reads_update_config_from_disk_when_config_is_cached
|
||||
|
||||
test_files:
|
||||
- tests/Feature/Console/Commands/ExecuteUpgradeStepsStandaloneTest.php
|
||||
|
||||
@@ -41,6 +41,8 @@ axes:
|
||||
spawn_failure_mode: [abort, fallback]
|
||||
from_to_relation: [from_lt_to, from_eq_to_forced] # version_compare 분기
|
||||
parent_memory_version: [equal_to_to, less_than_to, greater_than_to] # stale 가드 트리거 조건
|
||||
memory_version_source: [env_app_version, config_only_env_absent] # 가드 판독 출처 — env 우선(spawn 자식 계약), env 부재 시 config 폴백
|
||||
child_config_cache_state: [cached_from_version, no_cache] # 자식이 이전 버전 config 캐시로 부팅하는가 (7.0.9→7.0.10 실사례)
|
||||
steps_executed_signal: [present_positive, present_zero, absent] # 자식의 [STEPS_EXECUTED] count 발행 상태
|
||||
steps_discovered_signal: [discovered_positive, discovered_zero, absent] # 범위 내 발견된 스텝 파일 수 (신버전 자식만 발행, 구버전=absent)
|
||||
child_process_origin: [beta_5_plus, beta_4_or_earlier] # 이전 버전 자식 (silent skip 시뮬레이션)
|
||||
@@ -81,6 +83,12 @@ effects:
|
||||
- runUpgradeSteps_throws_UpgradeHandoffException_when_memory_lt_to_with_abort_mode
|
||||
- runUpgradeSteps_logs_warning_when_memory_lt_to_with_fallback_mode
|
||||
- runUpgradeSteps_proceeds_silently_when_memory_eq_or_gt_to
|
||||
- runUpgradeSteps_reads_env_APP_VERSION_before_config_so_spawn_child_with_stale_config_cache_passes_guard
|
||||
- runUpgradeSteps_falls_back_to_config_version_when_env_APP_VERSION_absent
|
||||
# config 캐시 부팅 자식 (2026-09-06 전수조사) — 부모는 spawn 전에 캐시를 비우고, 자식은 캐시 부팅이면 디스크 config 를 읽는다
|
||||
- spawnUpgradeStepsProcess_clears_config_cache_before_proc_open
|
||||
- execute_upgrade_steps_child_reads_update_config_from_disk_when_config_is_cached
|
||||
- route_cache_rebuild_preserves_container_instance
|
||||
- runUpgradeSteps_resume_command_format_matches_execute_upgrade_steps_signature
|
||||
# §1 symlink 보존 (CoreBackupHelper 위임 경로 포함)
|
||||
- copyDirectory_preserves_symlink_target_pointer_on_linux
|
||||
@@ -100,6 +108,9 @@ effects:
|
||||
|
||||
test_files:
|
||||
- tests/Feature/Console/CoreUpdateCommandSpawnFailureTest.php
|
||||
- tests/Feature/Console/Commands/ExecuteUpgradeStepsStandaloneTest.php
|
||||
- tests/Unit/Services/CoreUpdateServiceFreshDiskConfigTest.php
|
||||
- tests/Unit/Support/RouteCacheHelperContainerTest.php
|
||||
- tests/Feature/Console/CoreUpdateCommandHandoffTest.php
|
||||
- tests/Feature/Console/CoreUpdateResumeGuidanceTest.php
|
||||
- tests/Feature/Upgrades/MultiVersionUpgradePathTest.php
|
||||
|
||||
Reference in new issue
Block a user