hardening 2.4: 2meet-data-optimizer-hivepress-addon 0.5.0 (sort indexes, a day's transient TTL) #5

Merged
wpdev merged 3 commits from hardening/2.4 into main 2026-09-27 23:57:57 +08:00
2 changed files with 22 additions and 7 deletions
Showing only changes of commit 0cd2a9db5b - Show all commits
@@ -268,6 +268,11 @@ final class TMDO_HivePress_Entity_Groups {
'indexes' => method_exists( 'TMDO_Schema_Manager', 'ddl_allowed' ) ? array( 'indexes' => method_exists( 'TMDO_Schema_Manager', 'ddl_allowed' ) ? array(
'hourly_rate' => array( 'hp_hourly_rate' ), 'hourly_rate' => array( 'hp_hourly_rate' ),
'rating_count' => array( 'hp_rating_count' ), 'rating_count' => array( 'hp_rating_count' ),
// HivePress sorts: the value then the ID tie-break, which core 1.4.0
// reads in order (flat-first) instead of sorting every match.
'price_id' => array( 'hp_price', 'post_id' ),
'rating_id' => array( 'hp_rating', 'post_id' ),
'hourly_rate_id' => array( 'hp_hourly_rate', 'post_id' ),
) : array(), ) : array(),
) )
); );
+13 -3
View File
@@ -37,9 +37,15 @@ class HivePressEntityGroupsTest extends TestCase {
'hp_user' => 'hp_vendor_core', 'hp_user' => 'hp_vendor_core',
); );
private function post_adapter(): TMDO_Entity_Adapter_Interface {
$adapter = $this->createMock( TMDO_Entity_Adapter_Interface::class );
$adapter->method( 'get_entity_id_column' )->willReturn( 'post_id' );
return $adapter;
}
protected function setUp(): void { protected function setUp(): void {
TMDO_Entity_Registry::init(); TMDO_Entity_Registry::init();
TMDO_Entity_Registry::register_adapter( 'post', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); TMDO_Entity_Registry::register_adapter( 'post', $this->post_adapter() );
TMDO_Entity_Registry::register_adapter( 'user', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); TMDO_Entity_Registry::register_adapter( 'user', $this->createMock( TMDO_Entity_Adapter_Interface::class ) );
TMDO_HivePress_Entity_Groups::register_entity_fields(); TMDO_HivePress_Entity_Groups::register_entity_fields();
} }
@@ -68,6 +74,10 @@ class HivePressEntityGroupsTest extends TestCase {
array( array(
'hourly_rate' => array( 'hp_hourly_rate' ), 'hourly_rate' => array( 'hp_hourly_rate' ),
'rating_count' => array( 'hp_rating_count' ), 'rating_count' => array( 'hp_rating_count' ),
// Sorts: the value then the ID tie-break, read in order (2.4 PR-119).
'price_id' => array( 'hp_price', 'post_id' ),
'rating_id' => array( 'hp_rating', 'post_id' ),
'hourly_rate_id' => array( 'hp_hourly_rate', 'post_id' ),
), ),
TMDO_Entity_Registry::get_group_indexes( 'post', 'hp_listing_core' ) TMDO_Entity_Registry::get_group_indexes( 'post', 'hp_listing_core' )
); );
@@ -94,7 +104,7 @@ class HivePressEntityGroupsTest extends TestCase {
$GLOBALS['_wp_did_action']['after_setup_theme'] = 1; $GLOBALS['_wp_did_action']['after_setup_theme'] = 1;
try { try {
TMDO_Entity_Registry::init(); TMDO_Entity_Registry::init();
TMDO_Entity_Registry::register_adapter( 'post', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); TMDO_Entity_Registry::register_adapter( 'post', $this->post_adapter() );
TMDO_Entity_Registry::register_adapter( 'user', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); TMDO_Entity_Registry::register_adapter( 'user', $this->createMock( TMDO_Entity_Adapter_Interface::class ) );
TMDO_HivePress_Entity_Groups::register_entity_fields(); TMDO_HivePress_Entity_Groups::register_entity_fields();
} finally { } finally {
@@ -118,7 +128,7 @@ class HivePressEntityGroupsTest extends TestCase {
add_filter( 'tmdo_hp_listing_attribute_fields', static fn() => array( 'hp_warranty' => 'integer' ) ); add_filter( 'tmdo_hp_listing_attribute_fields', static fn() => array( 'hp_warranty' => 'integer' ) );
try { try {
TMDO_Entity_Registry::init(); TMDO_Entity_Registry::init();
TMDO_Entity_Registry::register_adapter( 'post', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); TMDO_Entity_Registry::register_adapter( 'post', $this->post_adapter() );
TMDO_Entity_Registry::register_adapter( 'user', $this->createMock( TMDO_Entity_Adapter_Interface::class ) ); TMDO_Entity_Registry::register_adapter( 'user', $this->createMock( TMDO_Entity_Adapter_Interface::class ) );
TMDO_HivePress_Entity_Groups::register_entity_fields(); TMDO_HivePress_Entity_Groups::register_entity_fields();
$this->assertSame( array(), TMDO_Entity_Registry::get_group_keys( 'post', 'hp_listing_attrs' ), 'plugins_loaded run: not yet' ); $this->assertSame( array(), TMDO_Entity_Registry::get_group_keys( 'post', 'hp_listing_attrs' ), 'plugins_loaded run: not yet' );