wpdev
56d534619e
feat(interceptors): 核心加入 Standard_Post_Interceptor 抽象基底(F1)
...
Template Method 基底(A v3.0.1),收斂 action_delete_post /
filter_update_meta / action_insert_post 三件套。子類只需宣告
public const FIELD_MAP + get_post_type() + get_table_key() +
build_insert_data()。
HP AddOn 的 4 個 interceptor 隨即改為繼承它(573 → 344 行);未來
LatePoint / bookings / quotation 等 post↔自訂表 1:1 鏡射也可直接用。
back-compat 補 WPDO_Standard_Post_Interceptor alias。
unit 451 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 06:07:20 +08:00
wpdev
17c001e451
docs(plan): 標記階段 4 完成,補相容層 lessons
...
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 06:04:19 +08:00
wpdev
a8190a6828
fix(compat): CLI 雙命名空間 + 選單 slug 對齊 + i18n text domain(E4/E6/E7)
...
E4:38 個子指令補 'wp tmdo' 註冊(原本只有 'wp wpdo')
cli-v2 15、cli-post 8、cli-member 7、cli-term-comment 8。
CLAUDE.md 宣稱 tmdo 為主命名空間,但 wp tmdo bridge-status /
snapshot create 等先前根本不存在。
E6:MENU_SLUG 由 '2meet-data-optimizer' 改回 'wp-data-optimizer'。
B 內部有 10+ 處連結(help-tabs、setup-wizard ×5、conflict-monitor、
export、3 個 template)硬編碼舊 slug,與註冊值不符 → 這些連結目前
全部 404。既然本外掛已沿用 wpdo_ 的表/option/cron/hook/CLI 命名空間,
選單 slug 一併回到同一套最連貫,A 退休後亦無衝突。
E7:13 處殘留的 'uae' text domain 改為 '2meet-data-optimizer'
(conflict-detector 3、mode-manager 9、entity-migration-engine 1;
另一處 'uae' 是陣列 key 非 text domain,保留)。
unit 451 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 06:02:19 +08:00
wpdev
efab023289
fix(back-compat): hook 橋改雙向 + alias 表修補 + 函式 shim(E1/E2/E5)
...
E1 雙向 hook 橋
原本只做 tmdo_* → wpdo_* 單向轉發,但核心一律 do_action('wpdo_*')
(core:69,275、custom-table-registry:110、options-manager:59),
所以任何 add_action('tmdo_after_write') 之類的新契約永遠收不到事件。
改為雙向,並以 $GLOBALS['tmdo_hook_relay_active'] 共用旗標防止
A→B→A 迴圈與 listener 重複觸發。
連帶:兩個 test bootstrap 補 do_action_ref_array() stub(單向時不會走到)。
E2 alias 表
- 刪死條目 'TMDO_Notifier'(B 沒有這個類別,此行永不生效)
- 補 'TMDO_Abstract_Notifier' => 'WPDO_Abstract_Notifier'(自訂 notifier 基底)
- trait-wpdo-anti-eav-aware-alias.php 移除與 interface-wpdo-entity-adapter-alias.php
重複的 WPDO_Entity_Adapter_Interface 宣告(composer 曾警告 Ambiguous class resolution)
E5 函式 shim:wpdo_run() / wpdo_load_textdomain() 委派到 tmdo_ 版本
unit 451 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 06:00:17 +08:00
wpdev
49653667fb
docs(plan): 標記階段 3 完成,補 4 條 lessons learned
...
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:57:04 +08:00
wpdev
feac63173b
test(migration): PostMigrationTest / PostEntityLifecycleTest 補 flush_table_exists_cache
...
引入 table_exists request-scoped cache 後,其他測試類建立/drop 的 sibling
flat 表(wpdo_post_attachment)會在快取留下 stale true,diagnose() 於是
去 COUNT 一張已被 drop 的表 → mysqli_sql_exception。
A 在 v3.4.6 踩過同一個坑,修法相同:兩個測試的 setUp 呼叫
Schema_Manager::flush_table_exists_cache()。
unit 451 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:56:36 +08:00
wpdev
c46814ce83
refactor(migration): 回填 Migration Phase Strategy 體系(PR-D)
...
A v3.0.1 把 orchestrator 的 11 個 phase 抽成可注入的 Phase 物件,B 仍是
1107 行單體、以 'phase_' . $current 字串魔法分派、completed 甚至 inline
在 tick() 裡。本 commit 對齊:
新增 13 檔
- includes/migration/interface-migration-phase.php
- includes/migration/class-tmdo-migration-phase-base.php(log/get_managed_keys/
execute_bulk_pivot/values_loose_equal 等共用 helper)
- includes/migration/phases/ 11 個 phase 類別
orchestrator 1107 → 640 行
- tick() 改 make_phase() 工廠 + $phase->execute($job)
- 移除 final、self::ENTITY_TYPE → static::(A v3.3.0 late static binding)
- 保留 B 原有的 '✓ %s (%.2fs)' 耗時 log(改為 tick 自行量測,A 版已簡化掉)
- 公開介面(preflight/start/tick/get_status/cancel/resume/needs_attention/
cron_tick)經 diff 確認與 A 完全一致,呼叫端零影響
連帶
- Schema_Manager 補 table_exists 的 request-scoped cache 與
flush_table_exists_cache()(A v3.1.6 + v3.4.6),Phase 測試需要它
- back-compat 補 12 個 Phase 類別的 WPDO_ alias
- 移植 MigrationPhaseTest + MigrationPhaseRemainingTest(527 行)
測試隔離差異(B 的 unit bootstrap 會載入 Member_Fields / Post_Fields,
A 的不會):MigrationPhaseRemainingTest 的 setUp 需額外清空 Entity_Registry
與 wpdo_register_entity_fields listener,否則 install_schema 會真的走進
dbDelta。MigrationPhaseTest 的 interface 斷言改用 TMDO_ 正式名稱
(PHP 無法 class_alias 介面,且該契約是核心內部擴充點)。
unit 451 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:54:49 +08:00
wpdev
f187ac5401
refactor(zones): 回填 Zone_Router + Routing_Predicate(PR-C)
...
A v3.0.1/v3.4.0 的架構深化,B 完全缺席:
新增
- includes/zones/class-tmdo-zone-router.php:module_name / read / write /
delete_field / delete_post 五個 static 分派點
- includes/class-tmdo-routing-predicate.php:entity_bridge_owns(含
request-level cache,B 原本沒有)+ should_{write,read,query}_from_zone
+ flush_cache
改寫
- Sync_Bridge 改用兩者,移除 5 個 private wrapper(get_zone_module /
read_from_zone / write_to_zone / delete_from_zone / is_owned_by_entity_bridge)
與 44 行 inline cleanup_post → Zone_Router::delete_post 一行(400→269 行)
- Query_Router 抽出 extract_hot_clauses() public static,pre_get_posts 變薄殼
- 收斂 5 處重複的 'hot_'/'cold_' . sanitize_key()(rest-api ×3、
hot/cold-migration ×2)
- back-compat 補 WPDO_Zone_Router / WPDO_Routing_Predicate alias
測試
- 移植 ZoneRouterTest(250 行)+ RoutingPredicateTest(85 行)
- SyncBridgeEntityGuardTest 的 setUp/tearDownAfterClass 補 flush_cache(),
否則 entity_bridge_cache 會跨測試污染(A v3.4.6 踩過同一個坑)
unit 409 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:47:08 +08:00
wpdev
98774c5035
docs(plan): 標記階段 1-2 完成並記錄 lessons learned
...
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:35:54 +08:00
wpdev
caf0351294
fix(hook-bus): write_to_flat 改用 TMDO_DB::upsert(B4)
...
原本 SELECT id → UPDATE/INSERT 三步,並發寫入同一 entity 會產生
duplicate row 或互相覆蓋。改為單一 upsert(A v3.1.7 同款)。
unit 379 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:35:20 +08:00
wpdev
59f3b19ce6
fix(zone-cold): JSON_MERGE_PATCH 原子寫入 + JSON_REMOVE 原子刪除(B2)
...
set()/set_many() 原本 get_blob_raw()→array_merge→save_blob() 三步,並發
寫入會互相覆蓋整個 blob;remove() 同樣是 read-modify-write。改為:
- 新增 private save_patch():INSERT ... ON DUPLICATE KEY UPDATE
data = JSON_MERGE_PATCH(COALESCE(data,'{}'), patch)
- remove():UPDATE ... SET data = JSON_REMOVE(COALESCE(data,'{}'), '$.key')
- save_blob() 改用 TMDO_DB::upsert()
- SQLite 保留 read-modify-write fallback
- ZoneColdTest stub 補 JSON_REMOVE / JSON_MERGE_PATCH / upsert 三種 SQL 模擬
對應 A v3.3.3 P1-21。unit 379 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:34:27 +08:00
wpdev
151a14a7e8
fix(zone-warm): warm 表 UNIQUE KEY + set() 改 upsert + 原子 increment(B1/B3)
...
- CREATE TABLE wpdo_warm 的 meta_key varchar(255)→varchar(191),
KEY idx_post_meta → UNIQUE KEY ui_post_meta:沒有這個唯一鍵,
ON DUPLICATE KEY UPDATE 不會觸發,會不斷 INSERT 重複列。
(既有站台的 ALTER 遷移原本就在 installer:1329,只有 CREATE 落後)
- Zone_Warm::set() 由 SELECT→update/insert 改為 TMDO_DB::upsert()
- 新增 Zone_Warm::increment():CAST(COALESCE(meta_value,0) AS SIGNED)+N
原子計數,取代 get()+set() 的 read-modify-write race(A v3.3.3)
- ZoneWarmTest stub 與 ZoneWarmIntegrationTest 建表同步適配
unit 379 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:31:34 +08:00
wpdev
68f7f6871c
fix(admin): 13 個破壞性動作由 GET 改 POST + nonce(A1-A4)
...
nonce 走 query string 會經 Referer 外洩,且 GET 觸發的破壞性動作(刪快照、
cutover、promote aeav_only、清 postmeta)可被 prefetch/爬蟲觸發。對應 A v3.3.1 P1-6。
Handler 端(admin/class-tmdo-admin.php:300-700):13 個動作與其附屬參數
(post_type / count / mode / samples)全部改讀 $_POST。唯讀的 tab /
classify_type / wpdo_msg / wpdo_module 維持 GET。
渲染端改為 <form method=post> + wp_nonce_field():
- admin:重置速率統計、建立/清除快照、刪除快照、啟用 module
- dashboard-widget:跑健康檢查、建立快照、一鍵清理 postmeta
- post-migration-wizard:5 個步驟動作
- setup-wizard:建立 baseline snapshot
- post-stress-test:移除已無呼叫端的 legacy GET $cleanup_url
註:A 的 dashboard-widget 仍以 wp_nonce_url 產生 postmeta_cleanup 連結,
但其 handler 已只收 POST → 該按鈕在 A 是壞的;B 這邊一併改成 form。
unit 379 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:27:57 +08:00
wpdev
6e81dc51c5
fix(sync-bridge): 讀取與刪除路徑補 entity-bridge 所有權守衛(A13)
...
intercept_get / intercept_delete 先前沒有 is_owned_by_entity_bridge() 檢查,
post entity 進入 dual_write 以上時:讀路徑會用 zone 值蓋掉 Hook Bus 的值、
刪路徑會在 aeav_only 下誤刪 flat 欄位(A v3.3.3 P1-24)。
unit 379 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:22:21 +08:00
wpdev
d040400da8
fix(rest): 公開端點加上 show_in_rest 欄位 allowlist(A5/A6)
...
4 個 permission_callback => '__return_true' 的公開端點先前回傳 hot+cold
全部欄位,未註冊 show_in_rest 的私密欄位隨之外洩(A v3.3.1,CVSS 5.3)。
- Schema_Registry::register() 新增 show_in_rest 預設 true
- 新增 get_rest_visible_hot_columns() / get_rest_visible_cold_keys()
- get_listing() 以 array_intersect_key 過濾,保留 id / post_type,
並提供 wpdo_rest_listing_visible_fields / tmdo_* filter 供調整
- listings_from_zone_a() 同樣以 visible_cols 過濾
unit 379 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:21:10 +08:00
wpdev
fa31a0527b
feat(security): DDL 型別白名單 + CLI 表名守衛(A7/A8)
...
- TMDO_Installer::ALLOWED_COL_BASE_TYPES(19 型別)+ validate_col_type(),
在 ALTER TABLE ADD COLUMN 與 CREATE TABLE 組欄位前驗證:先前 partner
plugin 經 Schema Registry 提供的 $col_type 直接拼進 DDL。
- TMDO_CLI::assert_safe_table_name(),守 doctor 的 SHOW COLUMNS / PRAGMA
與 benchmark 的 COUNT(*) 三處無法 prepare 的識別字。
對應 A v3.3.4。unit 379 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:18:55 +08:00
wpdev
a0847a27bf
fix(audit,sso): audit 表補 group_name/action 欄 + 註冊 Audit_Logger + known_login_ips(A11/A12/A14)
...
- wpdo_audit CREATE 補 group_name varchar(50) 與 action varchar(20):
TMDO_Audit_Logger::write_row() 一直在寫這兩個 key,表卻沒有該欄位。
SCHEMA_VERSION 2.0.0 → 2.1.0 觸發既有站台 dbDelta ALTER;主檔與兩個
test bootstrap 的 TMDO_DB_VERSION 同步(BackCompatTest 守門要求一致)。
- TMDO_Core::run() 註冊 TMDO_Audit_Logger::init():先前完全沒掛,
wpdo_after_write / wpdo_after_delete 的稽核監聽器形同不存在。
- register_sso_group() 補 known_login_ips(A v3.4.4):2meet-spoke-sso 的
TMSO_Login_Notify 以 set_entity 寫此欄,未註冊時降級落 wp_usermeta。
對應測試改為 test_sso_group_has_eight_fields。
unit 379 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:16:33 +08:00
wpdev
f1c577df0d
fix(logger): 修正 7 處 Logger::error 參數不足導致的 TypeError(A10)
...
TMDO_Logger::error() 簽章為 (module, hook, message, context, zone),但 7 處
以 (event, array) 兩參數呼叫 → array 傳給 string $hook 觸發 TypeError:
- 4 個 stress tester 的 batch 失敗路徑
- auto-promoter 的 promote 失敗路徑
- conflict-detector 的欄位衝突路徑
- hook-bus 的 shadow 比對例外路徑(shadow_read 模式必炸)
同時 backport A v3.3.x 的 mass column clear opt-in gate(A9):
delete_all=true 改由 wpdo_allow_mass_column_clear / tmdo_allow_mass_column_clear
filter 明確放行,取代原本「>500 列才擋」的啟發式(小站一次誤呼叫即整欄 NULL)。
註:A 對應處 class-wpdo-hook-bus.php:511,522 傳 3 個 string 給
Logger::warning(string,array),A 側自身有 TypeError,故未照搬其寫法。
unit 379 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:12:45 +08:00
wpdev
e8987fafa8
docs(plan): 記錄 backport v3.0.1-v3.4.6 的 8 階段規劃與階段 0 完成
...
階段 0(回歸網)已完成:composer dev 依賴齊備、兩個 test bootstrap 補
TMDO_FSM_GUARD_DISABLED、phpunit.xml failOnWarning=true、HealthCronTest
的 SHOW TABLES/INFORMATION_SCHEMA mock 對齊 A v3.2.0。
unit 379 tests / 778 assertions GREEN
integration 398 tests / 1139 assertions GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:07:58 +08:00
wpdev
d36bb954d1
chore: initial snapshot of 2meet-data-optimizer v0.1.0
...
Baseline before backporting wp-data-optimizer v3.0.1-v3.4.6.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com >
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 05:06:36 +08:00