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 並跳過
This commit is contained in:
+12
-7
@@ -798,12 +798,12 @@ class TMDO_CLI {
|
||||
if ( ! empty( $warm_posts ) ) {
|
||||
// Seed warm zone entries so reads are non-trivial.
|
||||
foreach ( $warm_posts as $pid ) {
|
||||
TMDO_Zone_Warm::set( (int) $pid, TMDO_Listing_Stats::VIEW_KEY, '1', DAY_IN_SECONDS );
|
||||
TMDO_Zone_Warm::set( (int) $pid, TMDO_Zone_Warm::VIEW_KEY, '1', DAY_IN_SECONDS );
|
||||
}
|
||||
|
||||
$start = microtime( true );
|
||||
foreach ( $warm_posts as $pid ) {
|
||||
TMDO_Zone_Warm::get( (int) $pid, TMDO_Listing_Stats::VIEW_KEY );
|
||||
TMDO_Zone_Warm::get( (int) $pid, TMDO_Zone_Warm::VIEW_KEY );
|
||||
}
|
||||
$warm_ms = ( microtime( true ) - $start ) * 1000;
|
||||
|
||||
@@ -1148,12 +1148,17 @@ class TMDO_CLI {
|
||||
WP_CLI::log( "Deleted {$warm_deleted} expired warm entries." );
|
||||
|
||||
if ( $archive_expired ) {
|
||||
WP_CLI::log( 'Archiving expired listing fields to Zone D...' );
|
||||
$archived = TMDO_Listing_Stats::archive_expired_listings();
|
||||
WP_CLI::log( "Archived {$archived} fields from expired listings." );
|
||||
// Listing archival is HivePress-specific and ships in that AddOn.
|
||||
if ( ! class_exists( 'TMDO_Listing_Stats' ) ) {
|
||||
WP_CLI::warning( '--archive-expired needs 2meet-data-optimizer-hivepress-addon; skipping.' );
|
||||
} else {
|
||||
WP_CLI::log( 'Archiving expired listing fields to Zone D...' );
|
||||
$archived = TMDO_Listing_Stats::archive_expired_listings();
|
||||
WP_CLI::log( "Archived {$archived} fields from expired listings." );
|
||||
|
||||
$stats = TMDO_Zone_Archive::stats();
|
||||
WP_CLI::log( "Zone D total: {$stats['total_rows']} rows, {$stats['compressed_rows']} compressed." );
|
||||
$stats = TMDO_Zone_Archive::stats();
|
||||
WP_CLI::log( "Zone D total: {$stats['total_rows']} rows, {$stats['compressed_rows']} compressed." );
|
||||
}
|
||||
}
|
||||
|
||||
WP_CLI::success( 'Cleanup complete.' );
|
||||
|
||||
Reference in New Issue
Block a user