fix(2meet-data-optimizer): skip cold-zone cache warming unless the cold module is active
- TMDO_Cache_Layer::prefetch() / warm_post() (and so on_save_post /
on_loop_start) queried wp_wpdo_cold_{post_type} whenever cold fields
were registered, even with the cold module idle and the table never
created: every HivePress / WC save logged "table doesn't exist" errors.
They now return unless the module is write-active and the table exists.
- CacheLayerTest activates the module in setUp; new cases assert zero cold
queries while idle or when the table is missing.
- Verify: CacheLayerTest 12 OK; unit 671 OK, integration 480 OK,
phpcs (phpcs.xml) 0, stan OK; dev36 live: seeding listings/products/
vendors with cold_hp_listing idle → 0 wpdo_cold errors (was hundreds)
- PR: PR-054
This commit is contained in:
@@ -40,7 +40,7 @@ class TMDO_Cache_Layer {
|
||||
}
|
||||
|
||||
$cold_keys = TMDO_Schema_Registry::instance()->get_cold_meta_keys( $post_type );
|
||||
if ( empty( $cold_keys ) ) {
|
||||
if ( empty( $cold_keys ) || ! self::cold_active( $post_type ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class TMDO_Cache_Layer {
|
||||
*/
|
||||
public static function warm_post( int $post_id, string $post_type ): void {
|
||||
$cold_keys = TMDO_Schema_Registry::instance()->get_cold_meta_keys( $post_type );
|
||||
if ( empty( $cold_keys ) ) {
|
||||
if ( empty( $cold_keys ) || ! self::cold_active( $post_type ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,6 +120,19 @@ class TMDO_Cache_Layer {
|
||||
TMDO_Zone_Cold::get_blob( $post_id, $post_type );
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the cold zone holds data for this post type: its module writes
|
||||
* to the cold table and the table exists. Registered cold fields alone do
|
||||
* not mean either (zero side effect while the module is idle).
|
||||
*
|
||||
* @param string $post_type Post type.
|
||||
* @return bool
|
||||
*/
|
||||
private static function cold_active( string $post_type ): bool {
|
||||
return TMDO_Feature_Flags::is_write_active( TMDO_Zone_Router::module_name( 'cold', $post_type ) )
|
||||
&& TMDO_Schema_Manager::table_exists( TMDO_Zone_Cold::table( $post_type ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush all cold cache for a post type.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user