refactor(2meet-data-optimizer): resolve post_type/group/table mappings through the registry
- TMDO_Post_Fields::post_type_for_group() / groups_for_post_type() derive HivePress-style groups from their registry post_type scope (core keeps its own attachment / wc_product / nav_menu_item map); the three copy-pasted switches and the query router's POST_TYPE_GROUP_MAP use them - Term/comment backfill, shadow verifier and CLI take their groups from the registry (TMDO_Term_Comment_Backfill::registered_groups()); installer drops the hp_* entries already covered by its table patterns; REST listings default post type is filterable (tmdo_rest_default_post_type, default 'post') - Verify: NoHpMappingsTest guard + mapping/default tests; core unit 640 / integration 449, HP 146/49, WC 10/22 OK - PR: PR-020e
This commit is contained in:
@@ -41,23 +41,6 @@ final class TMDO_Term_Comment_Shadow_Verifier {
|
||||
/** Default sample size per entity per cron tick. */
|
||||
public const DEFAULT_SAMPLE_SIZE = 100;
|
||||
|
||||
/**
|
||||
* Group → flat table suffix mapping. Keep in sync with
|
||||
* TMDO_Hivepress_Term_Comment_Fields registrations and the misc bucket.
|
||||
*
|
||||
* @var array<string, array{entity_type:string, table_suffix:string, has_misc:bool}>
|
||||
*/
|
||||
private const GROUP_MAP = array(
|
||||
'hp_taxonomy' => array(
|
||||
'entity_type' => 'term',
|
||||
'table_suffix' => 'wpdo_term_hp_taxonomy',
|
||||
),
|
||||
'hp_review' => array(
|
||||
'entity_type' => 'comment',
|
||||
'table_suffix' => 'wpdo_comment_hp_review',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Run a sample-compare pass for a single entity group.
|
||||
*
|
||||
@@ -215,11 +198,7 @@ final class TMDO_Term_Comment_Shadow_Verifier {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
foreach ( self::GROUP_MAP as $group => $cfg ) {
|
||||
$entity_type = $cfg['entity_type'];
|
||||
|
||||
foreach ( TMDO_Term_Comment_Backfill::registered_groups() as $group => $entity_type ) {
|
||||
// Only run when the entity is in shadow_read mode.
|
||||
if ( 'term' === $entity_type && ! $term_shadow ) {
|
||||
continue;
|
||||
@@ -232,7 +211,7 @@ final class TMDO_Term_Comment_Shadow_Verifier {
|
||||
if ( empty( $keys ) ) {
|
||||
continue;
|
||||
}
|
||||
$flat_table = $wpdb->prefix . $cfg['table_suffix'];
|
||||
$flat_table = TMDO_Schema_Manager::get_table_name( $entity_type, $group );
|
||||
|
||||
try {
|
||||
self::sample_compare( $entity_type, $group, $flat_table, $keys, self::DEFAULT_SAMPLE_SIZE );
|
||||
@@ -337,16 +316,14 @@ final class TMDO_Term_Comment_Shadow_Verifier {
|
||||
return array();
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
$out = array();
|
||||
|
||||
foreach ( self::GROUP_MAP as $group => $cfg ) {
|
||||
$entity_type = $cfg['entity_type'];
|
||||
$keys = TMDO_Entity_Registry::get_group_keys( $entity_type, $group );
|
||||
foreach ( TMDO_Term_Comment_Backfill::registered_groups() as $group => $entity_type ) {
|
||||
$keys = TMDO_Entity_Registry::get_group_keys( $entity_type, $group );
|
||||
if ( empty( $keys ) ) {
|
||||
continue;
|
||||
}
|
||||
$flat_table = $wpdb->prefix . $cfg['table_suffix'];
|
||||
$flat_table = TMDO_Schema_Manager::get_table_name( $entity_type, $group );
|
||||
|
||||
try {
|
||||
$out[ $group ] = self::sample_compare( $entity_type, $group, $flat_table, $keys, $sample_size );
|
||||
|
||||
Reference in New Issue
Block a user