fix(2meet-data-optimizer): skip zone deletes on tables that were never created
- TMDO_Zone_Router::delete_post() deleted from wp_wpdo_hot_/cold_{post_type}
whenever fields were registered for that zone, so every post delete on a
HivePress site (cold fields registered, module idle, table never created)
logged a "table doesn't exist" error. Hot and cold deletes now also need
the table to exist; module state is not checked, so a table left by a
rolled-back module still loses the rows of deleted posts.
- Live suite zero_side_effect: saving / updating / deleting an hp_listing
issues no query on missing zone tables (covers PR-054 and this PR).
- Verify: ZoneRouterTest 22 OK; live zero_side_effect + shadow_write +
serialized 9/9 PASS (old code: zero_side_effect FAIL); unit 687 OK,
integration 484 OK, phpcs (phpcs.xml) 0, stan OK
- PR: PR-054b
This commit is contained in:
@@ -104,7 +104,10 @@ class TMDO_Zone_Router {
|
||||
*
|
||||
* Callers only need post_id and post_type; zone enumeration and per-zone
|
||||
* error isolation are handled here. Hot and Cold are skipped when the
|
||||
* post_type has no registered fields in that zone (table may not exist).
|
||||
* post_type has no registered fields in that zone, or when the zone table
|
||||
* was never created (fields are registered long before a module runs).
|
||||
* Module state is not checked: a table left by a rolled-back module still
|
||||
* gets its rows for deleted posts removed.
|
||||
*
|
||||
* @param int $post_id Post ID being deleted.
|
||||
* @param string $post_type Post type slug.
|
||||
@@ -113,7 +116,7 @@ class TMDO_Zone_Router {
|
||||
public static function delete_post( int $post_id, string $post_type ): void {
|
||||
$registry = TMDO_Schema_Registry::instance();
|
||||
|
||||
if ( ! empty( $registry->get_hot_columns( $post_type ) ) ) {
|
||||
if ( ! empty( $registry->get_hot_columns( $post_type ) ) && TMDO_Schema_Manager::table_exists( TMDO_Zone_Hot::table( $post_type ) ) ) {
|
||||
try {
|
||||
TMDO_Zone_Hot::delete( $post_id, $post_type );
|
||||
} catch ( \Throwable $e ) {
|
||||
@@ -121,7 +124,7 @@ class TMDO_Zone_Router {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $registry->get_cold_meta_keys( $post_type ) ) ) {
|
||||
if ( ! empty( $registry->get_cold_meta_keys( $post_type ) ) && TMDO_Schema_Manager::table_exists( TMDO_Zone_Cold::table( $post_type ) ) ) {
|
||||
try {
|
||||
TMDO_Zone_Cold::delete( $post_id, $post_type );
|
||||
} catch ( \Throwable $e ) {
|
||||
|
||||
Reference in New Issue
Block a user