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
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
# 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)
|
||||
|
||||
- [x] 12 plugin 目錄結構(核心 + 11 AddOn)
|
||||
- [x] 主檔 `2meet-data-optimizer.php` + Plugin Header
|
||||
- [x] `includes/class-tmdo-bootstrap.php` stub
|
||||
- [x] `uninstall.php` stub
|
||||
- [x] `composer.json`
|
||||
- [x] `.gitignore`
|
||||
- [x] 7 件 MD(README / PLAN / CHANGELOG / DEPLOY / SECURITY / DESIGN / CLAUDE)
|
||||
|
||||
---
|
||||
|
||||
## Phase 1 ✅ — Core v0.1.0 (2026-05-15)
|
||||
|
||||
- [x] rsync 從 wp-data-optimizer 複製 ~110 個核心檔案,排除 HP/WC/LP/2meet 整合
|
||||
- [x] 檔名 `class-wpdo-*` → `class-tmdo-*`(含 abstract / interface / trait)
|
||||
- [x] sed 內容批次 rename:`WPDO_` → `TMDO_`(class + 常數,hook/table/option 前綴 `wpdo_` 保留共用)
|
||||
- [x] 常數 `TMDO_PLUGIN_DIR` → `TMDO_PATH` 等對齊
|
||||
- [x] Text-domain `'wp-data-optimizer'` → `'2meet-data-optimizer'`
|
||||
- [x] 主檔重寫成完整 loader(require chain ~150 行)
|
||||
- [x] 加 `tmdo_run()` boot 函式 + `plugins_loaded:4` action
|
||||
- [x] 加 `late-bind safety net` (priority 30) 確保 AddOn listener 收到 hook
|
||||
- [x] 加 `includes/class-tmdo-back-compat.php` — 80+ class_alias + 8 常數 alias + 9 hook dual-fire
|
||||
- [x] 移除 `register_hivepress_defaults()` (193 行) → 搬到 HP AddOn
|
||||
- [x] 把 core 內所有 HP/WC/LP 整合 class 引用加 `class_exists` 守門
|
||||
- [x] PHP lint:111 files PASS
|
||||
- [x] 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`)
|
||||
- [x] `TMDO_Hub_Bootstrap` 主啟動類別
|
||||
- [x] `TMDO_Hub_Vendor_Field` — 註冊 `_2meet_global_vendor_id` (hp_vendor / cold zone / indexed)
|
||||
- [x] `TMDO_Hub_Custom_Tables` — 註冊 12 張 `2mhc_*` 自訂表(fallback 列表 + delegate to hub-core helper if available)
|
||||
- [x] dual-emit 支援 (`tmdo_*` + `wpdo_*` 兩個 hook 路徑)
|
||||
- [x] PHP lint PASS
|
||||
|
||||
### Spoke AddOn (`2meet-data-optimizer-spoke-addon`)
|
||||
- [x] `TMDO_Spoke_Bootstrap` 主啟動類別
|
||||
- [x] `TMDO_Spoke_SSO_Group` — 註冊 user entity `sso` group(7 欄位 → wp_wpdo_user_sso)
|
||||
- [x] `TMDO_Spoke_Custom_Tables` — 註冊 `2mso_sso_config` / `2mso_user_mapping`
|
||||
- [x] `TMDO_Spoke_CLI::sync()` — 從舊 `_tmso_*` usermeta 遷移
|
||||
- [x] `TMDO_Spoke_CLI::force_logout()` — 設置 token_expires_at = 過去
|
||||
- [x] CLI 雙命名空間:`wp tmdo spoke-*` + `wp wpdo spoke-*`
|
||||
- [x] 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 行)
|
||||
- [x] 複製 13 adapter(core / reviews / bookings / messages / memberships / requests / favorites / statistics / tags / seo / social-links / blocks / marketplace)
|
||||
- [x] 複製 7 HPCT interceptor(reviews / messages / favorites / memberships / statistics / requests / listing-meta)
|
||||
- [x] 複製 5 query interceptor(reviews / messages / memberships / requests / listing-meta)
|
||||
- [x] 複製 補助組件(bootstrap framework / detector / conflict-guard / comment-router / cron-optimizer / attribute-bridge / suitability-scorer / benchmark / rest)
|
||||
- [x] 複製 admin tab + CLI namespace
|
||||
- [x] 複製 HP transient filter / HPCT import / Listing Stats / term-comment-fields
|
||||
- [x] `TMDO_HP_Bootstrap` outer bootstrap(避免與 inner family bootstrap class 衝突)
|
||||
- [x] PHP lint:46 files PASS
|
||||
|
||||
### WooCommerce AddOn (`2meet-data-optimizer-woocommerce-addon`, ~1,316 行)
|
||||
- [x] 複製 4 個 WC 整合檔
|
||||
- [x] `TMDO_Woocommerce_Bootstrap` 載入 + register
|
||||
- [x] PHP lint PASS
|
||||
|
||||
### LatePoint AddOn (`2meet-data-optimizer-latepoint-addon`, ~151 行)
|
||||
- [x] 複製 LatePoint interceptor
|
||||
- [x] `TMDO_Latepoint_Bootstrap` 載入 + register_hooks
|
||||
- [x] 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_fields` not `get_fields`) 命名不直觀
|
||||
|
||||
### Phase 3
|
||||
- HP family 內部已有 `TMDO_HivePress_Bootstrap` class(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` 已建立,bootstrap `tests/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_Stats` stub、`esc_sql` 用 `addslashes()`
|
||||
- 跳過 HP/WC/LP 專屬 test(HivePress/*、WooCommerceIntegrationTest、ListingStatsTest)
|
||||
|
||||
**Integration tests:398/398 GREEN(1139 assertions)**
|
||||
- `phpunit-integration.xml` 已建立,bootstrap `tests/integration/bootstrap.php` 完整重建
|
||||
- 35 個 integration test 檔搬遷(跳過 HivepressIntegrationTest × 3、WCTermCountFilterTest、ListingMetaInterceptorTest、TermCommentBackfillTest)
|
||||
- bootstrap 新增:`wp_upload_dir()`、`wp_mkdir_p()`、`TMDO_Listing_Stats` stub
|
||||
- 移除 `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
|
||||
Reference in New Issue
Block a user