fix(core,engine): OFFSET 순회 중 필터 컬럼 변경으로 인한 처리 누락 수정

Laravel chunk/each 는 OFFSET 기반이라, 콜백이 행의 필터 소속을 바꾸면
(필터 컬럼을 채우거나 매칭 행을 삭제하면) 다음 조회가 그만큼 앞으로 밀려
미처리 행을 조용히 건너뛴다. 250건/청크 100 이면 정확히 100건이 남는다.
코어·번들 확장 전수 조사로 확정한 6곳을 chunkById(키셋 순회)로 통일했다.

브라우저 검수(28축)에서 계획에 없던 결함 12건이 드러나 같은 사슬에서
수정했다. 이 중 layout_strategy=keep 무효화와 수정 감지 실패 시 "수정 없음"
오보는 사용자 작업 소실에 직결된다.

재발 방지로 audit 룰을 추가했고, 수정 6곳을 원복해 red 6건 / 복원 후 green
0건으로 판별력을 검증했다.
This commit is contained in:
HeuJung committed 2026-07-31 21:50:45 +09:00
1 parent 1866f0d566
commit 1eedbbdda1
55 files changed
+2764 -198

No files matched your search

@@ -13,21 +13,27 @@ return new class extends Migration
public function up(): void
{
Schema::table('template_layouts', function (Blueprint $table) {
$table->string('original_content_hash', 64)
->nullable()
->after('content')
->comment('원본 레이아웃 콘텐츠 SHA-256 해시 (수정 감지용)');
$table->unsignedInteger('original_content_size')
->nullable()
->after('original_content_hash')
->comment('원본 레이아웃 콘텐츠 바이트 크기 (변화량 표시용)');
if (! Schema::hasColumn('template_layouts', 'original_content_hash')) {
$table->string('original_content_hash', 64)
->nullable()
->after('content')
->comment('원본 레이아웃 콘텐츠 SHA-256 해시 (수정 감지용)');
}
if (! Schema::hasColumn('template_layouts', 'original_content_size')) {
$table->unsignedInteger('original_content_size')
->nullable()
->after('original_content_hash')
->comment('원본 레이아웃 콘텐츠 바이트 크기 (변화량 표시용)');
}
});
// 기존 데이터 hash 백필 (현재 content = 원본으로 간주)
// chunkById(키셋 순회) 필수 — 콜백이 필터 컬럼(original_content_hash)을 채우므로
// 처리된 행이 필터 결과에서 이탈한다. OFFSET 기반 chunk() 는 그만큼 앞으로 밀려
// 미처리 행을 건너뛴다.
DB::table('template_layouts')
->whereNull('original_content_hash')
->orderBy('id')
->chunk(100, function ($layouts) {
->chunkById(100, function ($layouts) {
foreach ($layouts as $layout) {
$content = json_decode($layout->content, true);
$normalized = json_encode($content, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
@@ -28,10 +28,12 @@ return new class extends Migration
});
// 기존 데이터 hash 백필 (현재 content = 원본으로 간주)
// chunkById(키셋 순회) 필수 — 콜백이 필터 컬럼(original_content_hash)을 채우므로
// 처리된 행이 필터 결과에서 이탈한다. OFFSET 기반 chunk() 는 그만큼 앞으로 밀려
// 미처리 행을 건너뛴다.
DB::table('template_layout_extensions')
->whereNull('original_content_hash')
->orderBy('id')
->chunk(100, function ($extensions) {
->chunkById(100, function ($extensions) {
foreach ($extensions as $extension) {
$content = json_decode($extension->content, true);
$normalized = json_encode($content, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);