d36bb954d1
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
9.5 KiB
9.5 KiB
PLAN — 2meet Data Optimizer (核心)
完整四階段拆分計畫見
~/.claude/plans/wp-data-optimizer-2meet-data-optimizer-zesty-liskov.md
Current state
- Version: 0.1.0 (scaffold + 4 phase 完成 2026-05-15)
- Phase: 全 4 phase 已完成
- Source: 從
wp-data-optimizer v2.16.0提煉
Phase 0 ✅ — 骨架建立 (2026-05-15)
- 12 plugin 目錄結構(核心 + 11 AddOn)
- 主檔
2meet-data-optimizer.php+ Plugin Header includes/class-tmdo-bootstrap.phpstubuninstall.phpstubcomposer.json.gitignore- 7 件 MD(README / PLAN / CHANGELOG / DEPLOY / SECURITY / DESIGN / CLAUDE)
Phase 1 ✅ — Core v0.1.0 (2026-05-15)
- rsync 從 wp-data-optimizer 複製 ~110 個核心檔案,排除 HP/WC/LP/2meet 整合
- 檔名
class-wpdo-*→class-tmdo-*(含 abstract / interface / trait) - sed 內容批次 rename:
WPDO_→TMDO_(class + 常數,hook/table/option 前綴wpdo_保留共用) - 常數
TMDO_PLUGIN_DIR→TMDO_PATH等對齊 - Text-domain
'wp-data-optimizer'→'2meet-data-optimizer' - 主檔重寫成完整 loader(require chain ~150 行)
- 加
tmdo_run()boot 函式 +plugins_loaded:4action - 加
late-bind safety net(priority 30) 確保 AddOn listener 收到 hook - 加
includes/class-tmdo-back-compat.php— 80+ class_alias + 8 常數 alias + 9 hook dual-fire - 移除
register_hivepress_defaults()(193 行) → 搬到 HP AddOn - 把 core 內所有 HP/WC/LP 整合 class 引用加
class_exists守門 - PHP lint:111 files PASS
- Live test:
wp tmdo doctor全 PASS、wp wpdo(alias) 通
Phase 1 DoD:✅ 全達標(除舊 unit/integration test 套件需後續 phase 1 follow-up)
Phase 2 ✅ — Hub + Spoke AddOn v0.1.0 (2026-05-15)
Hub AddOn (2meet-data-optimizer-hub-addon)
TMDO_Hub_Bootstrap主啟動類別TMDO_Hub_Vendor_Field— 註冊_2meet_global_vendor_id(hp_vendor / cold zone / indexed)TMDO_Hub_Custom_Tables— 註冊 12 張2mhc_*自訂表(fallback 列表 + delegate to hub-core helper if available)- dual-emit 支援 (
tmdo_*+wpdo_*兩個 hook 路徑) - PHP lint PASS
Spoke AddOn (2meet-data-optimizer-spoke-addon)
TMDO_Spoke_Bootstrap主啟動類別TMDO_Spoke_SSO_Group— 註冊 user entityssogroup(7 欄位 → wp_wpdo_user_sso)TMDO_Spoke_Custom_Tables— 註冊2mso_sso_config/2mso_user_mappingTMDO_Spoke_CLI::sync()— 從舊_tmso_*usermeta 遷移TMDO_Spoke_CLI::force_logout()— 設置 token_expires_at = 過去- CLI 雙命名空間:
wp tmdo spoke-*+wp wpdo spoke-* - PHP lint PASS
Phase 2 Live test 結果:
- ✅ Hub: 12 hub tables 全部 OK
- ✅ Spoke: SSO group 7 fields registered, 2 tables registered
- ✅ CLI:
wp tmdo spoke-sync --dry-run跑通,spoke-force-logout --user-id=1 --dry-run跑通
Phase 3 ✅ — HP + WC + LP AddOn v0.1.0 (2026-05-15)
HivePress AddOn (2meet-data-optimizer-hivepress-addon, ~7,400 行)
- 複製 13 adapter(core / reviews / bookings / messages / memberships / requests / favorites / statistics / tags / seo / social-links / blocks / marketplace)
- 複製 7 HPCT interceptor(reviews / messages / favorites / memberships / statistics / requests / listing-meta)
- 複製 5 query interceptor(reviews / messages / memberships / requests / listing-meta)
- 複製 補助組件(bootstrap framework / detector / conflict-guard / comment-router / cron-optimizer / attribute-bridge / suitability-scorer / benchmark / rest)
- 複製 admin tab + CLI namespace
- 複製 HP transient filter / HPCT import / Listing Stats / term-comment-fields
TMDO_HP_Bootstrapouter bootstrap(避免與 inner family bootstrap class 衝突)- PHP lint:46 files PASS
WooCommerce AddOn (2meet-data-optimizer-woocommerce-addon, ~1,316 行)
- 複製 4 個 WC 整合檔
TMDO_Woocommerce_Bootstrap載入 + register- PHP lint PASS
LatePoint AddOn (2meet-data-optimizer-latepoint-addon, ~151 行)
- 複製 LatePoint interceptor
TMDO_Latepoint_Bootstrap載入 + register_hooks- PHP lint PASS
Phase 3 Live test 結果:
- ✅ Plugin 全 active
- ✅ Hot zone 20 fields registered(mostly WC product/order)
- ✅ Cold zone 3 fields
- ✅ Total 23 fields
- ✅ HP no-op when HivePress not installed(detector check)
Phase 4 ✅ — 6 個 2meet 家族 AddOn v0.1.0 (2026-05-15)
| AddOn | Source | Status |
|---|---|---|
| infocards | class-tmdo-infocards.php | ✅ |
| bookings | class-tmdo-bookings.php | ✅ |
| quotation | class-tmdo-quotation.php | ✅ |
| mobile-bridge | class-tmdo-mobile-bridge.php | ✅ |
| collab | class-tmdo-collab.php | ✅ |
| playlist | class-tmdo-playlist.php | ✅ |
每個 AddOn 都有:
TMDO_{Module}_Bootstrap啟動類別- 核心整合 class(從 wp-data-optimizer 搬入)
- partner detection (early return if target plugin not installed)
register()掛wpdo_register_fields/wpdo_register_custom_tables
Phase 4 Live test 結果:
- ✅ 6 AddOn 全 active
- ✅ Target plugin 未安裝時正確 no-op (designed behavior)
- ✅ 0 fatal、0 lint error
整體驗收(2026-05-15 末)
| 指標 | 結果 |
|---|---|
| 12 plugin active | ✅ |
| PHP lint 全 files | ✅ 203 files PASS |
wp tmdo CLI |
✅ 18 個 subcommand 全 listed |
wp wpdo alias CLI |
✅ 通 |
wp tmdo doctor |
✅ system tables 全綠 + 14 partner tables 註冊 |
wp tmdo status |
✅ 23 fields registered |
| SSO group 7 欄位 | ✅ 全 7 欄位(含 hub_global_user_id searchable) |
| Hub-addon 12 表 | ✅ 全 12 表存在 + doctor PASS |
| Spoke-addon 2 表 | ✅ 註冊 OK(DB 表 missing 是 spoke-sso 從未啟用之故) |
| WC 20 表 | ✅ 註冊 OK(DB 表 missing 是 WC 未安裝) |
| 6 family AddOn no-op | ✅ target 未安裝時正確 early return |
Lessons learned
Phase 1
- rsync 的
--exclude對tests/與tools/top-level 不生效(因為 source 路徑沒這個前綴),需後續 rm -rf 清理 - sed 全檔大寫
WPDO_→TMDO_不影響 hook/table/option 小寫前綴wpdo_,確保資料相容 - 主檔的 require chain 無法以 sed 自動產出(需手動寫,因為 require 路徑與檔名變動)
- TMDO_Core::run() 內有 8 處對「整合層 class」的硬引用,需逐個加
class_exists守門 class_alias()對 trait 與 interface 不適用(需 wrapping wrapper,留 Phase 1 follow-up)- WP 6.5+
Requires Plugins:強制檢查 Plugin Name 而非 slug;hub-core / spoke-sso 仍寫死Requires Plugins: wp-data-optimizer故無法直接啟用 → Phase 5 計畫請求 hub-core / spoke-sso 端更新或加or 2meet-data-optimizer邏輯
Phase 2
- inner Hub class
TMDO_Hub_Bootstrap需與 outer AddOn bootstrap 區分名稱(衝突避免) TMDO_Entity_Registry::register_group()是公開 API;其他 read methods (get_group_fieldsnotget_fields) 命名不直觀
Phase 3
- HP family 內部已有
TMDO_HivePress_Bootstrapclass(v3.0.0 family bootstrap),故 outer AddOn bootstrap 改名TMDO_HP_Bootstrap避免衝突
Phase 4
- 所有 family integration class 皆有 partner detection (e.g.
class_exists('TMEETIC_Plugin')) → AddOn 無需自己重複偵測
Phase 5 follow-up 執行狀態(2026-05-15)
| # | 項目 | 狀態 |
|---|---|---|
| 1 | Tests 套件搬遷:tests/unit/ 與 tests/integration/ 重命名 + path 修正 |
✅ 完成 |
| 2 | PHPCS 套件:補 phpcs.xml.dist + WordPress coding standards | ⬜ 待執行 |
| 3 | PHPUnit bootstrap:完整重建 unit/integration test 環境 | ✅ 完成 |
| 4 | DB version migration:TMDO_DB_VERSION 對齊 SCHEMA_VERSION = '2.0.0' |
✅ 完成 |
| 5 | Requires Plugins: 2meet-data-optimizer — 12 個 AddOn + brandcards header 全部更新 |
✅ 完成 |
| 6 | Trait/interface alias wrappers:Trait_TMDO_Anti_EAV_Aware 等 |
✅ 完成 |
| 7 | Doctor callback signature 修正 | ✅ 完成 |
| 8 | 打包驗收:scripts/package-plugin.sh 12 次 10 終檢 PASS |
⬜ 待執行 |
#1 + #3 完成摘要(2026-05-15)
Unit tests:373/373 GREEN(771 assertions)
phpunit.xml已建立,bootstraptests/bootstrap.php完整重建- 32 個 unit test 檔從
wp-data-optimizer搬遷,全部class-wpdo-→class-tmdo-修正 - bootstrap 新增:minimal filter registry(
$GLOBALS['_wp_filter_callbacks'])、全域 FSM bypass filter、TMDO_Listing_Statsstub、esc_sql用addslashes() - 跳過 HP/WC/LP 專屬 test(HivePress/*、WooCommerceIntegrationTest、ListingStatsTest)
Integration tests:398/398 GREEN(1139 assertions)
phpunit-integration.xml已建立,bootstraptests/integration/bootstrap.php完整重建- 35 個 integration test 檔搬遷(跳過 HivepressIntegrationTest × 3、WCTermCountFilterTest、ListingMetaInterceptorTest、TermCommentBackfillTest)
- bootstrap 新增:
wp_upload_dir()、wp_mkdir_p()、TMDO_Listing_Statsstub - 移除
WarmArchiveIntegrationTest的 listing_stats 2 個方法(需真實 HP AddOn) - 移除
RestApiIntegrationTest的 post_view increment + rate-limit 2 個方法(同上)
Git tag plan
v0.1.0— 本 release(Phase 0-4 完成)v0.1.1— Phase 5 follow-up(tests / PHPCS / packaging)v0.2.0— WPDO_ deprecation notice + wpdo → tmdo migration CLI