refactor(zones): 回填 Zone_Router + Routing_Predicate(PR-C)
A v3.0.1/v3.4.0 的架構深化,B 完全缺席:
新增
- includes/zones/class-tmdo-zone-router.php:module_name / read / write /
delete_field / delete_post 五個 static 分派點
- includes/class-tmdo-routing-predicate.php:entity_bridge_owns(含
request-level cache,B 原本沒有)+ should_{write,read,query}_from_zone
+ flush_cache
改寫
- Sync_Bridge 改用兩者,移除 5 個 private wrapper(get_zone_module /
read_from_zone / write_to_zone / delete_from_zone / is_owned_by_entity_bridge)
與 44 行 inline cleanup_post → Zone_Router::delete_post 一行(400→269 行)
- Query_Router 抽出 extract_hot_clauses() public static,pre_get_posts 變薄殼
- 收斂 5 處重複的 'hot_'/'cold_' . sanitize_key()(rest-api ×3、
hot/cold-migration ×2)
- back-compat 補 WPDO_Zone_Router / WPDO_Routing_Predicate alias
測試
- 移植 ZoneRouterTest(250 行)+ RoutingPredicateTest(85 行)
- SyncBridgeEntityGuardTest 的 setUp/tearDownAfterClass 補 flush_cache(),
否則 entity_bridge_cache 會跨測試污染(A v3.4.6 踩過同一個坑)
unit 409 / integration 398 GREEN
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TbG1keQQ7XBa7qMQY16KCY
This commit is contained in:
@@ -537,7 +537,7 @@ class TMDO_REST_API {
|
||||
$order = strtoupper( (string) ( $request->get_param( 'order' ) ?? 'DESC' ) );
|
||||
$offset = ( $page - 1 ) * $per_page;
|
||||
|
||||
$module = 'hot_' . sanitize_key( $post_type );
|
||||
$module = TMDO_Zone_Router::module_name( 'hot', $post_type );
|
||||
|
||||
if ( TMDO_Feature_Flags::is_read_custom( $module ) ) {
|
||||
return $this->listings_from_zone_a( $post_type, $per_page, $offset, $orderby, $order, $request );
|
||||
@@ -571,7 +571,7 @@ class TMDO_REST_API {
|
||||
);
|
||||
|
||||
// Zone A.
|
||||
$hot_module = 'hot_' . sanitize_key( $post_type );
|
||||
$hot_module = TMDO_Zone_Router::module_name( 'hot', $post_type );
|
||||
if ( TMDO_Feature_Flags::is_read_custom( $hot_module ) ) {
|
||||
$hot = TMDO_Zone_Hot::get_row( $post_id, $post_type );
|
||||
if ( $hot ) {
|
||||
@@ -585,7 +585,7 @@ class TMDO_REST_API {
|
||||
}
|
||||
|
||||
// Zone C.
|
||||
$cold_module = 'cold_' . sanitize_key( $post_type );
|
||||
$cold_module = TMDO_Zone_Router::module_name( 'cold', $post_type );
|
||||
if ( TMDO_Feature_Flags::is_read_custom( $cold_module ) ) {
|
||||
$cold = TMDO_Zone_Cold::get_blob( $post_id, $post_type );
|
||||
$data = array_merge( $data, $cold );
|
||||
|
||||
Reference in New Issue
Block a user