fix(core,admin_basic): 정적 게시 재게시 누락 3건 수정 + 관리자 수동 복구 UI + sudo core:update 소유권 정합
- 템플릿 update 는 레이아웃 변경 여부와 무관하게 캐시 버전을 올리고(실패 복원 뒤에도), 자산 주소 방식 전환 3경로도 bump 한다 - config:cache 가 컨테이너 인스턴스를 덮어 이후 terminating 재게시가 사라지던 결함을 복원 헬퍼로 차단 - custom/ 변경 감지와 게시가 같은 열거자(재귀·크기 포함)를 쓰고, 서명은 호스트별로 저장 - 캐시 버전·서명 키를 만료시키지 않는다(기본 TTL 24h 로 매일 전체 재생성되던 문제) - 관리자 > 환경설정 > 일반 「초기 화면 정적 파일」 카드: 상태 조회 + 지금 다시 만들기(확인 모달), 대시보드 알림 버튼 연결, CLI 와 같은 statusReport 소비 - sudo core:update 경로의 root 소유 잔존(설정 디렉토리·임시 폴더·로그·업그레이드 마이그레이션 산출물) 상속·정합화, ext-static 명령 root 경고와 sudo -u 힌트 - 안내·문서·트러블슈팅 4건·audit 룰 ext-cache-version-raw-read·ja 언어팩 동기
This commit is contained in:
1 parent
d263f74cae
commit
de18159986
105 files changed
+4055
-208
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -52,7 +53,7 @@ class ConfigCacheHelper
|
||||
}
|
||||
|
||||
try {
|
||||
Artisan::call('config:cache');
|
||||
self::withPreservedContainer(static fn () => Artisan::call('config:cache'));
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('config 캐시 재생성 실패 (config:clear 로 stale 은 제거됨 — 다음 요청은 비캐시 부팅)', [
|
||||
'error' => $e->getMessage(),
|
||||
@@ -60,6 +61,30 @@ class ConfigCacheHelper
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 콜백 실행 뒤 전역 컨테이너 인스턴스를 원래 앱으로 되돌립니다.
|
||||
*
|
||||
* `config:cache` 는 신선한 설정을 얻기 위해 **새 Application 을 부팅**하는데, `Application` 생성자가
|
||||
* `Container::setInstance()` 를 호출하므로 그 순간부터 `app()` 헬퍼가 실행 중인 앱이 아니라 그
|
||||
* 일회용 앱을 가리킨다(파사드는 별도 참조라 그대로다). 같은 프로세스에서 그 뒤에 등록되는
|
||||
* `app()->terminating()` 콜백은 종료되지 않는 앱에 걸려 **영원히 실행되지 않는다** — 설정 저장
|
||||
* 뒤의 확장 캐시 버전 bump 가 예약한 정적 재게시가 그렇게 조용히 사라졌다(#651 F5 실측: 버전은
|
||||
* 올랐는데 게시는 다음 렌더의 자가 치유까지 미뤄짐). 예외도 로그도 없고, 자가 치유가 한 렌더
|
||||
* 뒤에 덮어 주므로 "한 박자 늦게 반영" 으로만 나타난다.
|
||||
*
|
||||
* @param callable $callback 전역 인스턴스를 바꿔 놓을 수 있는 작업
|
||||
*/
|
||||
public static function withPreservedContainer(callable $callback): void
|
||||
{
|
||||
$app = Container::getInstance();
|
||||
|
||||
try {
|
||||
$callback();
|
||||
} finally {
|
||||
Container::setInstance($app);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* config 캐시만 제거합니다 (재생성 없음).
|
||||
*
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Support;
|
||||
|
||||
use App\Extension\HookManager;
|
||||
use App\Rules\AllowedTemplateFileType;
|
||||
use App\Services\ExtensionStaticCacheService;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -53,6 +54,14 @@ class CustomAssets
|
||||
/** 요청 스코프 메모이즈 (같은 요청에서 같은 확장을 여러 번 묻는 경로 대비) */
|
||||
private static array $cache = [];
|
||||
|
||||
/**
|
||||
* 게시 대상 파일 열거 결과의 요청 스코프 메모이즈 (키 형식은 `$cache` 와 같다 — `{type}|{id}`).
|
||||
*
|
||||
* 서술자 메모(`$cache`)와 자리를 나눈다 — 서술자는 **로드 목록**(최상위 css/js), 이것은
|
||||
* **게시·변경 감지 집합**(하위 디렉토리 포함 전 허용 확장자)이라 의미가 다르다.
|
||||
*/
|
||||
private static array $fileCache = [];
|
||||
|
||||
/**
|
||||
* 확장 하나의 사용자 추가 에셋 목록을 돌려줍니다.
|
||||
*
|
||||
@@ -87,6 +96,110 @@ class CustomAssets
|
||||
public static function flushCache(): void
|
||||
{
|
||||
self::$cache = [];
|
||||
self::$fileCache = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 확장 하나의 `custom/` 아래 **게시 대상 파일 전체**를 열거합니다.
|
||||
*
|
||||
* 정적 게시(`ExtensionStaticCacheService`)와 변경 감지(`CollectsCustomAssets`)가 **같은
|
||||
* 열거자**를 쓴다. 종전에는 게시가 `custom/**` 를 재귀로 복사하고 감지는 최상위 css/js 의
|
||||
* mtime 만 서명해 범위가 어긋났다 — 문서가 권장하는 `url('./fonts/x.woff2')` 의 글꼴만
|
||||
* 교체하면 게시본이 영영 갱신되지 않았다(#651 F7). 감지 범위와 게시 범위를 한 코드가
|
||||
* 정의해야 다시 어긋나지 않는다.
|
||||
*
|
||||
* 규약 스캔의 **로드 목록**(`forExtension()` — 최상위 css/js) 과는 별개다. 글꼴·이미지는
|
||||
* CSS 가 상대 경로로 참조하는 대상이지 그 자체로 로드할 것이 아니므로 로드 목록은 그대로다.
|
||||
*
|
||||
* 허용 확장자는 종전 게시와 동일하게 `AllowedTemplateFileType::allowedExtensions()`(환경
|
||||
* 무관 게터)에서 소스맵(`map`)을 뺀 목록이다 — 배포 금지 정책(`*.map` gitignore)과 같다.
|
||||
*
|
||||
* @param string $extensionType `templates` | `modules` | `plugins`
|
||||
* @param string $identifier 확장 식별자
|
||||
* @return array<int, array{relative: string, absolute: string, mtime: int, size: int}> 상대 경로 오름차순
|
||||
*/
|
||||
public static function publishableFiles(string $extensionType, string $identifier): array
|
||||
{
|
||||
$cacheKey = $extensionType.'|'.$identifier;
|
||||
|
||||
if (array_key_exists($cacheKey, self::$fileCache)) {
|
||||
return self::$fileCache[$cacheKey];
|
||||
}
|
||||
|
||||
return self::$fileCache[$cacheKey] = self::enumeratePublishableFiles($extensionType, $identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* `publishableFiles()` 의 실제 열거 (메모 없음).
|
||||
*
|
||||
* @param string $extensionType 확장 타입
|
||||
* @param string $identifier 확장 식별자
|
||||
* @return array<int, array{relative: string, absolute: string, mtime: int, size: int}> 상대 경로 오름차순
|
||||
*/
|
||||
private static function enumeratePublishableFiles(string $extensionType, string $identifier): array
|
||||
{
|
||||
$directory = self::directory($extensionType, $identifier);
|
||||
|
||||
if ($directory === null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$realRoot = realpath($directory);
|
||||
|
||||
if ($realRoot === false || ! is_dir($realRoot)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$allowed = array_diff(AllowedTemplateFileType::allowedExtensions(), ['map']);
|
||||
|
||||
try {
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator($realRoot, \FilesystemIterator::SKIP_DOTS)
|
||||
);
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
Log::warning('사용자 추가 에셋 디렉토리를 열 수 없습니다.', [
|
||||
'identifier' => $identifier,
|
||||
'directory' => $realRoot,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
$files = [];
|
||||
|
||||
/** @var \SplFileInfo $file */
|
||||
foreach ($iterator as $file) {
|
||||
if (! $file->isFile()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$extension = strtolower($file->getExtension());
|
||||
|
||||
if (! in_array($extension, $allowed, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 컨테인먼트 검증 — 심볼릭 링크 등으로 custom 밖을 가리키는 실경로 차단 (게시와 동일)
|
||||
$realFile = $file->getRealPath();
|
||||
|
||||
if ($realFile === false || ! str_starts_with($realFile, $realRoot.DIRECTORY_SEPARATOR)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$relative = str_replace('\\', '/', substr($realFile, strlen($realRoot) + 1));
|
||||
|
||||
$files[$relative] = [
|
||||
'relative' => $relative,
|
||||
'absolute' => $realFile,
|
||||
'mtime' => (int) (@$file->getMTime() ?: 0),
|
||||
'size' => (int) (@$file->getSize() ?: 0),
|
||||
];
|
||||
}
|
||||
|
||||
ksort($files, SORT_STRING);
|
||||
|
||||
return array_values($files);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user