TMDO_Mobile_Bridge::register() 舊版偵測 TMEETMB_Plugin 類別, 在 partner 外掛中並不存在(或載入太晚),偵測實際完全靠 file_exists() 後備 撐著——程式碼讀起來像在驗證「partner 已載入」,實際只驗證了「目錄存在」。 改用 TMEETMB_VERSION / TMEETMB_PLUGIN_DIR,兩者在 partner 主檔的檔案解析當下即 define,早於 plugins_loaded,故本 AddOn bootstrap 的 :6 時點確實可用。 file_exists() 後備保留不動,行為不變;但偵測不再是死碼,即使將來移除後備也 不會重演 infocards-addon 那種「整個 AddOn 靜默失效」的事故。 同一版本另含先前未提交的 schema 工作:補齊 expected_columns / indexes, 並將 registry 索引 config key 由 expected_indexes 更正為 indexes (wp_parse_args() 會靜默丟棄未知 key,索引期望值先前等同從未送達)。 實測驗證(mu-plugin 於 plugins_loaded:6 量測真實請求): 新常數 AVAILABLE;wp wpdo doctor 89 OK / 0 FAIL;表註冊欄位與索引 100% 完整。
This commit is contained in:
@@ -19,8 +19,18 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
*/
|
||||
final class TMDO_Mobile_Bridge {
|
||||
|
||||
/**
|
||||
* 偵測以常數優先:`TMEETMB_VERSION` / `TMEETMB_PLUGIN_DIR` 在 2meet-mobile-bridge
|
||||
* 主檔的**檔案解析當下**(第 21/23 行)即 define,早於 `plugins_loaded`;本 AddOn
|
||||
* bootstrap 掛在 `plugins_loaded:6`,故此時常數已可用。
|
||||
*
|
||||
* 舊版偵測的 `TMEETMB_Plugin` 類別在 2meet-mobile-bridge 中**並不存在**,偵測實際
|
||||
* 完全靠 `file_exists()` 撐著。保留 file_exists 作最終後備,但常數檢查現在真的
|
||||
* 有效——即使將來移除後備也不會像 infocards 那樣整個 AddOn 靜默失效。
|
||||
*/
|
||||
public static function register(): void {
|
||||
$detected = class_exists( 'TMEETMB_Plugin' )
|
||||
$detected = defined( 'TMEETMB_VERSION' )
|
||||
|| defined( 'TMEETMB_PLUGIN_DIR' )
|
||||
|| file_exists( WP_PLUGIN_DIR . '/2meet-mobile-bridge/2meet-mobile-bridge.php' );
|
||||
if ( ! $detected ) {
|
||||
return;
|
||||
@@ -32,9 +42,23 @@ final class TMDO_Mobile_Bridge {
|
||||
$registry->register(
|
||||
'2meet-mobile-bridge',
|
||||
array(
|
||||
'table_name' => '2meet_refresh_tokens',
|
||||
'primary_key' => 'id',
|
||||
'post_type_link' => null,
|
||||
'table_name' => '2meet_refresh_tokens',
|
||||
'primary_key' => 'id',
|
||||
'post_type_link' => null,
|
||||
'expected_columns' => array(
|
||||
'id' => 'BIGINT',
|
||||
'token_hash' => 'CHAR',
|
||||
'user_id' => 'BIGINT',
|
||||
'expires_at' => 'DATETIME',
|
||||
'created_at' => 'DATETIME',
|
||||
'revoked_at' => 'DATETIME',
|
||||
'replaced_by' => 'CHAR',
|
||||
),
|
||||
'indexes' => array(
|
||||
'token_hash' => array( 'token_hash' ),
|
||||
'user_id' => array( 'user_id' ),
|
||||
'expires_at' => array( 'expires_at' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user