Compare commits
2 Commits
61762c49d0
...
fda9e43087
| Author | SHA1 | Date | |
|---|---|---|---|
| fda9e43087 | |||
| a01314cbb1 |
@@ -3,7 +3,7 @@
|
|||||||
* Plugin Name: 2meet Data Optimizer — Hivepress AddOn
|
* Plugin Name: 2meet Data Optimizer — Hivepress AddOn
|
||||||
* Plugin URI: https://2meet.io/2meet-data-optimizer/hivepress
|
* Plugin URI: https://2meet.io/2meet-data-optimizer/hivepress
|
||||||
* Description: HivePress + 12 擴充整合:13 adapter (core/reviews/bookings/messages/memberships/requests/favorites/statistics/tags/seo/social-links/blocks/marketplace) + 7 HPCT interceptor + 5 query interceptor + admin tab + CLI namespace
|
* Description: HivePress + 12 擴充整合:13 adapter (core/reviews/bookings/messages/memberships/requests/favorites/statistics/tags/seo/social-links/blocks/marketplace) + 7 HPCT interceptor + 5 query interceptor + admin tab + CLI namespace
|
||||||
* Version: 0.1.0
|
* Version: 0.2.0
|
||||||
* Requires at least: 6.0
|
* Requires at least: 6.0
|
||||||
* Tested up to: 6.9.4
|
* Tested up to: 6.9.4
|
||||||
* Requires PHP: 8.1
|
* Requires PHP: 8.1
|
||||||
@@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
define( 'TMDO_HIVEPRESS_VERSION', '0.1.0' );
|
define( 'TMDO_HIVEPRESS_VERSION', '0.2.0' );
|
||||||
define( 'TMDO_HIVEPRESS_PATH', plugin_dir_path( __FILE__ ) );
|
define( 'TMDO_HIVEPRESS_PATH', plugin_dir_path( __FILE__ ) );
|
||||||
define( 'TMDO_HIVEPRESS_URL', plugin_dir_url( __FILE__ ) );
|
define( 'TMDO_HIVEPRESS_URL', plugin_dir_url( __FILE__ ) );
|
||||||
define( 'TMDO_HIVEPRESS_FILE', __FILE__ );
|
define( 'TMDO_HIVEPRESS_FILE', __FILE__ );
|
||||||
|
|||||||
@@ -9,6 +9,20 @@ Versioning follows [Semantic Versioning](https://semver.org/).
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## [0.2.0] — 2026-09-26
|
||||||
|
|
||||||
|
Released with 2meet-data-optimizer 1.1.0 (hardening 2.1, search-index mode).
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- HivePress model query / search hooks (`optimize_query`, `optimize_search`)
|
||||||
|
are no longer bound while core's post router is active
|
||||||
|
(`TMDO_Post_Query_Router::is_router_active()`): core routes HivePress
|
||||||
|
searches, including `_sort`, to the entity flat tables, and two routers
|
||||||
|
would claim the same clauses.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- `tests/integration/`:bootstrap(複用核心的 integration bootstrap,連真實
|
- `tests/integration/`:bootstrap(複用核心的 integration bootstrap,連真實
|
||||||
|
|||||||
@@ -138,8 +138,14 @@ if ( ! class_exists( 'TMDO_HivePress_Core_Adapter' ) ) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind HivePress search query hooks at priority 20 (after HP setup).
|
* Bind HivePress search query hooks at priority 20 (after HP setup).
|
||||||
|
*
|
||||||
|
* Not while core's post router serves HivePress searches from the
|
||||||
|
* entity flat tables: two routers would claim the same clauses.
|
||||||
*/
|
*/
|
||||||
public function on_register_query_hooks(): void {
|
public function on_register_query_hooks(): void {
|
||||||
|
if ( class_exists( 'TMDO_Post_Query_Router' ) && TMDO_Post_Query_Router::is_router_active() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
foreach ( self::HOT_MODELS as $model => $post_type ) {
|
foreach ( self::HOT_MODELS as $model => $post_type ) {
|
||||||
unset( $post_type ); // Bound below by string-interpolated $model only.
|
unset( $post_type ); // Bound below by string-interpolated $model only.
|
||||||
add_action(
|
add_action(
|
||||||
|
|||||||
@@ -116,4 +116,33 @@ class HivePressCoreAdapterTest extends TestCase {
|
|||||||
$this->adapter->optimize_search( $query, array() );
|
$this->adapter->optimize_search( $query, array() );
|
||||||
$this->assertEmpty( $query->get( 'wpdo_hot_clauses' ) );
|
$this->assertEmpty( $query->get( 'wpdo_hot_clauses' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the query hooks with core's post mode set to $mode.
|
||||||
|
*
|
||||||
|
* @return array<int, mixed> Callbacks bound to the listing query hooks.
|
||||||
|
*/
|
||||||
|
private function query_hooks_in_post_mode( string $mode ): array {
|
||||||
|
$cache = new ReflectionProperty( TMDO_Mode_Manager::class, 'cache' );
|
||||||
|
$cache->setAccessible( true );
|
||||||
|
$cache->setValue( null, array( 'post' => $mode, 'user' => 'disabled', 'term' => 'disabled', 'comment' => 'disabled' ) );
|
||||||
|
unset( $GLOBALS['_wp_filter_callbacks']['hivepress/v1/models/listing/query'], $GLOBALS['_wp_filter_callbacks']['hivepress/v1/models/listing/search'] );
|
||||||
|
try {
|
||||||
|
$this->adapter->on_register_query_hooks();
|
||||||
|
} finally {
|
||||||
|
$cache->setValue( null, null );
|
||||||
|
}
|
||||||
|
return array_merge(
|
||||||
|
$GLOBALS['_wp_filter_callbacks']['hivepress/v1/models/listing/query'] ?? array(),
|
||||||
|
$GLOBALS['_wp_filter_callbacks']['hivepress/v1/models/listing/search'] ?? array()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_query_hooks_are_bound_while_the_core_post_router_is_idle(): void {
|
||||||
|
$this->assertCount( 2, $this->query_hooks_in_post_mode( 'dual_write' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_query_hooks_are_left_to_the_core_post_router_when_it_is_active(): void {
|
||||||
|
$this->assertSame( array(), $this->query_hooks_in_post_mode( 'shadow_read' ), 'two routers would claim the same clauses' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user