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:
@@ -67,6 +67,13 @@ class TMDO_Schema_Registry {
|
||||
*/
|
||||
private array $warm_fields = array();
|
||||
|
||||
/**
|
||||
* Providers already told the Hot zone is frozen (once per request).
|
||||
*
|
||||
* @var array<string, true>
|
||||
*/
|
||||
private array $hot_deprecation_flagged = array();
|
||||
|
||||
/**
|
||||
* Private constructor — use instance() to get the singleton.
|
||||
*/
|
||||
@@ -138,6 +145,7 @@ class TMDO_Schema_Registry {
|
||||
switch ( $config['zone'] ) {
|
||||
case 'hot':
|
||||
$this->hot_columns[ $config['post_type'] ][ $config['column'] ] = $config['data_type'];
|
||||
$this->flag_hot_deprecation( $provider, $config['meta_key'] );
|
||||
break;
|
||||
|
||||
case 'warm':
|
||||
@@ -159,6 +167,29 @@ class TMDO_Schema_Registry {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The Hot zone is frozen (ADR-003): fields still register so existing hot
|
||||
* data stays readable, but each provider gets one notice per request.
|
||||
*
|
||||
* @param string $provider Provider name.
|
||||
* @param string $meta_key First hot meta_key seen from it.
|
||||
*/
|
||||
private function flag_hot_deprecation( string $provider, string $meta_key ): void {
|
||||
if ( isset( $this->hot_deprecation_flagged[ $provider ] ) ) {
|
||||
return;
|
||||
}
|
||||
$this->hot_deprecation_flagged[ $provider ] = true;
|
||||
_doing_it_wrong(
|
||||
__CLASS__ . '::register',
|
||||
sprintf(
|
||||
'Provider "%1$s" registered Hot zone field "%2$s". The Hot zone is frozen; register an entity group (TMDO_Entity_Registry::register_group) instead.',
|
||||
esc_html( $provider ),
|
||||
esc_html( $meta_key )
|
||||
),
|
||||
esc_html( TMDO_VERSION )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk register multiple fields.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user