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:
@@ -8,18 +8,13 @@
|
||||
* Booking model (post_type=hp_booking) — fields are best-effort from the
|
||||
* addon's documented field aliases:
|
||||
*
|
||||
* start_time / end_time → unix timestamp range queries (hot)
|
||||
* status → enum filter (hot)
|
||||
* quantity → places booked, hp_quantity (hot for slot-availability;
|
||||
* only written when "Allow multiple places" is on)
|
||||
* start_time / end_time → unix timestamp range queries
|
||||
* quantity → places booked, hp_quantity (only written when
|
||||
* "Allow multiple places" is on)
|
||||
* listing → post_parent (already a posts column)
|
||||
*
|
||||
* Hot-zone target: `wp_wpdo_hot_hp_booking` with covering indexes on
|
||||
* `(listing_id, start_time)` for slot-availability queries and
|
||||
* `(status, start_time)` for vendor dashboard listings.
|
||||
*
|
||||
* The schema MAY drift from real Booking model when the addon is finally
|
||||
* installed; reconcile with `wp wpdo doctor` then.
|
||||
* These keys are flattened by the `hp_booking_core` entity group
|
||||
* (TMDO_HivePress_Entity_Groups); the adapter registers no zone fields.
|
||||
*
|
||||
* @package WP_Data_Optimizer
|
||||
* @since 3.0.0
|
||||
@@ -65,73 +60,6 @@ if ( ! class_exists( 'TMDO_HivePress_Bookings_Adapter' ) ) {
|
||||
return '1.0.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hot fields for hp_booking post type.
|
||||
*
|
||||
* @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(
|
||||
array(
|
||||
'post_type' => 'hp_booking',
|
||||
'meta_key' => 'hp_start_time',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'bigint(20) UNSIGNED NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_start_time',
|
||||
'indexed' => true,
|
||||
),
|
||||
array(
|
||||
'post_type' => 'hp_booking',
|
||||
'meta_key' => 'hp_end_time',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'bigint(20) UNSIGNED NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_end_time',
|
||||
'indexed' => true,
|
||||
),
|
||||
array(
|
||||
'post_type' => 'hp_booking',
|
||||
'meta_key' => 'hp_quantity',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'int(11) NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_quantity',
|
||||
'indexed' => false,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Doctor probe — verify hot table when addon is active.
|
||||
*
|
||||
* @return array{ok:bool, message:string}
|
||||
*/
|
||||
public function doctor_check(): array {
|
||||
global $wpdb;
|
||||
if ( ! isset( $wpdb ) || ! is_object( $wpdb ) ) {
|
||||
return array(
|
||||
'ok' => false,
|
||||
'message' => 'wpdb global not available',
|
||||
);
|
||||
}
|
||||
$table = $wpdb->prefix . 'wpdo_hot_hp_booking';
|
||||
try {
|
||||
$exists = (bool) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) );
|
||||
return array(
|
||||
'ok' => $exists,
|
||||
'message' => $exists
|
||||
? sprintf( 'hivepress-bookings: %s present', $table )
|
||||
: sprintf( 'hivepress-bookings: %s missing (addon installed but not migrated)', $table ),
|
||||
);
|
||||
} catch ( \Throwable $e ) {
|
||||
return array(
|
||||
'ok' => false,
|
||||
'message' => sprintf( 'hivepress-bookings doctor failed: %s', $e->getMessage() ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 8-D self-score.
|
||||
*
|
||||
@@ -146,15 +74,6 @@ if ( ! class_exists( 'TMDO_HivePress_Bookings_Adapter' ) ) {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* FSM modules this adapter contributes.
|
||||
*
|
||||
* @return array<int,string>
|
||||
*/
|
||||
public function migrations(): array {
|
||||
return array( 'hot_hp_booking' );
|
||||
}
|
||||
}
|
||||
|
||||
} // end if ( ! class_exists )
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
*
|
||||
* Covers the primary HivePress models:
|
||||
*
|
||||
* - `Listing` (post_type=hp_listing) — Hot zone columns for search/filter
|
||||
* (drafted, featured, verified, expired_time, featured_time).
|
||||
* - `Vendor` (post_type=hp_vendor) — Hot column `verified`; cold blob
|
||||
* for image / description (display-only).
|
||||
* - `Listing` (post_type=hp_listing) — cold blob for the gallery.
|
||||
* - `Vendor` (post_type=hp_vendor) — cold blob for the image.
|
||||
* - `User` (entity=user) — no zone fields; its `hp_user`
|
||||
* entity group is registered by TMDO_HivePress_Entity_Groups.
|
||||
*
|
||||
* Search/filter keys are flattened by TMDO_HivePress_Entity_Groups
|
||||
* (ADR-003: no Hot zone fields).
|
||||
*
|
||||
* This adapter SUPERSEDES the legacy `class-tmdo-hivepress.php` (242 lines).
|
||||
* Behavioural parity:
|
||||
*
|
||||
@@ -23,11 +24,6 @@
|
||||
* adapter only registers `hivepress` core fields.
|
||||
* - Vendor cold fields (`hp_image`, `hp_images`) — preserved.
|
||||
*
|
||||
* NEW additions vs legacy:
|
||||
*
|
||||
* - `hp_drafted` (Listing) — Hot tinyint(1) for user-dashboard filtering.
|
||||
* - `hp_expired_time` / `hp_featured_time` (Listing) — Hot bigint indexed
|
||||
* for cron expiry scan acceleration (replaces postmeta full scan).
|
||||
* (This adapter used to register a second `hp_user` definition —
|
||||
* hp_verified / hp_avatar_id, keys HivePress never writes — which the
|
||||
* registry silently dropped; TMDO_HivePress_Entity_Groups owns it now.)
|
||||
@@ -114,37 +110,10 @@ if ( ! class_exists( 'TMDO_HivePress_Core_Adapter' ) ) {
|
||||
* @param TMDO_Schema_Registry $registry Schema registry singleton.
|
||||
*/
|
||||
public function on_register_fields( TMDO_Schema_Registry $registry ): void {
|
||||
// ── Listing hot fields (search/filter accelerators) ──
|
||||
// ── Cold blobs (display-only) ──
|
||||
$registry->register_many(
|
||||
$this->plugin_slug(),
|
||||
array(
|
||||
// Drafted — used in user dashboard "my drafts" filter.
|
||||
array(
|
||||
'post_type' => 'hp_listing',
|
||||
'meta_key' => 'hp_drafted',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'tinyint(1) NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_drafted',
|
||||
'indexed' => true,
|
||||
),
|
||||
// Expired time — replaces `meta_query` clause in hourly cron.
|
||||
array(
|
||||
'post_type' => 'hp_listing',
|
||||
'meta_key' => 'hp_expired_time',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'bigint(20) UNSIGNED NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_expired_time',
|
||||
'indexed' => true,
|
||||
),
|
||||
// Featured time — same expiry pattern as above.
|
||||
array(
|
||||
'post_type' => 'hp_listing',
|
||||
'meta_key' => 'hp_featured_time',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'bigint(20) UNSIGNED NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_featured_time',
|
||||
'indexed' => true,
|
||||
),
|
||||
// Vendor cold blob — image attachment id (display-only).
|
||||
array(
|
||||
'post_type' => 'hp_vendor',
|
||||
@@ -276,57 +245,6 @@ if ( ! class_exists( 'TMDO_HivePress_Core_Adapter' ) ) {
|
||||
|
||||
// ── Doctor / score / migrations ────────────────────────────────────
|
||||
|
||||
/**
|
||||
* Health probe: verify hot tables exist + sample row count.
|
||||
*
|
||||
* @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 ( self::HOT_MODELS as $post_type ) {
|
||||
$table = $wpdb->prefix . 'wpdo_hot_' . sanitize_key( $post_type );
|
||||
try {
|
||||
$exists = (bool) $wpdb->get_var(
|
||||
$wpdb->prepare( 'SHOW TABLES LIKE %s', $table )
|
||||
);
|
||||
$details[ $post_type ] = array(
|
||||
'table' => $table,
|
||||
'exists' => $exists,
|
||||
);
|
||||
if ( $exists ) {
|
||||
$details[ $post_type ]['rows'] = (int) $wpdb->get_var(
|
||||
"SELECT COUNT(*) FROM `{$table}`" // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Sanitized via sanitize_key + wpdb prefix.
|
||||
);
|
||||
} else {
|
||||
$ok = false;
|
||||
}
|
||||
} catch ( \Throwable $e ) {
|
||||
$details[ $post_type ] = array(
|
||||
'table' => $table,
|
||||
'error' => $e->getMessage(),
|
||||
);
|
||||
$ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'ok' => $ok,
|
||||
'message' => $ok
|
||||
? 'hivepress core: hot tables OK'
|
||||
: 'hivepress core: one or more hot tables missing or unreadable',
|
||||
'details' => $details,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 8-dimension self-score for the core adapter.
|
||||
*
|
||||
@@ -348,18 +266,6 @@ if ( ! class_exists( 'TMDO_HivePress_Core_Adapter' ) ) {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* FSM modules this adapter contributes.
|
||||
*
|
||||
* @return array<int,string>
|
||||
*/
|
||||
public function migrations(): array {
|
||||
return array(
|
||||
'hot_hp_listing',
|
||||
'hot_hp_vendor',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
} // end if ( ! class_exists )
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
*
|
||||
* The marketplace addon turns listings into purchasable items, integrating
|
||||
* with WooCommerce. Its filterable, sortable listing attribute `price` is
|
||||
* stored as `hp_price` → decimal(10,2), used in price-range filters (HOT).
|
||||
* stored as `hp_price` → decimal(10,2), used in price-range filters. It is
|
||||
* flattened by the `hp_listing_core` entity group
|
||||
* (TMDO_HivePress_Entity_Groups); the adapter registers no zone fields.
|
||||
*
|
||||
* Its other listing attributes (price tiers / extras / discounts, quantity,
|
||||
* subscription period, …) are not search filters, and it keeps no per-listing
|
||||
@@ -57,57 +59,6 @@ if ( ! class_exists( 'TMDO_HivePress_Marketplace_Adapter' ) ) {
|
||||
return '1.0.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Register marketplace hot fields on the listing post type.
|
||||
*
|
||||
* @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(
|
||||
array(
|
||||
'post_type' => 'hp_listing',
|
||||
'meta_key' => 'hp_price',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'decimal(10,2) DEFAULT NULL',
|
||||
'column' => 'hp_price',
|
||||
'indexed' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Doctor probe — verify hot column exists on listing hot table.
|
||||
*
|
||||
* @return array{ok:bool, message:string}
|
||||
*/
|
||||
public function doctor_check(): array {
|
||||
global $wpdb;
|
||||
if ( ! isset( $wpdb ) || ! is_object( $wpdb ) ) {
|
||||
return array(
|
||||
'ok' => false,
|
||||
'message' => 'wpdb global not available',
|
||||
);
|
||||
}
|
||||
$table = $wpdb->prefix . 'wpdo_hot_hp_listing';
|
||||
try {
|
||||
$exists = (bool) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) );
|
||||
return array(
|
||||
'ok' => $exists,
|
||||
'message' => $exists
|
||||
? 'hivepress-marketplace: shares wp_wpdo_hot_hp_listing'
|
||||
: 'hivepress-marketplace: hot listing table missing',
|
||||
);
|
||||
} catch ( \Throwable $e ) {
|
||||
return array(
|
||||
'ok' => false,
|
||||
'message' => sprintf( 'hivepress-marketplace doctor failed: %s', $e->getMessage() ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 8-D self-score.
|
||||
*
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* Two related models:
|
||||
*
|
||||
* - Request (post_type=hp_request)
|
||||
* hot fields: hp_drafted (bool), hp_expired_time (unix ts)
|
||||
* — same access pattern as Listing (user dashboard + expiry cron)
|
||||
* hp_drafted / hp_expired_time are flattened by the `hp_draft_flags`
|
||||
* and `hp_request_core` entity groups (TMDO_HivePress_Entity_Groups).
|
||||
*
|
||||
* - Offer (comment_type=hp_offer, parent post_type=hp_request)
|
||||
* stored in comment columns only — no comment meta to flatten.
|
||||
@@ -59,74 +59,6 @@ if ( ! class_exists( 'TMDO_HivePress_Requests_Adapter' ) ) {
|
||||
public function minimum_addon_version(): string {
|
||||
return '1.2.0';
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hot fields for hp_request post type.
|
||||
*
|
||||
* @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(
|
||||
array(
|
||||
'post_type' => 'hp_request',
|
||||
'meta_key' => 'hp_drafted',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'tinyint(1) NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_drafted',
|
||||
'indexed' => true,
|
||||
),
|
||||
array(
|
||||
'post_type' => 'hp_request',
|
||||
'meta_key' => 'hp_expired_time',
|
||||
'zone' => 'hot',
|
||||
'data_type' => 'bigint(20) UNSIGNED NOT NULL DEFAULT 0',
|
||||
'column' => 'hp_expired_time',
|
||||
'indexed' => true,
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Doctor probe — request hot table.
|
||||
*
|
||||
* @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',
|
||||
);
|
||||
}
|
||||
$table = $wpdb->prefix . 'wpdo_hot_hp_request';
|
||||
try {
|
||||
$exists = (bool) $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $table ) );
|
||||
return array(
|
||||
'ok' => $exists,
|
||||
'message' => $exists
|
||||
? sprintf( 'hivepress-requests: %s present', $table )
|
||||
: sprintf( 'hivepress-requests: %s missing', $table ),
|
||||
);
|
||||
} catch ( \Throwable $e ) {
|
||||
return array(
|
||||
'ok' => false,
|
||||
'message' => sprintf( 'hivepress-requests doctor failed: %s', $e->getMessage() ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* FSM modules this adapter contributes.
|
||||
*
|
||||
* @return array<int,string>
|
||||
*/
|
||||
public function migrations(): array {
|
||||
return array( 'hot_hp_request' );
|
||||
}
|
||||
}
|
||||
|
||||
} // end if ( ! class_exists )
|
||||
|
||||
Reference in New Issue
Block a user