fix(2meet-data-optimizer-hivepress-addon): let transient timeouts outlive their values; register site attributes once themes load
- review F5: a timeout entry expired before its value (a day vs a week), and HivePress reads a missing timeout as "never expires", serving the stale value for up to six more days. The timeout now expires a minute after the later of MAX_CACHE_TTL and its own time, so HivePress sees it expire first - review F7: site attributes accept only types with a plain index (json and binary would fail the CREATE TABLE) - review F8: the hp_listing_attrs group is registered on the run after after_setup_theme (init:1), so a filter added in a theme counts and the group has one definition per request; only keys of other groups are skipped - Verify: TTL test, attribute group tests, unit 148, integration 53, phpcs - PR: PR-115 (2.3 acceptance correctness review)
This commit is contained in:
@@ -280,17 +280,25 @@ final class TMDO_HivePress_Entity_Groups {
|
||||
* They get a group of their own — a new table, each column indexed at
|
||||
* creation — so hp_listing_core and its pinned definition stay unchanged.
|
||||
* Keys another group already manages, keys without the hp_ prefix and
|
||||
* unknown types are ignored. Backfill with `wp tmdo post-migrate-group`.
|
||||
* types that cannot take a plain index (json, binary) are ignored. Core
|
||||
* fills the new table from native meta (drift fix) before using it.
|
||||
*
|
||||
* Registered once themes are loaded (the init:1 run): a filter added in a
|
||||
* theme is seen, and the group gets one definition per request.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private static function register_hp_listing_attributes_group(): void {
|
||||
if ( ! did_action( 'after_setup_theme' ) ) {
|
||||
return;
|
||||
}
|
||||
$fields = array();
|
||||
foreach ( (array) apply_filters( 'tmdo_hp_listing_attribute_fields', array() ) as $key => $type ) {
|
||||
$key = (string) $key;
|
||||
$key = (string) $key;
|
||||
$owner = TMDO_Entity_Registry::get_field( 'post', $key, 'hp_listing' );
|
||||
if ( 1 !== preg_match( '/^hp_[a-z0-9_]+$/', $key )
|
||||
|| ! in_array( $type, TMDO_Entity_Registry::VALID_TYPES, true )
|
||||
|| null !== TMDO_Entity_Registry::get_field( 'post', $key, 'hp_listing' ) ) {
|
||||
|| ! in_array( $type, array( 'text', 'textarea', 'integer', 'decimal', 'boolean', 'date', 'datetime', 'timestamp', 'enum' ), true )
|
||||
|| ( null !== $owner && 'hp_listing_attrs' !== $owner['group'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$fields[] = array(
|
||||
|
||||
Reference in New Issue
Block a user