v7.0.0 release

This commit is contained in:
HeuJung committed 2026-07-01 10:30:32 +09:00
1 parent 0e7fa04b03
commit c4ea9a6cd1
3582 files changed
+626189 -160151

No files matched your search

+18 -3
View File
@@ -137,6 +137,21 @@ class ValidationApi
throw new Exception(lang('error_db_credentials_required'));
}
// DB 테이블 접두사 길이 검증 (Write DB 입력에만 적용)
// 접두사가 길면 자동 생성 인덱스명이 MySQL identifier 한도(64자)를 초과해
// 일부 확장 설치 시 마이그레이션이 실패하므로 연결 시도 전에 차단한다.
if (! $isReadDb) {
$tablePrefix = (string) ($input['db_prefix'] ?? '');
if (strlen($tablePrefix) > MAX_DB_PREFIX_LENGTH) {
throw new Exception(
lang('error_db_prefix_too_long', [
'max' => MAX_DB_PREFIX_LENGTH,
'current' => strlen($tablePrefix),
])
);
}
}
// 데이터베이스 연결 시도
$pdo = getDatabaseConnection($config, $isReadDb);
@@ -162,12 +177,12 @@ class ValidationApi
$message = lang('success_db_write_connected');
}
// 기존 테이블 감지 (Write DB만 수행 — 이슈 #244 대응)
// 기존 테이블 감지 (Write DB만 수행)
// 사용자가 입력한 db_prefix를 g7 시그니처에 적용하여 정확히 비교
$existingTables = null;
if (!$isReadDb) {
$tablePrefix = (string) ($input['db_prefix'] ?? 'g7_');
$existingTables = checkExistingTables($pdo, $database, $tablePrefix);
$detectPrefix = ($input['db_prefix'] ?? '') !== '' ? (string) $input['db_prefix'] : 'g7_';
$existingTables = checkExistingTables($pdo, $database, $detectPrefix);
}
// 성공 응답
+15 -4
View File
@@ -73,7 +73,7 @@ class StateManagementApi
// state.json 파일 실제 존재 여부 (getInstallationState는 부재 시 DEFAULT_INSTALLATION_STATE를 반환하므로
// isset($state['installation_status']) 로는 "기본 상태"와 "실제 파일 상태"를 구분할 수 없다)
$stateFileExists = file_exists(STATE_PATH);
$installedFlagPath = BASE_PATH . '/storage/app/g7_installed';
$installedFlagPath = BASE_PATH.'/storage/app/g7_installed';
// 현재 설치 상태 조회
$state = getInstallationState();
@@ -81,7 +81,7 @@ class StateManagementApi
// installation_status 값을 status로 매핑
$status = 'pending';
if (!$stateFileExists && file_exists($installedFlagPath)) {
if (! $stateFileExists && file_exists($installedFlagPath)) {
// state.json 삭제 + g7_installed 플래그 존재 → 설치 완료 후 정리된 상태
// 폴링이 완료 시점을 놓치면 이후 주기에서 이 분기로 completed 전환
$status = 'completed';
@@ -189,7 +189,7 @@ class StateManagementApi
// 상태 저장
$saved = saveInstallationState($state);
if (!$saved) {
if (! $saved) {
throw new Exception(lang('state_save_failed'));
}
@@ -280,7 +280,7 @@ class StateManagementApi
$state['abort_reason'] = 'User requested';
// 롤백 실패 정보 저장 (새로고침 후에도 표시용)
if (isset($rollbackResult['success']) && !$rollbackResult['success']) {
if (isset($rollbackResult['success']) && ! $rollbackResult['success']) {
$state['rollback_failure'] = [
'task' => $rollbackResult['task'] ?? null,
'message' => $rollbackResult['message'] ?? null,
@@ -356,6 +356,17 @@ require_once __DIR__.'/../includes/installer-state.php';
// 롤백 함수 로드 (reset, abort 액션에서 필요)
require_once __DIR__.'/rollback-functions.php';
// 설치 완료 후 진입 차단 (KVE-2026-1056)
// finalize 전용 가드 — `.env` 의 INSTALLER_COMPLETED=true 단독으로만 차단한다.
// 일반 가드(installer_guard_or_410)는 `g7_installed` 락 파일도 차단 사유로 삼는데,
// 그 락 파일은 마지막 task `complete_flag` 가 먼저 생성한다. 그 직후에도 본 엔드포인트의
// action=get 폴링(1초 간격)이 계속되어 `completed` 상태를 받아야 완료 화면으로 전환되므로,
// 락 파일 기준으로 차단하면 정상 설치가 "진행 중"에 고착되는 자가 차단 회귀가 발생한다.
// 완전 완료 신호인 `.env` 플래그를 기준으로 삼아 get/reset/abort 를
// 일괄 차단하면서 폴링 구간은 비파괴로 통과시킨다.
require_once __DIR__.'/_guard.php';
installer_guard_finalize_or_410();
// 다국어 로드
$currentLang = getCurrentLanguage();
$translations = loadTranslations($currentLang);
+12 -3
View File
@@ -987,7 +987,7 @@
const result = await response.json();
if (result.success) {
// Write DB 기존 테이블 감지: 인라인 상세 카드로 표시 (이슈 #244 대응)
// Write DB 기존 테이블 감지: 인라인 상세 카드로 표시
// 요구사항: 모달 대신 페이지 본문에 즉시 노출, 백업 동의 체크박스로
// 다음 단계 진행 여부 제어. 실제 삭제는 Step 5의 db_cleanup task에서 수행.
let existingCardHtml = '';
@@ -1149,7 +1149,7 @@
write: false,
read: false
},
// 기존 DB 테이블 감지 시 삭제 동의 추적 (이슈 #244)
// 기존 DB 테이블 감지 시 삭제 동의 추적
dbCleanup: {
required: false, // Write DB 테스트 결과 기존 테이블 감지 여부
consented: false, // 사용자가 백업 완료 + 삭제 동의 체크 여부
@@ -1450,6 +1450,15 @@
showFieldError(field, getLangMessage('validation_alpha_num_underscore').replace(':field', getLangMessage('fields.db_prefix')));
return false;
}
// 접두사 길이 제한 — 길면 자동 생성 인덱스명이 DB 한도(64자)를 초과한다.
// 서버 MAX_DB_PREFIX_LENGTH 와 동일한 값을 유지한다.
var maxPrefixLength = field.maxLength && field.maxLength > 0 ? field.maxLength : 6;
if (value.length > maxPrefixLength) {
showFieldError(field, getLangMessage('error_db_prefix_too_long')
.replace(':max', maxPrefixLength)
.replace(':current', value.length));
return false;
}
}
// 관리자 이름 검증
@@ -2978,7 +2987,7 @@
}
/**
* 기존 DB 테이블 경고 모달 표시 (이슈 #244 대응).
* 기존 DB 테이블 경고 모달 표시.
*
* DB 테스트 배지를 클릭하면 호출되며, 사용자에게 백업 안내 + 강제 진행 옵션을 제공합니다.
* "기존 테이블 모두 삭제 후 설치"를 선택하면 sessionStorage에 existing_db_action=drop_tables 저장.
+8
View File
@@ -74,6 +74,14 @@ if (!defined('MIN_DISK_SPACE_MB')) {
define('MIN_DISK_SPACE_MB', 500);
}
// DB 테이블 접두사 최대 길이.
// MySQL identifier 한도(64자) 안에서 자동 생성 인덱스명이 안전하도록 제한한다.
// 가장 긴 자동 생성 인덱스명(접두사 제외)이 58자이므로 58 + 6 = 64 로 정확히 한도에 맞는다.
// 7자 이상 접두사는 일부 인덱스명이 65자가 되어 마이그레이션이 실패한다.
if (!defined('MAX_DB_PREFIX_LENGTH')) {
define('MAX_DB_PREFIX_LENGTH', 6);
}
// 디렉토리 권한 설정 (8진수)
// 업계 표준 755 (WordPress/Drupal/Joomla/Laravel 공통) — 실제 통과 기준은 is_writable() && is_readable()
if (!defined('REQUIRED_DIRECTORY_PERMISSIONS')) {
+31 -1
View File
@@ -1191,7 +1191,7 @@ function getPermissionFixCommand(string $pathList, string $mode = 'ownership'):
/**
* 기존 DB 테이블 감지 (이슈 #244 대응).
* 기존 DB 테이블 감지.
*
* Write DB에 테이블이 존재하는지 확인하고, G7 시그니처 테이블과 비교하여
* 설치 진행 가능 여부를 판정합니다.
@@ -1256,3 +1256,33 @@ function checkExistingTables(PDO $pdo, string $database, string $tablePrefix = '
'severity' => $severity,
];
}
if (!function_exists('filterTablesByPrefix')) {
/**
* 기존 테이블 목록을 db_prefix 로 필터링합니다.
*
* drop_tables 동의의 의미는 "이 prefix 로 설치되는 G7 테이블을 지우고 다시 설치"이므로,
* 입력한 prefix 로 시작하는 테이블만 삭제 대상으로 선별합니다. prefix 가 없는
* 다른 애플리케이션/이전 설치의 테이블은 동일 DB 를 공유하더라도 보존합니다.
*
* 빈 prefix 는 전체 일치가 되어 모든 테이블이 삭제되는 위험이 있으므로,
* 데이터 손실 방어를 위해 빈 목록(삭제 대상 없음)을 반환합니다.
*
* @param array $tables SHOW TABLES 로 조회한 전체 테이블 목록
* @param string $prefix 사용자가 입력한 테이블 prefix (예: 'g7_')
* @return array prefix 로 시작하는 테이블만 담은 목록
*/
function filterTablesByPrefix(array $tables, string $prefix): array
{
if ($prefix === '') {
return [];
}
$prefixLength = strlen($prefix);
return array_values(array_filter(
$tables,
fn ($table) => strncmp((string) $table, $prefix, $prefixLength) === 0
));
}
}
+11 -3
View File
@@ -873,11 +873,14 @@ if (!function_exists('dependencyPrecheckSSE')) {
if (!function_exists('cleanupExistingTablesSSE')) {
/**
* 기존 DB 테이블 정리 (이슈 #244 대응).
* 기존 DB 테이블 정리.
*
* state.json의 existing_db_action 값에 따라 기존 테이블을 삭제합니다.
* - skip (또는 null): 작업 없이 건너뛰기
* - drop_tables: FOREIGN_KEY_CHECKS=0 → 모든 테이블 DROP → FOREIGN_KEY_CHECKS=1
* - drop_tables: FOREIGN_KEY_CHECKS=0 → db_prefix 로 시작하는 테이블만 DROP → FOREIGN_KEY_CHECKS=1
*
* prefix 없는 타 테이블까지 삭제하던 결함 수정. db_prefix 로 시작하는
* 테이블만 선별 삭제하며, 빈 prefix 는 데이터 손실 방어로 삭제를 수행하지 않는다.
*/
function cleanupExistingTablesSSE(): array
{
@@ -907,9 +910,14 @@ if (!function_exists('cleanupExistingTablesSSE')) {
try {
$pdo = getDatabaseConnection($config, false);
$database = $config['db_write_database'] ?? '';
$prefix = (string) ($config['db_prefix'] ?? 'g7_');
$stmt = $pdo->query('SHOW TABLES');
$tables = $stmt ? $stmt->fetchAll(PDO::FETCH_COLUMN) : [];
$allTables = $stmt ? $stmt->fetchAll(PDO::FETCH_COLUMN) : [];
// 입력한 db_prefix 로 시작하는 테이블만 삭제 대상으로 선별.
// prefix 없는 타 애플리케이션/이전 설치 테이블은 동일 DB 라도 보존한다.
$tables = filterTablesByPrefix($allTables, $prefix);
if (empty($tables)) {
sendSSEEvent('log', ['message' => lang('log_db_cleanup_empty')]);
+9 -8
View File
@@ -94,7 +94,7 @@ return [
'db_username' => 'Username',
'db_password' => 'Password',
'db_prefix' => 'Table Prefix',
'db_prefix_hint' => 'Prefix added to all table names. (e.g., g7_users, g7_posts)',
'db_prefix_hint' => 'Prefix added to all table names. (e.g., g7_users, g7_posts) Up to 6 characters.',
'db_prefix_placeholder' => 'g7_',
'test_write_db_connection' => 'Test Write DB Connection',
'test_read_db_connection' => 'Test Read DB Connection',
@@ -171,6 +171,7 @@ return [
'error_db_name_required' => 'Database name is required.',
'error_db_username_required' => 'Database username is required.',
'error_db_credentials_required' => 'Database name and username are required.',
'error_db_prefix_too_long' => 'Table prefix may be up to :max characters. (entered: :current) A long prefix makes some table index names exceed the database identifier limit.',
'error_db_privileges_insufficient' => 'Insufficient database privileges.',
'error_db_not_tested' => 'Please test the database connection first.',
'error_write_db_not_tested' => 'Please test Write DB connection first.',
@@ -594,7 +595,7 @@ Firewalls or proxies may be blocking long-lived HTTP connections.',
'dependency_missing_tooltip' => 'Please resolve dependencies first',
'dependency_precheck_failed' => 'Dependency precheck failed — return to Step 4 and select the missing modules/plugins',
// Step 3 existing database detection (issue #244)
// Step 3 existing database detection
'db_existing_g7_badge' => 'Existing G7 installation detected',
'db_existing_foreign_badge' => 'Foreign data detected',
'db_existing_mixed_badge' => 'Mixed G7 + foreign tables',
@@ -602,15 +603,15 @@ Firewalls or proxies may be blocking long-lived HTTP connections.',
'db_existing_foreign_title' => 'Foreign Data Detected',
'db_existing_mixed_title' => 'Mixed Data Detected',
'db_existing_generic_title' => 'Existing Tables Detected',
'db_existing_g7_desc' => 'The selected database already contains a G7 installation. Forcing the install will delete all existing data. Back up first.',
'db_existing_foreign_desc' => 'The selected database contains unknown tables. Forcing the install will drop all of them. Consider using another database or back up first.',
'db_existing_mixed_desc' => 'The selected database contains a mix of G7 and other tables. Forcing the install will drop all of them.',
'db_existing_generic_desc' => 'The selected database contains existing tables. Forcing the install will drop all of them.',
'db_existing_g7_desc' => 'The selected database already contains a G7 installation. Forcing the install will drop the existing G7 tables that start with the table prefix you entered. Back up first.',
'db_existing_foreign_desc' => 'The selected database contains unknown tables. Forcing the install will only drop tables that start with the table prefix you entered; tables with a different prefix are preserved. Back up first.',
'db_existing_mixed_desc' => 'The selected database contains a mix of G7 and other tables. Forcing the install will only drop tables that start with the table prefix you entered; tables with a different prefix are preserved.',
'db_existing_generic_desc' => 'The selected database contains existing tables. Forcing the install will only drop tables that start with the table prefix you entered.',
'db_existing_tables_list' => 'Detected tables (up to 20):',
'db_backup_guide' => 'Backup command example (verify host/user/database before running):',
'db_backup_confirmed' => 'I have backed up and agree that all existing tables will be dropped',
'db_backup_confirmed' => 'I have backed up and agree that existing tables starting with my table prefix will be dropped',
'error_db_cleanup_consent_required' => 'You must consent to dropping existing tables before proceeding to the next step.',
'db_force_proceed_drop' => 'Drop all existing tables and install',
'db_force_proceed_drop' => 'Drop existing tables and install',
'db_force_proceed_confirmed' => 'Force install mode (existing tables will be dropped)',
'log_db_cleanup_skipped' => 'Skipping existing table cleanup (no action)',
'log_db_cleanup_empty' => 'No existing tables. Skipping cleanup.',
+9 -8
View File
@@ -94,7 +94,7 @@ return [
'db_username' => '사용자명',
'db_password' => '비밀번호',
'db_prefix' => '테이블 접두사',
'db_prefix_hint' => '모든 테이블명 앞에 붙는 접두사입니다. (예: g7_users, g7_posts)',
'db_prefix_hint' => '모든 테이블명 앞에 붙는 접두사입니다. (예: g7_users, g7_posts) 최대 6자까지 입력할 수 있습니다.',
'db_prefix_placeholder' => 'g7_',
'test_write_db_connection' => 'Write DB 연결 테스트',
'test_read_db_connection' => 'Read DB 연결 테스트',
@@ -171,6 +171,7 @@ return [
'error_db_name_required' => '데이터베이스 이름은 필수입니다.',
'error_db_username_required' => '데이터베이스 사용자명을 입력해주세요.',
'error_db_credentials_required' => '데이터베이스명과 사용자명은 필수입니다.',
'error_db_prefix_too_long' => '테이블 접두사는 최대 :max자까지 가능합니다. (입력: :current자) 접두사가 길면 일부 테이블의 인덱스명이 데이터베이스 한도를 초과합니다.',
'error_db_privileges_insufficient' => '데이터베이스에 필요한 권한이 부족합니다.',
'error_db_not_tested' => '데이터베이스 연결 테스트를 먼저 수행해주세요.',
'error_write_db_not_tested' => 'Write DB 연결 테스트를 먼저 수행해주세요.',
@@ -594,7 +595,7 @@ ini_set(\'zlib.output_compression\', \'off\');
'dependency_missing_tooltip' => '의존성을 먼저 해결해주세요',
'dependency_precheck_failed' => '의존성 사전 검증 실패 — Step 4로 돌아가 누락된 모듈/플러그인을 선택해주세요',
// Step 3 기존 DB 감지 (이슈 #244)
// Step 3 기존 DB 감지
'db_existing_g7_badge' => '기존 그누보드7 설치 감지',
'db_existing_foreign_badge' => '다른 데이터 감지',
'db_existing_mixed_badge' => 'G7 일부 + 다른 테이블 혼재',
@@ -602,15 +603,15 @@ ini_set(\'zlib.output_compression\', \'off\');
'db_existing_foreign_title' => '다른 데이터 감지',
'db_existing_mixed_title' => '데이터 혼재 감지',
'db_existing_generic_title' => '기존 테이블 감지',
'db_existing_g7_desc' => '선택한 DB에 이미 그누보드7이 설치되어 있습니다. 강제 진행 시 기존 데이터가 모두 삭제됩니다. 반드시 백업 후 진행하세요.',
'db_existing_foreign_desc' => '선택한 DB에 알 수 없는 테이블이 존재합니다. 강제 진행 시 모든 테이블이 삭제됩니다. 다른 DB를 사용하거나 반드시 백업 후 진행하세요.',
'db_existing_mixed_desc' => '선택한 DB에 G7 일부 테이블과 다른 테이블이 혼재합니다. 강제 진행 시 모든 테이블이 삭제됩니다.',
'db_existing_generic_desc' => '선택한 DB에 기존 테이블이 존재합니다. 강제 진행 시 모든 테이블이 삭제됩니다.',
'db_existing_g7_desc' => '선택한 DB에 이미 그누보드7이 설치되어 있습니다. 강제 진행 시 입력한 테이블 접두사로 시작하는 기존 그누보드7 테이블이 삭제됩니다. 반드시 백업 후 진행하세요.',
'db_existing_foreign_desc' => '선택한 DB에 알 수 없는 테이블이 존재합니다. 강제 진행 시 입력한 테이블 접두사로 시작하는 테이블만 삭제되며, 접두사가 다른 테이블은 보존됩니다. 반드시 백업 후 진행하세요.',
'db_existing_mixed_desc' => '선택한 DB에 G7 일부 테이블과 다른 테이블이 혼재합니다. 강제 진행 시 입력한 테이블 접두사로 시작하는 테이블만 삭제되며, 접두사가 다른 테이블은 보존됩니다.',
'db_existing_generic_desc' => '선택한 DB에 기존 테이블이 존재합니다. 강제 진행 시 입력한 테이블 접두사로 시작하는 테이블만 삭제됩니다.',
'db_existing_tables_list' => '감지된 테이블 (최대 20개):',
'db_backup_guide' => '백업 명령어 예시 (호스트/사용자/데이터베이스명 확인 후 실행하세요):',
'db_backup_confirmed' => '백업을 완료했으며, 기존 테이블이 모두 삭제되는 것에 동의합니다',
'db_backup_confirmed' => '백업을 완료했으며, 입력한 접두사로 시작하는 기존 테이블이 삭제되는 것에 동의합니다',
'error_db_cleanup_consent_required' => '기존 테이블 삭제에 동의하셔야 다음 단계로 진행할 수 있습니다.',
'db_force_proceed_drop' => '기존 테이블 모두 삭제 후 설치',
'db_force_proceed_drop' => '기존 테이블 삭제 후 설치',
'db_force_proceed_confirmed' => '강제 진행 모드 (설치 시 기존 테이블 삭제)',
'log_db_cleanup_skipped' => '기존 테이블 정리 건너뛰기 (액션 없음)',
'log_db_cleanup_empty' => '기존 테이블이 없습니다. 정리 건너뛰기',
+1
View File
@@ -73,6 +73,7 @@ $dbReadHash = getDatabaseFieldHash($formData, 'db_read');
class="form-input"
placeholder="<?= htmlspecialchars(lang('db_prefix_placeholder')) ?>"
pattern="^[a-z][a-z0-9_]*$"
maxlength="<?= MAX_DB_PREFIX_LENGTH ?>"
aria-invalid="false"
aria-describedby="db_prefix-error db_prefix-hint">
<small id="db_prefix-hint" class="form-hint">