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
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Support;
|
||||
|
||||
use App\Support\ConfigCacheHelper;
|
||||
use Illuminate\Container\Container;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* `ConfigCacheHelper` 가 `config:cache` 뒤 전역 컨테이너 인스턴스를 되돌리는지 (#651 F2 실측 파생).
|
||||
*
|
||||
* `config:cache` 는 새 Application 을 부팅하고 그 생성자가 `Container::setInstance()` 를 호출한다.
|
||||
* 되돌리지 않으면 같은 프로세스의 후속 `app()->terminating()` 이 종료되지 않는 일회용 앱에 등록되어
|
||||
* 정적 재게시 예약이 조용히 사라진다 — 예외도 로그도 없이 "다음 렌더에야 반영" 으로만 나타난다.
|
||||
*/
|
||||
class ConfigCacheHelperContainerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* 콜백이 전역 인스턴스를 바꿔 놓아도 실행 후 원래 앱으로 돌아온다.
|
||||
*
|
||||
* @effects config_cache_rebuild_preserves_container_instance
|
||||
*/
|
||||
#[Test]
|
||||
public function 콜백이_전역_인스턴스를_바꿔도_원래_앱으로_되돌린다(): void
|
||||
{
|
||||
$original = Container::getInstance();
|
||||
$stray = new Container;
|
||||
|
||||
ConfigCacheHelper::withPreservedContainer(static function () use ($stray): void {
|
||||
Container::setInstance($stray);
|
||||
});
|
||||
|
||||
$this->assertSame($original, Container::getInstance(), 'config:cache 뒤 app() 이 일회용 앱을 가리킨 채 남는다 — 후속 terminating 예약이 사라진다');
|
||||
$this->assertSame($original, app());
|
||||
}
|
||||
|
||||
/**
|
||||
* 콜백이 예외를 던져도 인스턴스는 되돌린다.
|
||||
*
|
||||
* @effects config_cache_rebuild_preserves_container_instance
|
||||
*/
|
||||
#[Test]
|
||||
public function 콜백이_실패해도_원래_앱으로_되돌린다(): void
|
||||
{
|
||||
$original = Container::getInstance();
|
||||
|
||||
try {
|
||||
ConfigCacheHelper::withPreservedContainer(static function (): void {
|
||||
Container::setInstance(new Container);
|
||||
|
||||
throw new \RuntimeException('boom');
|
||||
});
|
||||
$this->fail('예외가 전파되어야 한다');
|
||||
} catch (\RuntimeException) {
|
||||
// 기대한 예외
|
||||
}
|
||||
|
||||
$this->assertSame($original, Container::getInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
* `rebuild()` 가 `config:cache` 호출을 보존 래퍼로 감싼다 (소스 구조).
|
||||
*
|
||||
* @effects config_cache_rebuild_preserves_container_instance
|
||||
*/
|
||||
#[Test]
|
||||
public function rebuild_는_config_cache_를_보존_래퍼로_감싼다(): void
|
||||
{
|
||||
$method = new \ReflectionMethod(ConfigCacheHelper::class, 'rebuild');
|
||||
$lines = file($method->getFileName()) ?: [];
|
||||
$body = implode('', array_slice($lines, $method->getStartLine() - 1, $method->getEndLine() - $method->getStartLine() + 1));
|
||||
|
||||
$this->assertStringContainsString("withPreservedContainer(static fn () => Artisan::call('config:cache'))", $body);
|
||||
$this->assertStringNotContainsString("\n Artisan::call('config:cache');", $body);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Support;
|
||||
|
||||
use App\Support\CustomAssets;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* `CustomAssets::publishableFiles()` — 게시·변경 감지가 공유하는 열거자 테스트 (#651 F7).
|
||||
*
|
||||
* 정적 게시는 `custom/**` 를 재귀로 복사하고, 변경 감지는 종전에 최상위 css/js 의 mtime 만
|
||||
* 서명했다. 두 범위를 서로 다른 코드가 정의하면 어긋나고, 그 어긋남은 "글꼴을 바꿨는데
|
||||
* 반영되지 않는다" 로만 나타난다. 이 열거자 하나가 두 소비자의 집합을 정한다.
|
||||
*
|
||||
* DB 를 쓰지 않는다 — 파일 시스템 해석만 검증한다.
|
||||
*/
|
||||
class CustomAssetsPublishableFilesTest extends TestCase
|
||||
{
|
||||
/** 테스트용 가짜 플러그인 식별자 */
|
||||
private const FAKE_PLUGIN = 'g7test-publishable';
|
||||
|
||||
private function pluginDir(): string
|
||||
{
|
||||
return base_path('plugins/'.self::FAKE_PLUGIN);
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
CustomAssets::flushCache();
|
||||
File::ensureDirectoryExists($this->pluginDir().'/custom');
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
File::deleteDirectory($this->pluginDir());
|
||||
CustomAssets::flushCache();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function writeCustom(string $relative, string $contents = '/* x */'): void
|
||||
{
|
||||
$path = $this->pluginDir().'/custom/'.$relative;
|
||||
File::ensureDirectoryExists(dirname($path));
|
||||
File::put($path, $contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* 하위 디렉토리의 글꼴·이미지까지 열거한다 — 게시와 같은 범위.
|
||||
*
|
||||
* @scenario custom_source=convention_scan, custom_asset=static_file, custom_change_detection=nested_static_file
|
||||
*
|
||||
* @effects custom_signature_covers_publishable_tree
|
||||
*/
|
||||
#[Test]
|
||||
public function 하위_디렉토리의_정적_파일까지_열거한다(): void
|
||||
{
|
||||
$this->writeCustom('custom.css');
|
||||
$this->writeCustom('fonts/x.woff2', 'font');
|
||||
$this->writeCustom('img/deep/marker.svg', '<svg/>');
|
||||
|
||||
$relatives = array_column(CustomAssets::publishableFiles('plugins', self::FAKE_PLUGIN), 'relative');
|
||||
|
||||
$this->assertSame(['custom.css', 'fonts/x.woff2', 'img/deep/marker.svg'], $relatives);
|
||||
}
|
||||
|
||||
/**
|
||||
* 허용 확장자 밖(텍스트·PHP)과 소스맵은 뺀다 — 게시 화이트리스트와 동일.
|
||||
*
|
||||
* @scenario custom_source=convention_scan, custom_asset=static_file, custom_change_detection=nested_static_file
|
||||
*
|
||||
* @effects custom_signature_covers_publishable_tree
|
||||
*/
|
||||
#[Test]
|
||||
public function 허용_확장자_밖과_소스맵은_열거하지_않는다(): void
|
||||
{
|
||||
$this->writeCustom('custom.css');
|
||||
$this->writeCustom('notes.txt', 'not an asset');
|
||||
$this->writeCustom('evil.php', '<?php');
|
||||
$this->writeCustom('custom.css.map', '{}');
|
||||
|
||||
$relatives = array_column(CustomAssets::publishableFiles('plugins', self::FAKE_PLUGIN), 'relative');
|
||||
|
||||
$this->assertSame(['custom.css'], $relatives);
|
||||
}
|
||||
|
||||
/**
|
||||
* 항목마다 절대 경로·수정 시각·크기를 싣는다 — 서명 재료이자 게시 복사 원본이다.
|
||||
*
|
||||
* @scenario custom_source=convention_scan, custom_asset=css, custom_change_detection=top_level_asset
|
||||
*
|
||||
* @effects custom_signature_covers_publishable_tree
|
||||
*/
|
||||
#[Test]
|
||||
public function 항목은_절대경로_mtime_크기를_갖는다(): void
|
||||
{
|
||||
$this->writeCustom('custom.css', '/* twelve b */');
|
||||
|
||||
$files = CustomAssets::publishableFiles('plugins', self::FAKE_PLUGIN);
|
||||
|
||||
$this->assertCount(1, $files);
|
||||
$this->assertSame('custom.css', $files[0]['relative']);
|
||||
$this->assertFileExists($files[0]['absolute']);
|
||||
$this->assertSame(14, $files[0]['size']);
|
||||
$this->assertGreaterThan(0, $files[0]['mtime']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 요청 스코프 메모이즈 — 같은 요청에서 두 번 물어도 디스크를 다시 훑지 않고, `flushCache()` 가 비운다.
|
||||
*
|
||||
* @scenario custom_source=convention_scan, custom_asset=css, custom_change_detection=no_change
|
||||
*
|
||||
* @effects custom_signature_covers_publishable_tree
|
||||
*/
|
||||
#[Test]
|
||||
public function 결과는_요청_스코프로_메모이즈되고_flush_로_비워진다(): void
|
||||
{
|
||||
$this->writeCustom('custom.css');
|
||||
|
||||
$first = CustomAssets::publishableFiles('plugins', self::FAKE_PLUGIN);
|
||||
|
||||
// 메모가 살아 있는 동안 추가한 파일은 보이지 않는다
|
||||
$this->writeCustom('fonts/x.woff2', 'font');
|
||||
$this->assertSame($first, CustomAssets::publishableFiles('plugins', self::FAKE_PLUGIN));
|
||||
|
||||
CustomAssets::flushCache();
|
||||
|
||||
$this->assertCount(2, CustomAssets::publishableFiles('plugins', self::FAKE_PLUGIN));
|
||||
}
|
||||
|
||||
/**
|
||||
* 디렉토리가 없거나 타입이 유효하지 않으면 빈 목록이다.
|
||||
*
|
||||
* @scenario custom_source=none, custom_asset=css, custom_change_detection=no_change
|
||||
*
|
||||
* @effects custom_signature_covers_publishable_tree
|
||||
*/
|
||||
#[Test]
|
||||
public function 디렉토리_부재와_무효_타입은_빈_목록이다(): void
|
||||
{
|
||||
File::deleteDirectory($this->pluginDir());
|
||||
|
||||
$this->assertSame([], CustomAssets::publishableFiles('plugins', self::FAKE_PLUGIN));
|
||||
$this->assertSame([], CustomAssets::publishableFiles('unknown', self::FAKE_PLUGIN));
|
||||
$this->assertSame([], CustomAssets::publishableFiles('plugins', '../escape'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 로드 목록(`forExtension`)은 그대로 최상위 css/js 만 싣는다 — 열거자 도입이 로드 의미를 바꾸지 않는다.
|
||||
*
|
||||
* @scenario custom_source=convention_scan, custom_asset=static_file, custom_change_detection=nested_static_file
|
||||
*
|
||||
* @effects custom_signature_covers_publishable_tree
|
||||
*/
|
||||
#[Test]
|
||||
public function 로드_목록은_여전히_최상위_css_js_만_싣는다(): void
|
||||
{
|
||||
$this->writeCustom('custom.css');
|
||||
$this->writeCustom('fonts/inner.css');
|
||||
$this->writeCustom('img/marker.svg', '<svg/>');
|
||||
|
||||
$loaded = CustomAssets::forExtension('plugins', self::FAKE_PLUGIN);
|
||||
$publishable = CustomAssets::publishableFiles('plugins', self::FAKE_PLUGIN);
|
||||
|
||||
$this->assertCount(1, $loaded);
|
||||
$this->assertStringContainsString('custom.css', $loaded[0]['url']);
|
||||
$this->assertCount(3, $publishable);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user