fix(extension): 확장 수명주기 캐시 무효화 순서 회귀 및 실패 사유 전달
route:cache 는 새 앱을 부팅해 라우트를 수집하고, 그 부팅의 확장 라우트 프로바이더는 DB 가 아니라 캐시된 활성 확장 목록을 읽는다. 그래서 rebuild 가 invalidate*StatusCache 보다 앞서면 방금 바뀐 상태가 빠진 채 라우트가 박제되고, 라우트 캐시에는 스캔 폴백이 없어 오류도 로그도 없이 404 가 된다. 무효화를 굽기 직전이 아니라 DB 상태 쓰기 직후로 올려, 같은 목록을 읽는 훅 매핑 캐시까지 함께 바로잡았다. update 경로는 Updating 전이 직후에 비우면 그 창의 오토로드 갱신이 확장을 비활성으로 판정하므로, 상태 복원 직후에 비운 뒤 훅 캐시를 다시 굽는다. 플러그인 라우트 프로바이더에는 활성 게이트가 없어 비활성 플러그인의 API 가 계속 응답했다. 화면·메뉴만 사라지고 기능은 살아 있는 상태였다. 모듈과 같은 기준을 적용했다. 실패 사유가 하위 계층에서 버려져 관리자 화면에 :error 자리표시자가 그대로 노출되던 문제도 고쳤다. 반환 경로를 깨지 않도록 배열 키 reason 과 뒤에 붙인 선택적 out 파라미터로 사유를 실어 올리고, 확장이 수명주기 훅에서 사유를 남길 수 있는 통로를 추가했다. 설치 경로의 광역 RuntimeException catch 는 도메인 예외로 좁혀 원본 키와 파라미터를 응답에 싣는다 — 상태코드 422 는 유지해 사용자 계약을 함께 바꾸지 않는다. 언어팩 화면은 프로덕션에서 예외 원문을 싣지 않는 것이 확정된 계약이므로, 자리를 일반 문구로 채우는 대신 치환 자리 자체를 제거했다. 원문은 종전대로 errors 통로를 거쳐 디버그 모드에서 도달한다.
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Contracts\Extension\PluginManagerInterface;
|
||||
use App\Contracts\Extension\TemplateManagerInterface;
|
||||
use App\Contracts\Repositories\LayoutVersionRepositoryInterface;
|
||||
use App\Contracts\Repositories\TemplateRepositoryInterface;
|
||||
use App\Enums\DeactivationReason;
|
||||
use App\Enums\ExtensionStatus;
|
||||
use App\Exceptions\TemplateNotFoundException;
|
||||
use App\Exceptions\TemplateOperationException;
|
||||
@@ -476,12 +477,15 @@ class TemplateService
|
||||
* 템플릿을 비활성화합니다.
|
||||
*
|
||||
* @param int|string $idOrIdentifier 템플릿 ID 또는 식별자
|
||||
* @param string|null $failureReason 실패 시 사유가 담기는 out 파라미터 (성공 시 null)
|
||||
* @return array|null 비활성화된 템플릿 정보 또는 null
|
||||
*
|
||||
* @throws ValidationException 비활성화 실패 시
|
||||
*/
|
||||
public function deactivateTemplate(int|string $idOrIdentifier): ?array
|
||||
public function deactivateTemplate(int|string $idOrIdentifier, ?string &$failureReason = null): ?array
|
||||
{
|
||||
$failureReason = null;
|
||||
|
||||
// ID 또는 identifier로 템플릿 조회
|
||||
$template = is_int($idOrIdentifier)
|
||||
? $this->templateRepository->findById($idOrIdentifier)
|
||||
@@ -496,7 +500,14 @@ class TemplateService
|
||||
HookManager::doAction('core.templates.before_deactivate', $template->identifier);
|
||||
|
||||
try {
|
||||
$result = $this->templateManager->deactivateTemplate($template->identifier);
|
||||
// 위치 인자로 넘긴다 — 이 의존성은 인터페이스 타입이고 테스트가 그 인터페이스를
|
||||
// mock 하므로, 이름 붙인 인자는 mock 의 __call 에 닿아 "Unknown named parameter" 가 된다.
|
||||
$result = $this->templateManager->deactivateTemplate(
|
||||
$template->identifier,
|
||||
DeactivationReason::Manual->value,
|
||||
null,
|
||||
$failureReason
|
||||
);
|
||||
|
||||
if ($result) {
|
||||
// 템플릿 매니저에서 업데이트된 정보 조회
|
||||
@@ -2021,7 +2032,11 @@ class TemplateService
|
||||
$result = $this->templateManager->installTemplate($identifier);
|
||||
|
||||
if (! $result) {
|
||||
throw new TemplateOperationException('templates.errors.install_failed');
|
||||
// installTemplate 은 사유 out 파라미터를 갖지 않으므로 일반 문구로 채운다.
|
||||
// 비워 두면 치환 자리가 남아 관리자 화면에 리터럴 ':error' 가 노출된다.
|
||||
throw new TemplateOperationException('templates.errors.install_failed', [
|
||||
'error' => __('templates.errors.unknown_error'),
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->templateManager->getTemplateInfo($identifier);
|
||||
|
||||
Reference in New Issue
Block a user