refactor(2meet-data-optimizer): stop registering the wc_product post group
- WooCommerce reads product meta directly and writes stock by SQL, so a flat copy drifted (R-2.1 V1 T4); product meta now stays in native only (plan decision 2). TMDO_Post_Fields registers wp_core, attachment and nav_menu_item. Existing wp_wpdo_post_wc_product tables are left in place and still dropped on uninstall; the orphan restore registers nothing for them while native meta holds the keys; `wp tmdo bridge-restore-native post --group=wc_product --retire` archives them. - Tests that route products register the former group themselves (tmdo_test_register_wc_product_group(), same name and table); live router Q06 runs on wp_core's _wp_page_template instead of _sku. The post stress tester already skips flat tables that do not exist. - Verify: PostFieldsRegistrationTest (RED before); dev36: wc_product absent from the registry and not restored as an orphan, a CLI order took stock 452 → 450 in native with no DB error (reverted), drift post 10 groups 0. - PR: PR-077
This commit is contained in:
@@ -33,13 +33,12 @@ class PostFieldsRegistrationTest extends TestCase {
|
||||
$this->assertTrue( true );
|
||||
}
|
||||
|
||||
public function test_all_four_groups_are_registered(): void {
|
||||
public function test_the_core_groups_are_registered(): void {
|
||||
WPDO_Post_Fields::register_entity_fields();
|
||||
|
||||
$expected = array(
|
||||
'wp_core',
|
||||
'attachment',
|
||||
'wc_product',
|
||||
'nav_menu_item',
|
||||
);
|
||||
|
||||
@@ -92,38 +91,14 @@ class PostFieldsRegistrationTest extends TestCase {
|
||||
$this->assertSame( 'json', $field['type'] );
|
||||
}
|
||||
|
||||
// ── wc_product group ─────────────────────────────────────────────────────
|
||||
// ── WooCommerce products stay in native meta (2.2 PR-077) ───────────────
|
||||
|
||||
public function test_wc_product_group_has_19_keys(): void {
|
||||
public function test_core_registers_no_woocommerce_product_group(): void {
|
||||
WPDO_Post_Fields::register_entity_fields();
|
||||
$keys = $this->get_field_keys( 'wc_product' );
|
||||
$this->assertCount( 19, $keys, 'wc_product group should register exactly 19 keys.' );
|
||||
}
|
||||
|
||||
public function test_wc_product_critical_keys_present(): void {
|
||||
WPDO_Post_Fields::register_entity_fields();
|
||||
$keys = $this->get_field_keys( 'wc_product' );
|
||||
foreach ( array( '_price', '_regular_price', '_sale_price', '_stock', '_stock_status', '_sku' ) as $key ) {
|
||||
$this->assertContains( $key, $keys, "wc_product missing critical key: {$key}" );
|
||||
}
|
||||
}
|
||||
|
||||
public function test_wc_product_price_is_searchable_decimal(): void {
|
||||
WPDO_Post_Fields::register_entity_fields();
|
||||
$field = $this->find_field( 'wc_product', '_price' );
|
||||
$this->assertNotNull( $field );
|
||||
$this->assertSame( 'decimal', $field['type'] );
|
||||
$this->assertTrue( (bool) ( $field['searchable'] ?? false ) );
|
||||
}
|
||||
|
||||
public function test_wc_product_stock_status_is_enum_searchable(): void {
|
||||
WPDO_Post_Fields::register_entity_fields();
|
||||
$field = $this->find_field( 'wc_product', '_stock_status' );
|
||||
$this->assertNotNull( $field );
|
||||
$this->assertSame( 'enum', $field['type'] );
|
||||
$this->assertTrue( (bool) ( $field['searchable'] ?? false ) );
|
||||
$this->assertContains( 'instock', $field['options'] );
|
||||
$this->assertContains( 'outofstock', $field['options'] );
|
||||
$this->assertSame( array(), WPDO_Entity_Registry::get_group_fields( 'post', 'wc_product' ), 'WooCommerce reads and writes product meta directly (stock by SQL)' );
|
||||
$this->assertNull( WPDO_Entity_Registry::get_field( 'post', '_price', 'product' ) );
|
||||
$this->assertSame( array(), WPDO_Post_Fields::groups_for_post_type( 'product' ) );
|
||||
}
|
||||
|
||||
// ── HivePress groups moved to the HivePress AddOn ───────────────────────
|
||||
@@ -139,7 +114,6 @@ class PostFieldsRegistrationTest extends TestCase {
|
||||
|
||||
public function test_core_groups_map_to_their_post_types(): void {
|
||||
$this->assertSame( 'attachment', WPDO_Post_Fields::post_type_for_group( 'attachment' ) );
|
||||
$this->assertSame( 'product', WPDO_Post_Fields::post_type_for_group( 'wc_product' ) );
|
||||
$this->assertSame( 'nav_menu_item', WPDO_Post_Fields::post_type_for_group( 'nav_menu_item' ) );
|
||||
$this->assertNull( WPDO_Post_Fields::post_type_for_group( 'wp_core' ), 'wp_core spans every post type' );
|
||||
}
|
||||
@@ -149,7 +123,6 @@ class PostFieldsRegistrationTest extends TestCase {
|
||||
|
||||
$this->assertSame( 'x_type', WPDO_Post_Fields::post_type_for_group( 'x_core' ) );
|
||||
$this->assertSame( array( 'x_core' ), WPDO_Post_Fields::groups_for_post_type( 'x_type' ) );
|
||||
$this->assertSame( array( 'wc_product' ), WPDO_Post_Fields::groups_for_post_type( 'product' ) );
|
||||
$this->assertNull( WPDO_Post_Fields::post_type_for_group( 'hp_listing_core' ), 'unregistered HivePress group is unknown to core' );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user