diff --git a/bin/wp-cli.php b/bin/wp-cli.php index 5e1656c..4987f03 100644 --- a/bin/wp-cli.php +++ b/bin/wp-cli.php @@ -57,10 +57,18 @@ private function contain_memory_leaks() { return; } - $wp_object_cache->group_ops = array(); - $wp_object_cache->stats = array(); - $wp_object_cache->memcache_debug = array(); - $wp_object_cache->cache = array(); + 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(); } @@ -287,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'] ) diff --git a/lib/class-sp-api.php b/lib/class-sp-api.php index 00e7303..0effbff 100644 --- a/lib/class-sp-api.php +++ b/lib/class-sp-api.php @@ -265,6 +265,13 @@ public function request( $url = '', $method = 'GET', $body = '', $request_params 'body' => $body, ) ); + /** + * 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 = sp_remote_request( $url, $request_params ); diff --git a/lib/class-sp-debug.php b/lib/class-sp-debug.php index b6d6072..66f2775 100644 --- a/lib/class-sp-debug.php +++ b/lib/class-sp-debug.php @@ -81,9 +81,10 @@ public static function split() { */ 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(); diff --git a/lib/class-sp-integration.php b/lib/class-sp-integration.php index 80c8b4d..6d45408 100644 --- a/lib/class-sp-integration.php +++ b/lib/class-sp-integration.php @@ -196,7 +196,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;