fix(core,installer): 프로세스 출력 인코딩으로 인한 JSON 빈 응답 차단
한국어 Windows 에서 whoami 가 CP949 로 출력해 계정명에 한글이 있으면 invalid UTF-8 이 응답 배열에 실리고 json_encode 가 false 를 반환한다. echo false 는 빈 문자열이라 HTTP 200 + 빈 본문이 나가는데 예외도 로그도 남지 않아, 설치 마법사 2단계가 진행 불가 상태로 멈춘다. 2026-07 수정(7.0.2)은 로그 축 4곳만 막았다. 출처에서 정규화하고(1차), 응답 경계를 단일 헬퍼로 닫고(2차), 실패 시 문제 필드 경로를 로그에 남기도록(3차) 세 층으로 처리해 다른 경로가 열린 채 남지 않게 했다. 정규화는 복원 가능한 코드페이지 출력을 먼저 되살리므로, 종전 mb_scrub 단독 처리와 달리 한글이 U+FFFD 로 훼손되지 않는다. 같은 원인으로 한국어 Windows 에서 관리자 환경설정의 시스템 정보가 500 이 되던 것도 함께 막았다.
This commit is contained in:
1 parent
f094a5f3fc
commit
01d319e74b
37 files changed
+1662
-277
No files matched your search
@@ -31,16 +31,14 @@
|
||||
* 적용하지 않음 — SSE 호환성 사전 체크(sse-probe.php) 가 buffered 환경을 감지하면
|
||||
* 클라이언트가 폴링 모드로 fallback.
|
||||
* ============================================================================
|
||||
*
|
||||
* @package G7\Installer
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../includes/config.php';
|
||||
require_once __DIR__ . '/../includes/functions.php';
|
||||
require_once __DIR__ . '/../includes/installer-state.php';
|
||||
require_once __DIR__ . '/../includes/progress-emitter.php';
|
||||
require_once __DIR__ . '/../includes/task-runner.php';
|
||||
require_once __DIR__ . '/_guard.php';
|
||||
require_once __DIR__.'/../includes/config.php';
|
||||
require_once __DIR__.'/../includes/functions.php';
|
||||
require_once __DIR__.'/../includes/installer-state.php';
|
||||
require_once __DIR__.'/../includes/progress-emitter.php';
|
||||
require_once __DIR__.'/../includes/task-runner.php';
|
||||
require_once __DIR__.'/_guard.php';
|
||||
installer_guard_or_410();
|
||||
|
||||
// SSE는 세션을 사용하지 않음 (세션 잠금 방지)
|
||||
@@ -52,7 +50,7 @@ $translations = loadTranslations($lang);
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
||||
http_response_code(405);
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode([
|
||||
echo installer_json_encode([
|
||||
'success' => false,
|
||||
'message' => lang('sse_method_not_allowed'),
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
@@ -94,14 +92,14 @@ error_reporting(E_ALL);
|
||||
|
||||
// Worker 시작 로그 (디버깅용)
|
||||
addLog('=== Install Worker SSE Started ===');
|
||||
addLog('Client IP: ' . ($_SERVER['REMOTE_ADDR'] ?? 'unknown'));
|
||||
addLog('Client IP: '.($_SERVER['REMOTE_ADDR'] ?? 'unknown'));
|
||||
|
||||
// 워커 lock 획득 — 다른 워커가 활동 중이면 진입 거부 (race 차단).
|
||||
// SSE 응답으로 거부 사유 전달 후 종료.
|
||||
$lockResult = acquireWorkerLock(15);
|
||||
if (! $lockResult['acquired']) {
|
||||
addLog('=== SSE Worker rejected — another worker is active ===');
|
||||
setProgressEmitter(new SseEmitter());
|
||||
setProgressEmitter(new SseEmitter);
|
||||
sendSSEEvent('aborted', [
|
||||
'message' => lang('error_worker_busy'),
|
||||
'reason' => 'busy',
|
||||
@@ -110,7 +108,7 @@ if (! $lockResult['acquired']) {
|
||||
}
|
||||
|
||||
$workerId = $lockResult['worker_id'];
|
||||
addLog('Worker lock acquired: ' . $workerId . ' (reason: ' . $lockResult['reason'] . ')');
|
||||
addLog('Worker lock acquired: '.$workerId.' (reason: '.$lockResult['reason'].')');
|
||||
|
||||
// 워커 종료 시 lock 자동 해제
|
||||
register_shutdown_function('releaseWorkerLock', $workerId);
|
||||
|
||||
Reference in new issue
Block a user