feat(2meet-data-optimizer): flag new Hot zone registrations as deprecated
- ADR-003 step 4 (core side): TMDO_Schema_Registry::register() raises _doing_it_wrong() the first time each provider registers a zone=hot field in a request (zone omitted defaults to hot). Fields still register, so existing hot data stays readable. - Cold / warm / archive registrations are unaffected. - Test bootstrap's _doing_it_wrong stub now records calls. - Verify: core unit 658 / integration 459, HP 142/49, WC 10/22 green, phpcs clean - PR: PR-038
This commit is contained in:
+1
-1
@@ -231,7 +231,7 @@ if ( ! function_exists( 'esc_sql' ) ) {
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( '_doing_it_wrong' ) ) {
|
||||
function _doing_it_wrong( string $fn, string $msg, string $ver ): void {}
|
||||
function _doing_it_wrong( string $fn, string $msg, string $ver ): void { $GLOBALS['_doing_it_wrong_calls'][] = array( $fn, $msg ); }
|
||||
}
|
||||
if ( ! function_exists( 'get_option' ) ) {
|
||||
function get_option( string $key, $default = false ) { return $GLOBALS['_wp_options'][ $key ] ?? $default; }
|
||||
|
||||
@@ -18,6 +18,30 @@ class SchemaRegistryTest extends TestCase {
|
||||
$instance->setValue( null, null );
|
||||
|
||||
$this->registry = WPDO_Schema_Registry::instance();
|
||||
$GLOBALS['_doing_it_wrong_calls'] = array();
|
||||
}
|
||||
|
||||
// ── Hot zone deprecation (ADR-003) ──────────────────────────────────────
|
||||
|
||||
public function test_hot_registration_is_flagged_once_per_provider(): void {
|
||||
foreach ( array( 'p1', 'p1', 'p2' ) as $i => $provider ) {
|
||||
$this->registry->register( $provider, array( 'post_type' => 'x', 'meta_key' => "k{$i}", 'zone' => 'hot' ) );
|
||||
}
|
||||
$this->registry->register( 'p1', array( 'post_type' => 'x', 'meta_key' => 'k9' ) ); // zone defaults to hot.
|
||||
|
||||
$calls = $GLOBALS['_doing_it_wrong_calls'];
|
||||
$this->assertCount( 2, $calls );
|
||||
$this->assertStringContainsString( 'p1', $calls[0][1] );
|
||||
$this->assertStringContainsString( 'p2', $calls[1][1] );
|
||||
$this->assertSame( 'hot', $this->registry->get_field_zone( 'x', 'k9' ), 'still registered: frozen, not rejected' );
|
||||
}
|
||||
|
||||
public function test_other_zones_are_not_flagged(): void {
|
||||
$this->registry->register( 'p', array( 'post_type' => 'x', 'meta_key' => 'c', 'zone' => 'cold' ) );
|
||||
$this->registry->register( 'p', array( 'post_type' => 'x', 'meta_key' => 'w', 'zone' => 'warm' ) );
|
||||
$this->registry->register( 'p', array( 'post_type' => 'x', 'meta_key' => 'a', 'zone' => 'archive' ) );
|
||||
|
||||
$this->assertSame( array(), $GLOBALS['_doing_it_wrong_calls'] );
|
||||
}
|
||||
|
||||
// ── register() ──────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user