refactor(2meet-data-optimizer-hivepress-addon): take ownership of hp_* entity groups

- Add TMDO_HivePress_Entity_Groups registering hp_listing_core / hp_request_core / hp_vendor_core / hp_user, copied verbatim from core (same order; schema hashes match the persisted wpdo_registry_meta rows)
- Drop the core adapter's conflicting hp_user definition (hp_verified / hp_avatar_id — keys HivePress never writes)
- Verify: HivePressEntityGroupsTest (identical to core, same shared-key resolution, no collisions); HP unit 144 / integration 49 OK; hashes = dev20 registry_meta
- PR: PR-019
This commit is contained in:
2026-09-25 23:43:40 +08:00
parent ff6d6b10e4
commit 19add5fc16
7 changed files with 346 additions and 48 deletions
@@ -2,15 +2,14 @@
/**
* Core HivePress adapter — `hivepress` (the parent plugin).
*
* Owns three primary HivePress models:
* 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).
* - `User` (entity=user) — Entity group `hp_user_core` for
* `hp_verified` and the WP-stock `first_name` / `last_name` /
* `description`.
* - `User` (entity=user) — no zone fields; its `hp_user`
* entity group is registered by TMDO_HivePress_Entity_Groups.
*
* This adapter SUPERSEDES the legacy `class-tmdo-hivepress.php` (242 lines).
* Behavioural parity:
@@ -29,9 +28,9 @@
* - `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).
* - `hp_user_core` entity group — first_name / last_name / hp_verified
* promoted from usermeta to wp_wpdo_user_hp_user (already created by
* TMDO_Member_Fields v2.7.0).
* (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.)
*
* @package WP_Data_Optimizer
* @since 3.0.0
@@ -166,47 +165,6 @@ if ( ! class_exists( 'TMDO_HivePress_Core_Adapter' ) ) {
);
}
/**
* Register entity field group for HP User model.
*
* The `hp_user` group is already created by `TMDO_Member_Fields`
* (v2.7.0). We add adapter ownership here for cross-cutting tooling
* (`wp wpdo hivepress doctor` reports owner; admin UI shows source).
*
* The `register_entity_fields()` helper from `TMDO_Anti_EAV_Aware`
* delegates to `TMDO_Entity_Registry::register_group()` which has
* internal dedup — so re-registering with same group name is a no-op.
*/
public function on_register_entity_fields(): void {
if ( ! class_exists( 'TMDO_Entity_Registry' ) ) {
return;
}
// Mirror the (canonical) group definition from TMDO_Member_Fields::HP_USER_FIELDS.
// Source of truth lives in TMDO_Member_Fields; we register defensively for the
// case where Member_Fields didn't load (custom builds without that integration).
$this->register_entity_fields(
'user',
'hp_user',
array(
array(
'key' => 'hp_verified',
'type' => 'boolean',
'default' => false,
'searchable' => true,
'label' => 'HivePress KYC verified',
),
array(
'key' => 'hp_avatar_id',
'type' => 'integer',
'default' => 0,
'searchable' => false,
'label' => 'HivePress avatar attachment id',
),
)
);
}
// ── Query optimization (preserved from legacy class-tmdo-hivepress.php) ──
/**