41 Commits

Author SHA1 Message Date
wpdev c5027b0fce docs: CHANGELOG 補上階段 6/7 的 Admin、邊界與品質數據
Anti-EAV Lint + Quality Gate / anti-eav-lint (push) Successful in 7s
Tests / Unit Tests (push) Successful in 9s
Tests / Integration Tests (push) Successful in 36s
Tests / PHP Lint (push) Successful in 7s
Tests / PHPCS (push) Successful in 20s
Tests / PHPStan (push) Successful in 24s
2026-07-31 10:44:46 +08:00
wpdev e33ae4e626 test(boundary): 新增 CoreBoundaryTest,並補完 PR-I 的兩個缺漏測試
Anti-EAV Lint + Quality Gate / anti-eav-lint (push) Successful in 9s
Tests / Unit Tests (push) Successful in 9s
Tests / Integration Tests (push) Successful in 31s
Tests / PHP Lint (push) Successful in 8s
Tests / PHPCS (push) Successful in 20s
Tests / PHPStan (push) Successful in 24s
CoreBoundaryTest 靜態掃描核心 126 個生產檔,斷言每一處對 AddOn 類別的
static 呼叫都在同一個函式內有 class_exists() 守衛。上一個 commit 修的
TMDO_Listing_Stats fatal 就是這類缺陷,這個測試讓它不會再回來。

它當場又抓到 3 處同類違規(都是實際會 fatal 的路徑),一併修掉:
- admin render_hpct_import():改印 admin notice 並 return
- wp tmdo import-hpct:改 WP_CLI::error 明示需要 hivepress-addon
- cli-post cleanup-hp-transients 其實早有守衛,是測試的行距啟發式太窄;
  判斷範圍改成「同一個函式內」而非固定 12 行

負向驗證:暫時注入一處無守衛呼叫 → 測試如預期失敗;還原後回綠。

同時補完計畫階段 7 PR-I 列的兩個缺漏測試:
- 核心 tests/unit/StandardPostInterceptorTest.php(10 tests)
- HP AddOn tests/unit/ListingStatsTest.php(9 tests)——AddOn 的 unit
  bootstrap 先前刻意不載入真實 TMDO_Listing_Stats,改以
  TMDO_TEST_SKIP_LISTING_STATS_STUB 常數讓它跳過核心的 stub
- 核心 unit bootstrap 補 add_post_meta() stub(flush 路徑用得到)

核心 unit 451 → 587、HP AddOn 145 → 154。
2026-07-31 10:41:13 +08:00
wpdev d52d604d7a style(admin): inline style 全面改用 CSS class(PR-H)
Anti-EAV Lint + Quality Gate / anti-eav-lint (push) Successful in 8s
Tests / Unit Tests (push) Successful in 10s
Tests / Integration Tests (push) Successful in 35s
Tests / PHP Lint (push) Successful in 7s
Tests / PHPCS (push) Successful in 19s
Tests / PHPStan (push) Successful in 24s
admin/ 的 inline style= 由 348 處降到 9 處,剩下的 9 處全是 CSS custom
property 載體(--wpdo-bar-width / --wpdo-cov-pct 等動態數值),與來源外掛的
設計一致。

- wpdo-admin.css 543 → 911 行:補上 148 個 class(來源檔在 selector 與
  rule-block 層級都是既有內容的超集,逐條核對過),另加 .wpdo-form-inline
- 5 個變數改為 class 版本:$mode_cls / $badge_mode_cls / $diffs_cls /
  $ap_cls / $e_mode_cls;3 個 stress-test template 補 $mode_text_cls /
  $mode_card_cls
- 刪掉因此變成孤兒的 $mode_badge / $style / $mode_style / $badge_style /
  $e_mode_bg / $badge_bg
- entity card 改 .wpdo-eb-card、pipeline dot 改 .wpdo-stage-pill、demote 按鈕
  改 .wpdo-eb-btn-dim;.wpdo-native-counts / .wpdo-recommendation /
  .wpdo-setup-banner-btn 的重複 inline style 移除
- dashboard 的 top-views 查詢一併改用上一個 commit 的 TMDO_Zone_Warm::VIEW_KEY

PHPStan 抓出自動轉換造成的 11 個未定義變數,已全數補回定義並複驗。
2026-07-31 10:34:57 +08:00
wpdev 6751c69bc2 fix(boundary): 核心不得無守衛呼叫 AddOn 的 TMDO_Listing_Stats
實機渲染時 Dashboard 分頁 fatal:"Class TMDO_Listing_Stats not found"。
該類別住在 hivepress-addon,核心有 6 處直呼,沒裝 AddOn 的站台會炸掉
Dashboard 與兩個 REST 端點(GET /listing/{id}、POST /listing/{id}/view)。

- TMDO_Zone_Warm 新增 VIEW_KEY / VIEW_TTL 常數(值與 AddOn 的
  TMDO_Listing_Stats::VIEW_KEY 完全相同的 'wpdo_views',指向同一批列,
  無資料遷移)
- CLI benchmark 改用核心常數
- REST 兩個 handler 改走新的 read_view_count() / bump_view_count():
  AddOn 在場時仍委派過去(保留 hp_view_count postmeta fallback),
  否則核心自己讀寫 warm 列
- wp tmdo cleanup --archive-expired 加守衛,AddOn 缺席時印 warning 並跳過
2026-07-31 10:34:40 +08:00
wpdev b63ab46f54 docs: 移植 readme.txt / CONTEXT.md / docs(backport A v3.4.6)
Tests / Integration Tests (push) Successful in 1m11s
Tests / Unit Tests (push) Failing after 11m56s
Anti-EAV Lint + Quality Gate / anti-eav-lint (push) Failing after 12m7s
Tests / PHPStan (push) Failing after 14m37s
Tests / PHPCS (push) Failing after 14m46s
Tests / PHP Lint (push) Failing after 14m57s
- readme.txt(WP 外掛目錄格式,隨 ZIP 發佈):Stable tag 對齊 1.0.0,
  changelog 補 1.0.0 條目
- CONTEXT.md(領域詞彙表):Status 區塊改寫為 v1.0.0 實況;
  HPCT_INTERCEPTORS 與 HivePress Adapter 兩節標註「已搬到 AddOn,核心無此常數」
- docs/:ENTITY_ADAPTER_COOKBOOK、2 篇 ADR、INTEGRATION_PATTERN_DECISION、
  anti-eav-lint.yml.template
  - cookbook 修掉兩個死連結(ANTI_EAV_PLAYBOOK 在來源外掛就不存在)
  - INTEGRATION_PATTERN_DECISION 加 v1.0.0 後記:結論已被 AddOn 拆分取代
  - template 改 wpdev/2meet-data-optimizer + ref v1.0.0 + wp tmdo lint
- README.md 文件索引補上以上 7 個檔案

前綴改寫刻意只動類別/函式/slug(WPDO_→TMDO_、wp-data-optimizer→2meet-...),
wpdo_ option/cron/hook/表名與 wpdo/v1 REST namespace 一律保留 —— 這是資料層
零遷移的前提。
2026-07-31 10:06:03 +08:00
wpdev 2203bc471c feat(admin): Settings 分區即時儲存(backport A v3.0.2)
7 個設定分區各自加「儲存此區塊」按鈕,經 wp_ajax_wpdo_save_settings_section
以 AJAX 存檔,不再需要整頁 reload。

- 新增 ajax_save_settings_section() + 7 個 private save_section_*()
- 新增 admin/assets/wpdo-settings.js(106 行)與 4 條 CSS 規則
- render_settings() 的 7 個 h3 各包上 .wpdo-settings-section[data-section]
- 全頁送出按鈕改標「儲存全部設定」,原本的 POST handler 保持不變(漸進增強)

hp-transient / wc-term-count 兩個分區的 toggle 仍由核心 admin 呈現(實作在
AddOn),只寫 wp_options,故不需 class_exists 守衛。
2026-07-31 10:01:20 +08:00
wpdev fa356a63b1 fix(bootstrap): 舊外掛互斥偵測改查 active_plugins
Anti-EAV Lint + Quality Gate / anti-eav-lint (push) Successful in 8s
Tests / Unit Tests (push) Successful in 10s
Tests / Integration Tests (push) Successful in 33s
Tests / PHP Lint (push) Successful in 8s
Tests / PHPCS (push) Successful in 20s
Tests / PHPStan (push) Successful in 22s
Release / Test Gate (lint + phpcs + phpstan + unit + integration) (push) Successful in 1m2s
Release / release (push) Successful in 11s
WPDO_VERSION 由 class-tmdo-back-compat.php 自行 define 為 TMDO_VERSION,
兩者永遠相等,admin notice 從未觸發;PHPStan L6 認出 notIdentical.alwaysFalse
並卡掉 main run #8 與 v1.0.0 tag 的 Test Gate。改查 active_plugins basename,
與 HP AddOn detector 的偵測方式一致。
v1.0.0
2026-07-31 09:50:23 +08:00
wpdev fbe41e2130 release: v1.0.0 — 取代 wp-data-optimizer v3.4.6
Anti-EAV Lint + Quality Gate / anti-eav-lint (push) Successful in 9s
Tests / Unit Tests (push) Successful in 10s
Tests / Integration Tests (push) Successful in 33s
Tests / PHP Lint (push) Successful in 8s
Tests / PHPCS (push) Successful in 20s
Tests / PHPStan (push) Failing after 25s
Release / Test Gate (lint + phpcs + phpstan + unit + integration) (push) Failing after 36s
Release / release (push) Has been skipped
版本 0.1.0 → 1.0.0(含 TMDO_VERSION / TWO_MEET_DATA_OPTIMIZER_VERSION /
WP_DATA_OPTIMIZER_VERSION 與 unit bootstrap)。姊妹外掛只在診斷 CLI 顯示
WP_DATA_OPTIMIZER_VERSION、無版本比較,故報 1.0.0 安全。

wp-data-optimizer 退休:兩站台已停用,本機三個目錄改名為 *.retired
(wp-data-optimizer / -v3.1.1 / _audit),git 歷史保留在 gitea。

CHANGELOG 記錄本次 backport 全貌與 4 項 ABI/行為變更。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 09:45:22 +08:00
wpdev bc4fad3b86 fix(ci): packaging 步驟不可在每次 push 執行
Anti-EAV Lint + Quality Gate / anti-eav-lint (push) Successful in 10s
Tests / Unit Tests (push) Successful in 13s
Tests / Integration Tests (push) Successful in 35s
Tests / PHP Lint (push) Successful in 9s
Tests / PHPCS (push) Successful in 24s
Tests / PHPStan (push) Successful in 26s
package-plugin.sh 依 SLUG 解析到 wp-content/plugins 下的固定路徑,打包的是
線上工作副本而非 CI 的 checkout,且會在該目錄跑 composer install --no-dev
→ 每次 push 都會把開發機的 vendor/bin 清掉(本 session 中發生兩次)。

- anti-eav-lint.yml:移除 packaging 步驟,只保留 lint
- ci-package.sh:委派共用腳本後補跑 composer install 還原 dev 依賴

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 09:31:09 +08:00
wpdev c712bf6e0a ci: 觸發首次完整 CI(secret 設定後)
Anti-EAV Lint + Quality Gate / anti-eav-lint (push) Has been cancelled
Tests / Unit Tests (push) Successful in 9s
Tests / Integration Tests (push) Successful in 33s
Tests / PHP Lint (push) Successful in 9s
Tests / PHPCS (push) Successful in 21s
Tests / PHPStan (push) Successful in 24s
首次 push 早於 TMDO_TEST_DB_PASS secret 建立,integration job 的 DB
preflight 因此拿不到密碼。此空 commit 用於驗證 secret 生效後全綠。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 09:29:14 +08:00
wpdev 5e11c882aa docs(plan): 記錄 AddOn 測試基建與全家族測試現況
Anti-EAV Lint + Quality Gate / anti-eav-lint (push) Successful in 19s
Tests / Unit Tests (push) Successful in 12s
Tests / Integration Tests (push) Failing after 10s
Tests / PHP Lint (push) Successful in 11s
Tests / PHPCS (push) Successful in 23s
Tests / PHPStan (push) Failing after 11s
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 09:21:07 +08:00
wpdev c300d56aef docs(plan): 記錄打包後需重跑 composer install 的踩坑
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 09:13:14 +08:00
wpdev e246c9539e docs(plan): 更新 CI 與測試補齊進度
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 09:11:35 +08:00
wpdev 77b4501682 ci: 移植 gitea workflows + ci-package.sh(PR-I 後半)
.gitea/workflows/
- test.yml:unit / integration / lint / phpcs,外加 A 從未有過的 phpstan job。
  env 改 TMDO_TEST_DB_*(bootstrap 仍相容 WPDO_TEST_DB_*),host-mode runner
  直連本機 MariaDB,保留 A v3.4.6 的 DB preflight(區分 INFRA 失敗與測試失敗)
- anti-eav-lint.yml:TMDO_HOST 指向 dev30、改用 wp tmdo lint、slug 換成
  2meet-data-optimizer
- release.yml:v* tag 觸發,test-gate 加跑 phpstan

scripts/ci-package.sh
  依專案規範委派給共用的 scripts/package-plugin.sh(10 項終檢、統一排除清單、
  輸出 wp-local-dev/dist/),而不是自帶一份排除邏輯;找不到共用腳本時才走
  最小 fallback 並明確警告該路徑跳過終檢。

實測:bash scripts/ci-package.sh → 10 項終檢全 PASS
(552 KB / 185 entries、schema drift 34 CREATE vs 34 DROP 對齊)

註:B 目前沒有 git remote,workflow 檔案就緒但要推上 gitea 才會實際執行。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 09:11:04 +08:00
wpdev cd03d66151 test: 補 HookBus 與 audit 寫入的 integration 回歸網(PR-I)
HookBusIntegrationTest(14 tests,自 A 移植)
  integration bootstrap 原本只載入 hook-bus-bridge、沒載入 hook-bus 本體,
  所以連 WPDO_Hook_Bus alias 都建不出來 — 一併補 auto-promoter 與 hook-bus。

AuditLoggerIntegrationTest(4 tests,新寫)
  直接鎖住上一個 commit 修掉的 fatal:
  - after_write 必須寫出一列 audit(覆蓋 Logger::trace_id() 缺失)
  - group_name / action 兩欄必須有值(SCHEMA_VERSION 2.1.0 新增)
  - trace_id 必須是 UUIDv4 且同一 request 內共用
  - 未註冊的 key 不得寫入
  tearDownAfterClass 卸掉 listener 而非 drop 表,否則後續測試類的受管寫入
  會打到不存在的表;integration bootstrap 連帶補 remove_action() stub。

註:TermCommentBackfillTest 未移植 — 它 require HP AddOn 的
class-*-hivepress-term-comment-fields.php,屬 HP AddOn 測試套件而非核心。

unit 451 / integration 416 GREEN、PHPCS 0/0

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 08:55:12 +08:00
wpdev d8e7a7190a docs(plan): 記錄 dev30 實機驗證結果
A 33 OK + 15 WC MISSING → B 49 OK / All checks passed。
alias / CLI 雙命名空間 / anti-EAV 寫入 / audit 欄位 / REST allowlist
逐項實測通過;brandcards 的 doctor_callback 在新 ABI 下仍正常。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 08:30:52 +08:00
wpdev ae99820bbc fix(logger): 補回 TMDO_Logger::trace_id()(實機驗證抓到的 fatal)
TMDO_Audit_Logger::write_row() 第 160 行呼叫 TMDO_Logger::trace_id(),
但 B 提煉時漏掉了這個方法(A 有,class-wpdo-logger.php:35-47)。
先前 Audit_Logger::init() 從未被註冊,所以這個 fatal 一直藏著;
A12 把它掛上之後,任何一次受管 meta 寫入都會炸。

PHPUnit 沒有覆蓋 audit 寫入路徑,是在 dev30 實機跑
WPDO_API::set_entity() 時才暴露的。

trace_id() 產生 request-scoped UUIDv4,讓同一次請求寫出的所有 audit
row 共用同一個關聯 id。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 08:29:08 +08:00
wpdev 5385d72346 docs(plan): 標記階段 5-7 進度、列出 follow-up 與 ABI 變更
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 06:22:36 +08:00
wpdev f524ea3f16 build: 移植 PHPCS + PHPStan L6 品質 gate(PR-I 前半)
- phpcs.xml(自 A 移植):ruleset 改名、*/tools/* 例外換成 */back-compat/*、
  中文註解全域排除 Squiz.Commenting.InlineComment.InvalidEndChar、
  interface 別名檔排除 OneObjectStructurePerFile
- 檔頭正規化:16 個檔案的 declare(strict_types=1) 與前導 // 註解移到
  file docblock 之後,並移除 <?php 後多餘空行(phpcbf 另自動修 190 處)
- phpstan.neon + .phpstan/stubs.php(TMDO_ 與 WPDO_ 兩套常數)+
  重新產生的 phpstan-baseline.neon(710 errors,A 的 3877 行 baseline
  因前綴與路徑不同無法沿用)

現況:PHPCS 0 errors / 0 warnings、PHPStan L6 No errors、
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:22:00 +08:00
wpdev 76c01e44df refactor: 全部 128 個生產檔加入 declare(strict_types=1)(PR-H)
對齊 A v3.2.0。型別強制會把隱式轉換變成 TypeError,所以一次全檔加入
並跑完整測試(unit 451 / integration 398 全綠,無迴歸)。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
2026-07-31 06:13:33 +08:00
wpdev d6c1540444 feat(diagnostics): crypto 健檢 + backup 目錄探測 + 15 個 usermeta 欄位(PR-G)
- Crypto::is_key_derivable()(A v3.3.2):AUTH_KEY / SECURE_AUTH_SALT 皆缺
  時回 false,讓金鑰推導優雅短路
- wp tmdo doctor 新增兩項健檢:
  · backup 目錄 HTTP 可及性探測(200 = 紅旗並附 nginx 設定建議,
    403/404 = OK,0 = 離線時退回檢查 .htaccess)(A v3.1.9)
  · crypto 金鑰可推導性(缺常數時警告 notifier secrets 會以明文儲存)
- doctor_callback 呼叫簽章 3 參數 → 1 參數(A v3.0.3 修復)。**ABI 變更**:
  AddOn 註冊的 callback 若依賴 rows / full_name 需自行調整
- Member_Fields::register_admin_prefs_group() 由 7 欄擴到 22 欄(A v3.1.4),
  補上 wp_user_level / show_welcome_panel / wp_persisted_preferences /
  wp_user-settings / community-events-location 等 15 個 WP 原生 usermeta,
  這些先前全部落在 wp_usermeta
- capture_before_value 預設 true → false(A v3.1.5):每次受管寫入省一次
  DB read。**行為變更**:需要 value_before 的消費者(audit log)要
  add_filter( 'wpdo_capture_before_value', '__return_true' ) 明確開啟

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:11:52 +08:00
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