fix: 修復 partner 偵測時序 bug(AddOn 從未生效)+ IG meta_key 錯配 #1

Open
wpdev wants to merge 0 commits from fix/partner-detection-timing into main
Owner

本 AddOn 從未掛上任何 hook,等同未啟用(嚴重)

TMDO_Infocards::register() 舊版在 bootstrap 當下就以 class_exists('TMEETIC_*') 偵測 partner,失敗即 early return。但本 AddOn bootstrap 掛在 plugins_loaded:6,而 2meet-infocards 要到 :20(tmeetic_run)才 require 自身類別——在 :6 當下 TMEETIC_* 一律不存在,偵測必定失敗。

實測:TMEETIC_Frontend 在 prio 6 = MISSING、prio 21 = EXISTS。

三處修法

  1. 偵測從 bootstrap 移進 hook callback 內執行,hook 一律先掛上。核心於 plugins_loaded:30 有 late-bind safety net 會重新 fire,唯有延後偵測才會正確生效。
  2. 偵測改以 TMEETIC_VERSION / TMEETIC_PLUGIN_DIR 常數優先(檔案解析當下即 define,早於 plugins_loaded),class_exists() 退為後備。核心 fire_registration() 最早在 :4 觸發,該時點只有常數可用。
  3. bootstrap priority 6 → 3;wpdo_register_custom_tables callback prio 設 5。Custom_Table_Registry 對同一 provider:table_name 是「先註冊者勝」,主外掛的 closure 在檔案解析當下就掛上 prio 10,不提前會被無 expected_columns 的版本佔走 key。

同時修正 IG token 兩個欄位的 meta_key 錯配,以及 registry 索引 config key expected_indexes → indexes。

實證驗證

指標 修正前 修正後
wpdo_register_fields 掛載 從未掛上 prio 10
wpdo_register_custom_tables 掛載 從未掛上 prio 5
2meet_vendor_profiles 註冊者 主外掛(無 metadata) AddOn(16 欄位 / 1 索引 / doctor_callback)
缺 expected_columns 26/29 0/46

wp wpdo doctor 60 OK / 0 FAIL;anti-EAV lint 通過;站台 200/200。


🤖 Generated with Claude Code

**本 AddOn 從未掛上任何 hook,等同未啟用(嚴重)** `TMDO_Infocards::register()` 舊版在 bootstrap 當下就以 `class_exists('TMEETIC_*')` 偵測 partner,失敗即 early return。但本 AddOn bootstrap 掛在 `plugins_loaded:6`,而 2meet-infocards 要到 `:20`(`tmeetic_run`)才 require 自身類別——在 `:6` 當下 TMEETIC_* 一律不存在,偵測**必定**失敗。 實測:`TMEETIC_Frontend` 在 prio 6 = MISSING、prio 21 = EXISTS。 **三處修法** 1. 偵測從 bootstrap 移進 hook callback 內執行,hook 一律先掛上。核心於 `plugins_loaded:30` 有 late-bind safety net 會重新 fire,唯有延後偵測才會正確生效。 2. 偵測改以 `TMEETIC_VERSION` / `TMEETIC_PLUGIN_DIR` 常數優先(檔案解析當下即 define,早於 `plugins_loaded`),`class_exists()` 退為後備。核心 `fire_registration()` 最早在 `:4` 觸發,該時點只有常數可用。 3. bootstrap priority 6 → 3;`wpdo_register_custom_tables` callback prio 設 5。`Custom_Table_Registry` 對同一 `provider:table_name` 是「先註冊者勝」,主外掛的 closure 在檔案解析當下就掛上 prio 10,不提前會被無 `expected_columns` 的版本佔走 key。 同時修正 IG token 兩個欄位的 `meta_key` 錯配,以及 registry 索引 config key `expected_indexes` → `indexes`。 **實證驗證** | 指標 | 修正前 | 修正後 | |------|--------|--------| | `wpdo_register_fields` 掛載 | 從未掛上 | prio 10 | | `wpdo_register_custom_tables` 掛載 | 從未掛上 | prio 5 | | `2meet_vendor_profiles` 註冊者 | 主外掛(無 metadata) | AddOn(16 欄位 / 1 索引 / doctor_callback) | | 缺 `expected_columns` | 26/29 | **0/46** | `wp wpdo doctor` 60 OK / 0 FAIL;anti-EAV lint 通過;站台 200/200。 --- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
wpdev added 1 commit 2026-08-08 18:50:47 +08:00
TMDO_Infocards::register() 舊版在 bootstrap 當下以 class_exists('TMEETIC_*')
偵測 partner,失敗即 early return。但本 AddOn bootstrap 掛在 plugins_loaded:6,
而 2meet-infocards 要到 :20(tmeetic_run)才 require 自身類別——在 :6 當下
TMEETIC_* 一律不存在,偵測必定失敗,兩個註冊 hook 從未被掛上,整個 AddOn
等同未啟用。

三處修法:
1. 偵測從 bootstrap 移進 hook callback 內執行,hook 一律先掛上
2. 偵測改以 TMEETIC_VERSION / TMEETIC_PLUGIN_DIR 常數優先(檔案解析當下即
   define,早於 plugins_loaded),class_exists() 退為後備
3. bootstrap priority 6 → 3;wpdo_register_custom_tables callback prio 設 5,
   讓本 AddOn 較豐富的定義勝過主外掛無 expected_columns 的版本

同時修正 IG token 兩個欄位的 meta_key 錯配(tmeetic_ig_access_token_enc /
tmeetic_ig_token_expiry),以及 registry 索引 config key expected_indexes →
indexes。

實測驗證:
- wpdo_register_fields 掛載 prio 10、wpdo_register_custom_tables prio 5
- 2meet_vendor_profiles 由本 AddOn 註冊(16 欄位 / 1 索引 / doctor_callback)
- 缺 expected_columns 由 26/29 降為 0/46
- wp wpdo doctor 60 OK / 0 FAIL;anti-EAV lint 通過;站台 200/200
All checks were successful
Tests / PHP Lint (pull_request) Successful in 8s
Required
Details
This branch is already included in the target branch. There is nothing to merge.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/partner-detection-timing:fix/partner-detection-timing
git checkout fix/partner-detection-timing
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wpdev/2meet-data-optimizer-infocards-addon#1