From e42b7f3ee059105ab938d80240ddb63a334aa2f8 Mon Sep 17 00:00:00 2001 From: Kyle Benk Date: Tue, 3 Mar 2020 10:38:51 -0700 Subject: [PATCH 1/9] Add filter for request URL --- lib/class-sp-api.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/class-sp-api.php b/lib/class-sp-api.php index 12122fd..de51650 100644 --- a/lib/class-sp-api.php +++ b/lib/class-sp-api.php @@ -152,7 +152,15 @@ public function request( $url = '', $method = 'GET', $body = '', $request_params 'body' => $body, ) ); - $result = wp_remote_request( $url, $request_params ); + /** + * Filters the API URL directly before the request is made. + * + * @param string $url The URL of the request. + * @param array $request_params The request params. + */ + $url = apply_filters( 'sp_api_request_url' $url, $request_params ); + + $result = wp_remote_request( $url, $request_params ); if ( ! is_wp_error( $result ) ) { $this->last_request = array( From c19b987af023b21147d6385dc56a0481298402ed Mon Sep 17 00:00:00 2001 From: Kyle Benk Date: Tue, 3 Mar 2020 10:42:56 -0700 Subject: [PATCH 2/9] Add comma --- lib/class-sp-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-sp-api.php b/lib/class-sp-api.php index de51650..0d8e1e7 100644 --- a/lib/class-sp-api.php +++ b/lib/class-sp-api.php @@ -158,7 +158,7 @@ public function request( $url = '', $method = 'GET', $body = '', $request_params * @param string $url The URL of the request. * @param array $request_params The request params. */ - $url = apply_filters( 'sp_api_request_url' $url, $request_params ); + $url = apply_filters( 'sp_api_request_url', $url, $request_params ); $result = wp_remote_request( $url, $request_params ); From d19dbc1ca0cf7364f8e2e606ea4138d825470e2e Mon Sep 17 00:00:00 2001 From: Matthew Boynes Date: Fri, 6 Oct 2023 14:19:39 -0400 Subject: [PATCH 3/9] Fix indexing error when using SP_DEBUG --- lib/class-sp-debug.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/class-sp-debug.php b/lib/class-sp-debug.php index b6d6072..f54f6f6 100644 --- a/lib/class-sp-debug.php +++ b/lib/class-sp-debug.php @@ -75,15 +75,16 @@ public static function split() { } /** - * Triggers the sp_debug action to include the data before indexing. + * Triggers the sp_debug filter to include the data before indexing. * * @param object $data The data passed to sp_post_pre_index. */ public static function debug_sp_post_pre_index( $data ) { do_action( 'sp_debug', '[SP_Post] Post JSON', wp_json_encode( $data ) ); + return $data; } } add_action( 'sp_debug', array( 'SP_Debug', 'debug' ), 10, 2 ); -add_action( 'sp_post_pre_index', array( 'SP_Debug', 'debug_sp_post_pre_index' ), 999 ); +add_filter( 'sp_post_pre_index', array( 'SP_Debug', 'debug_sp_post_pre_index' ), 999 ); SP_Debug::init(); From ebada8eb115da25f1dce8e267d6f5b0c5ead4a95 Mon Sep 17 00:00:00 2001 From: Matthew Boynes Date: Fri, 6 Oct 2023 14:20:49 -0400 Subject: [PATCH 4/9] Revert doc change --- lib/class-sp-debug.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-sp-debug.php b/lib/class-sp-debug.php index f54f6f6..66f2775 100644 --- a/lib/class-sp-debug.php +++ b/lib/class-sp-debug.php @@ -75,7 +75,7 @@ public static function split() { } /** - * Triggers the sp_debug filter to include the data before indexing. + * Triggers the sp_debug action to include the data before indexing. * * @param object $data The data passed to sp_post_pre_index. */ From e93d603871bbe724c20d7e85bd6d903d1ab3e4b8 Mon Sep 17 00:00:00 2001 From: Ricardo Moraleida Date: Tue, 2 Jan 2024 14:26:14 -0300 Subject: [PATCH 5/9] fix possible fatal where ->sp is set but is not an array --- lib/class-sp-integration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-sp-integration.php b/lib/class-sp-integration.php index 8ac6d1b..bd53765 100644 --- a/lib/class-sp-integration.php +++ b/lib/class-sp-integration.php @@ -141,7 +141,7 @@ public function force_search_template( &$wp_query ) { $this->sp = get_query_var( 'sp' ); // If this is a search, but not a keyword search, we have to fake it. - if ( ! $wp_query->is_search() && ! empty( $this->sp ) && 1 === intval( $this->sp['force'] ) ) { + if ( ! $wp_query->is_search() && isset( $this->sp['force'] ) && 1 === intval( $this->sp['force'] ) ) { // First, we'll set the search string to something phony. $wp_query->set( 's', '1441f19754335ca4638bfdf1aea00c6d' ); $wp_query->is_search = true; From 4559fca96d51b14ae2611194d55e72f02fe88a96 Mon Sep 17 00:00:00 2001 From: Sean Fisher Date: Wed, 3 Apr 2024 12:32:55 -0400 Subject: [PATCH 6/9] Handle a protected ->cache --- bin/wp-cli.php | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index ed9ebb2..20bcc47 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -15,14 +15,26 @@ class Searchpress_CLI_Command extends WP_CLI_Command { private function contain_memory_leaks() { global $wpdb, $wp_object_cache; $wpdb->queries = array(); - if ( !is_object( $wp_object_cache ) ) + + if ( !is_object( $wp_object_cache ) ) { return; - $wp_object_cache->group_ops = array(); - $wp_object_cache->stats = array(); - $wp_object_cache->memcache_debug = array(); - $wp_object_cache->cache = array(); - if ( method_exists( $wp_object_cache, '__remoteset' ) ) + } + + if ( isset( $wp_object_cache->group_ops ) ) { + $wp_object_cache->group_ops = []; + } + + if ( isset( $wp_object_cache->memcache_debug ) ) { + $wp_object_cache->memcache_debug = []; + } + + if ( isset( $wp_object_cache->cache ) ) { + $wp_object_cache->cache = []; + } + + if ( method_exists( $wp_object_cache, '__remoteset' ) ) { $wp_object_cache->__remoteset(); + } } From 96bb088de42949d8961b0eadc970b75438145b10 Mon Sep 17 00:00:00 2001 From: Greg Marshall Date: Tue, 20 Aug 2024 10:15:28 -0500 Subject: [PATCH 7/9] WIP: issue-187 From da2a5c6854c38e91ff7554711749dd0ce392fd01 Mon Sep 17 00:00:00 2001 From: Greg Marshall Date: Tue, 20 Aug 2024 10:15:51 -0500 Subject: [PATCH 8/9] change to expect a string --- bin/wp-cli.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/wp-cli.php b/bin/wp-cli.php index 6737caa..4987f03 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -295,7 +295,7 @@ public function index( $args, $assoc_args ) { WP_CLI::log( sprintf( - 'Indexing %1$s, %2$d at a time, starting on page %3$d', + 'Indexing %1$s, %2$s at a time, starting on page %3$d', $limit_text, number_format( $assoc_args['bulk'] ), absint( $assoc_args['page'] ) From 832837aa0abe699002379c8e63937ca931c60d33 Mon Sep 17 00:00:00 2001 From: Greg Marshall Date: Tue, 20 Aug 2024 10:16:02 -0500 Subject: [PATCH 9/9] Ready for review