refactor(2meet-data-optimizer-hivepress-addon): stop registering Hot zone fields
- ADR-003 step 4 (AddOn side): core, requests, bookings, memberships and marketplace adapters no longer register zone=hot fields or contribute hot_* FSM modules; their keys live in TMDO_HivePress_Entity_Groups. Cold/warm registrations are unchanged. - Hot-table doctor probes go with them (trait defaults apply). The hot-clause query rewrite and cron optimizer are now inert and are left for the ADR step-5 removal together with core's hot path. - New NoHotZoneRegistrationTest pins the invariant across all 13 adapters; per-adapter hot assertions removed. - Verify: HP unit 142 / integration 49 green, phpcs clean (WordPress) - PR: PR-037
This commit is contained in:
@@ -5,18 +5,13 @@
|
||||
* Two post-type models:
|
||||
*
|
||||
* - Membership_Plan (post_type=hp_membership_plan)
|
||||
* hot fields: hp_expire_period (int), hp_primary (bool)
|
||||
* hp_expire_period (int), hp_primary (bool)
|
||||
*
|
||||
* - Membership (post_type=hp_membership)
|
||||
* hot fields: hp_expired_time (unix ts) — checked on every page load
|
||||
* hp_expired_time (unix ts) — checked on every page load
|
||||
*
|
||||
* Both fields registered to Hot zone so:
|
||||
* - `hp_expired_time < NOW()` lookups become indexed range scans
|
||||
* (replaces O(N) postmeta scan on each request).
|
||||
* - `hp_primary = 1` lookups for "default plan" become O(1).
|
||||
*
|
||||
* Tables `wp_wpdo_hot_hp_membership_plan` and `wp_wpdo_hot_hp_membership`
|
||||
* are created by `TMDO_Schema_Manager` from the registered hot columns.
|
||||
* Flattened by the `hp_membership_plan_core` / `hp_membership_core` entity
|
||||
* groups (TMDO_HivePress_Entity_Groups); the adapter registers no zone fields.
|
||||
*
|
||||
* @package WP_Data_Optimizer
|
||||
* @since 3.0.0
|
||||
@@ -62,81 +57,6 @@ if ( ! class_exists( 'TMDO_HivePress_Memberships_Adapter' ) ) {
|
||||
return '2.0.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hot fields for both post types.
|
||||
*
|
||||
* @param TMDO_Schema_Registry $registry Schema registry singleton.
|
||||
*/
|
||||
public function on_register_fields( TMDO_Schema_Registry $registry ): void {
|
||||
$registry->register_many(
|
||||
$this->plugin_slug(),
|
||||
array(
|
||||
// Plan fields.
|
||||
array(
|
||||
'post_type' => 'hp_membership_plan',
|
||||
'meta_key' => 'hp_expire_period',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'int(11) NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_expire_period',
|
||||
'indexed' => false,
|
||||
),
|
||||
array(
|
||||
'post_type' => 'hp_membership_plan',
|
||||
'meta_key' => 'hp_primary',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'tinyint(1) NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_primary',
|
||||
'indexed' => true,
|
||||
),
|
||||
// Membership (subscription) field — hottest path: every page load.
|
||||
array(
|
||||
'post_type' => 'hp_membership',
|
||||
'meta_key' => 'hp_expired_time',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'bigint(20) UNSIGNED NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_expired_time',
|
||||
'indexed' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Doctor probe — verify both hot tables.
|
||||
*
|
||||
* @return array{ok:bool, message:string, details?:array<string,mixed>}
|
||||
*/
|
||||
public function doctor_check(): array {
|
||||
global $wpdb;
|
||||
if ( ! isset( $wpdb ) || ! is_object( $wpdb ) ) {
|
||||
return array(
|
||||
'ok' => false,
|
||||
'message' => 'wpdb global not available',
|
||||
);
|
||||
}
|
||||
$details = array();
|
||||
$ok = true;
|
||||
foreach ( array( 'hp_membership_plan', 'hp_membership' ) as $pt ) {
|
||||
$table = $wpdb->prefix . 'wpdo_hot_' . sanitize_key( $pt );
|
||||
try {
|
||||
$exists = (bool) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) );
|
||||
$details[ $pt ]['table'] = $table;
|
||||
$details[ $pt ]['exists'] = $exists;
|
||||
if ( ! $exists ) {
|
||||
$ok = false;
|
||||
}
|
||||
} catch ( \Throwable $e ) {
|
||||
$details[ $pt ]['error'] = $e->getMessage();
|
||||
$ok = false;
|
||||
}
|
||||
}
|
||||
return array(
|
||||
'ok' => $ok,
|
||||
'message' => $ok ? 'hivepress-memberships: hot tables OK' : 'hivepress-memberships: hot tables missing',
|
||||
'details' => $details,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 8-D self-score.
|
||||
*
|
||||
@@ -152,18 +72,6 @@ if ( ! class_exists( 'TMDO_HivePress_Memberships_Adapter' ) ) {
|
||||
public function suitability_score(): array {
|
||||
return $this->compose_score( array() );
|
||||
}
|
||||
|
||||
/**
|
||||
* FSM modules this adapter contributes.
|
||||
*
|
||||
* @return array<int,string>
|
||||
*/
|
||||
public function migrations(): array {
|
||||
return array(
|
||||
'hot_hp_membership_plan',
|
||||
'hot_hp_membership',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} // end if ( ! class_exists )
|
||||
|
||||
Reference in New Issue
Block a user