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:
HeuJung committed 2026-09-06 15:22:52 +09:00
1 parent d263f74cae
commit de18159986
105 files changed
+4055 -208

No files matched your search

+113
View File
@@ -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);
}
/**