[Issue A] save_thing_end 脏数据写回导致幽灵 spec #15

Closed
opened 2026-04-20 13:46:53 +00:00 by sileya-ai · 0 comments

概述

save_thing_end 时机优先读 DB 旧数据,前端过滤后的数据只是 fallback。脏 config 块(template_id 指向已硬删除的场馆)被写回 DB,导致幽灵 spec 累积。

根因

AdminGoodsSaveHandle.php 第 60-65 行:
DB 值优先,fallback 才是前端已过滤值。但 DB 值本身已含脏 config。

数据流

  1. 商品曾配置场馆 A 和场馆 B,场馆 A 被硬删除
  2. 用户编辑商品 → 前端过滤掉场馆 A,只提交场馆 B
  3. save_handle 将过滤后的数据写入 data
  4. save_thing_end 从 DB 读旧数据(含场馆 A)→ 脏 config 块残留
  5. 写回 DB → 场馆 A 的脏配置被写回

修复方案

修改 1(主要修复):调换读取优先级

AdminGoodsSaveHandle.php 第 60-65 行:
data 优先,DB 值兜底

修改 2(防御层):无效 config 块移除

第 88-89 行:continue → unset(configs[i])
第 145 行后:array_values 重排索引

修改 3(防御层):写回前判空

第 148-150 行前加 if (!empty(configs))

参考资料

  • reports/GHOST_SPEC_INVESTIGATION_REPORT.md
  • reviews/council-ghost-spec-BackendArchitect.md
  • reviews/council-ghost-spec-summary.md
## 概述 save_thing_end 时机优先读 DB 旧数据,前端过滤后的数据只是 fallback。脏 config 块(template_id 指向已硬删除的场馆)被写回 DB,导致幽灵 spec 累积。 ## 根因 AdminGoodsSaveHandle.php 第 60-65 行: DB 值优先,fallback 才是前端已过滤值。但 DB 值本身已含脏 config。 ## 数据流 1. 商品曾配置场馆 A 和场馆 B,场馆 A 被硬删除 2. 用户编辑商品 → 前端过滤掉场馆 A,只提交场馆 B 3. save_handle 将过滤后的数据写入 data 4. save_thing_end 从 DB 读旧数据(含场馆 A)→ 脏 config 块残留 5. 写回 DB → 场馆 A 的脏配置被写回 ## 修复方案 ### 修改 1(主要修复):调换读取优先级 AdminGoodsSaveHandle.php 第 60-65 行: data 优先,DB 值兜底 ### 修改 2(防御层):无效 config 块移除 第 88-89 行:continue → unset(configs[i]) 第 145 行后:array_values 重排索引 ### 修改 3(防御层):写回前判空 第 148-150 行前加 if (!empty(configs)) ## 参考资料 - reports/GHOST_SPEC_INVESTIGATION_REPORT.md - reviews/council-ghost-spec-BackendArchitect.md - reviews/council-ghost-spec-summary.md
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sileya-ai/vr-shopxo-plugin#15
There is no content yet.