Files
HeuJung 4744e7bf85 fix(core): 라우트 캐시 상태에서 DevTools 덤프·브라우저 로그 수집 복구
route:cache 가 걸리면 RouteServiceProvider 가 캐시 로드로 분기해 라우트 파일이
실행되지 않는다. routes/devtools.php 는 전역 함수 5개를 정의하고 핸들러가 호출했고,
boost 의 browser-logs 는 프로바이더 boot 등록분이라 setCompiledRoutes 교체로
폐기됐다. 7.0.6 의 RouteCacheHelper 가 12개 라이프사이클 지점에서 캐시를 자동
생성하면서, 확장을 한 번이라도 건드린 사이트에서 항상 재현됐다.

로직을 오토로드되는 App\Support\DevTools\* 로 옮기고 browser-logs URI 를 G7 가
직접 소유해 캐시에 함께 구워지게 했다. 게이트가 참조하던 App\Models\Setting 은
저장소에 없는 유물이라 ConfigRepositoryInterface 로 교체했다.

같은 부류의 재발은 정적 검사(route-file-local-function)로 차단하고, 재현이
in-process 로 불가능하므로 서브프로세스 하네스로 회귀를 고정했다.
2026-08-07 10:13:52 +09:00

42 lines
1.7 KiB
PHP

<?php
namespace App\Support\DevTools;
use App\Contracts\Repositories\ConfigRepositoryInterface;
/**
* DevTools 엔드포인트 접근 게이트 (디버그 모드 판정).
*
* 왜 별도 클래스인가:
* `routes/devtools.php` 의 게이트는 원래
* `config('app.debug') || \App\Models\Setting::getValue('debug.mode', false)` 였는데,
* **`App\Models\Setting` 은 저장소에 존재하지 않는다** (설정이 JSON 으로 이관되며 제거된 유물).
* `||` 단축평가에 가려져 드러나지 않았을 뿐이다 — `SettingsServiceProvider` 가 `debug.mode` 를
* `config('app.debug')` 로 동기화하므로 정상 경로에서는 두 번째 항이 평가되지 않는다.
*
* 그러나 settings JSON 의 `debug` 카테고리가 비면 그 동기화가 조기 반환하고, `.env` 의
* `APP_DEBUG=false` 와 만나 **403 이어야 할 응답이 `Class "App\Models\Setting" not found`
* 500 이 된다.** 이 게이트의 두 번째 조건은 한 번도 동작한 적이 없다.
*
* 판정 SSoT 는 형제 컴포넌트인 `App\Http\Middleware\SyncBoostWithDebugMode` 가 쓰는
* `ConfigRepositoryInterface::get('debug.mode', false)` 와 일치시킨다.
*/
class DebugGate
{
/**
* 디버그 모드 활성화 여부를 반환합니다.
*
* `.env` 의 `APP_DEBUG` 또는 관리자 환경설정의 `debug.mode` 중 하나라도 켜져 있으면 true.
*
* @return bool 디버그 모드 활성화 여부
*/
public static function isEnabled(): bool
{
if ((bool) config('app.debug')) {
return true;
}
return (bool) app(ConfigRepositoryInterface::class)->get('debug.mode', false);
}
}