공개 저장소 이슈 gnuboard/g7 (@bigmsg) 제보에서 출발한 작업이다. 브라우저가 화면을 그리려고 제3자 CDN 에 도달해야 하면, 그 도달 실패는 예외도 로그도 남기지 않고 화면 기능만 조용히 사라진다. 폐쇄망·방화벽·광고차단기에서 재현되는데 자체 서버 로그에는 흔적이 없어 운영자가 원인을 특정할 수 없다. 제보된 것은 편집기 하나였지만 같은 구조가 아이콘·글꼴·코드편집기·압축 라이브러리·설치 마법사·개발 대시보드에 똑같이 있었으므로, 번들 확장과 템플릿 전체를 자체 제공으로 옮겼다. 런타임에 외부로 나가는 것은 주소 검색 서비스 하나만 남았다. 자체 제공만으로는 부족하다 — 자기 서버에서 받는 파일도 실패할 수 있고, 종전에는 그 실패가 무음이었다. CSS 경로에 재시도 계층을 세우고(스크립트 경로와 동형), 서버가 HTML 에 직접 심는 externals 까지 실패를 붙잡아 안내 배너와 [다시 시도]로 표면화했다. 편집기·코드편집기는 확보 실패 시 평문 입력으로 내려앉되 저장 계약을 유지한다. 두 번째 축은 운영자가 CSS 를 덧붙일 자리가 없던 문제다(sir.kr 문의). 확장 디렉토리의 custom/ 을 운영자 소유로 정해, 확장 교체가 그 디렉토리만은 보존하게 했다. 출처에 의존하지 않는 서술자로 해석하므로 나중에 다른 출처가 붙어도 소비자는 바뀌지 않는다. 확장 자산과 같은 메커니즘으로 정적 게시되어 CSS 내부 상대 url 도 해석되고, 파일을 고치면 그 변경을 감지해 재게시까지 예약된다. FTP 접근이 없는 운영자에게는 그 자리도 없는 것과 같으므로 레이아웃 편집기에서 직접 넣고 고칠 수 있게 했다. 모듈·플러그인·템플릿이 한 엔드포인트를 공유한다 — 타입별로 나누면 같은 검증이 세 벌로 갈리고 그중 약한 하나가 우회로가 된다. 여기서 올린 스크립트는 그 레이아웃 한 장이 아니라 사이트 전 화면에서 실행되므로 레이아웃 편집과 분리된 전용 권한으로 연다. 운영자 CSS 가 화면을 조작 불능으로 만들면 그것을 고칠 화면에도 같은 CSS 가 실려 스스로 갇히므로, 서버가 목록을 비우는 탈출구(?custom=off)를 함께 뒀다. 동봉 자산은 재생성 경로에 버전 대조 가드를 붙였다. 선언과 다른 버전을 버전 디렉토리에 써 넣는 조용한 거짓말은 배포된 뒤에는 드러나지 않는다.
112 lines
3.9 KiB
PHP
112 lines
3.9 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Template;
|
|
|
|
use App\Console\Commands\Traits\HasProgressBar;
|
|
use App\Console\Commands\Traits\HasUnifiedConfirm;
|
|
use App\Contracts\Repositories\TemplateRepositoryInterface;
|
|
use App\Extension\TemplateManager;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class UninstallTemplateCommand extends Command
|
|
{
|
|
use HasProgressBar;
|
|
use HasUnifiedConfirm;
|
|
|
|
/**
|
|
* The name and signature of the console command.
|
|
*/
|
|
protected $signature = 'template:uninstall {identifier : 템플릿 식별자}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*/
|
|
protected $description = '템플릿을 삭제합니다';
|
|
|
|
/**
|
|
* 템플릿 관리자 및 리포지토리
|
|
*/
|
|
public function __construct(
|
|
private TemplateManager $templateManager,
|
|
private TemplateRepositoryInterface $templateRepository
|
|
) {
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle(): int
|
|
{
|
|
$identifier = $this->argument('identifier');
|
|
|
|
try {
|
|
// 템플릿 디렉토리 스캔 및 로드
|
|
$this->templateManager->loadTemplates();
|
|
|
|
// 템플릿 존재 확인
|
|
$template = $this->templateRepository->findByIdentifier($identifier);
|
|
|
|
if (! $template) {
|
|
$this->error('❌ '.__('templates.commands.activate.not_installed', ['template' => $identifier]));
|
|
|
|
return Command::FAILURE;
|
|
}
|
|
|
|
// 삭제 확인 프롬프트
|
|
$this->warn(__('templates.commands.uninstall.confirm_prompt', ['template' => $identifier]));
|
|
$this->warn(__('templates.commands.uninstall.confirm_details.layouts', ['count' => $template->layouts()->count()]));
|
|
$this->warn(__('templates.commands.uninstall.confirm_details.versions'));
|
|
|
|
if (! $this->unifiedConfirm(__('templates.commands.uninstall.confirm_question'), false)) {
|
|
$this->info(__('templates.commands.uninstall.aborted'));
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
|
|
// 레이아웃 및 버전 개수 조회
|
|
$layoutsCount = $template->layouts()->count();
|
|
|
|
// 템플릿 삭제
|
|
$onProgress = $this->createProgressCallback(TemplateManager::UNINSTALL_STEPS);
|
|
try {
|
|
$result = $this->templateManager->uninstallTemplate($identifier, $onProgress, $preservedBackups);
|
|
$this->finishProgress();
|
|
} catch (\Exception $e) {
|
|
$this->finishProgress();
|
|
throw $e;
|
|
}
|
|
|
|
if ($result) {
|
|
// 성공 메시지
|
|
$this->info('✅ '.__('templates.commands.uninstall.success', ['template' => $identifier]));
|
|
$this->info(' - '.__('templates.commands.uninstall.layouts_deleted', ['count' => $layoutsCount]));
|
|
|
|
// 운영자가 넣은 `custom/` 은 삭제 전에 사본을 남긴다 — 그 경로를 알리지 않으면
|
|
// 로그를 뒤지지 않는 한 사본의 존재를 알 수 없다.
|
|
foreach ($preservedBackups ?? [] as $backup) {
|
|
$this->info(' - '.__('templates.commands.uninstall.custom_preserved', [
|
|
'directory' => $backup['directory'],
|
|
'archive' => $backup['archive'],
|
|
]));
|
|
}
|
|
|
|
Log::info(__('templates.commands.uninstall.success', ['template' => $identifier]));
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
|
|
return Command::FAILURE;
|
|
} catch (\Exception $e) {
|
|
$this->error('❌ '.$e->getMessage());
|
|
Log::error('템플릿 삭제 실패', [
|
|
'template' => $identifier,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
|
|
return Command::FAILURE;
|
|
}
|
|
}
|
|
}
|