diff --git a/CHANGELOG.md b/CHANGELOG.md index 6df6477e..3d7e1695 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +## 2.6.1 + +* Fixed: Performance issues related to delete operations. +* Fixed: Performance issues around WP All Import. + +## 2.6.0 + +* Added: Support for syncing imported items when "fast mode" from WP All Import enabled. +* Added: Support for updating child posts if parent post's slug has been updated. +* Added: Support for updating posts when an associated term has been updatd. +* Added: Wait for delete operations to complete before moving to updates. +* Updated: Algolia Search library to 4.18.x +* Updated: InstantSearch library to 4.56.x + +## 2.5.4 + +* Updated: Ensure reindexing completes when using the from_batch flag with CLI. +* Updated: Assigned Algolia_Admin instance to a property for access elsewhere. + ## 2.5.3 * Updated: Autocomplete template file with user link fix when cmd/ctrl clicking. diff --git a/README.txt b/README.txt index 7653895d..b89f12aa 100644 --- a/README.txt +++ b/README.txt @@ -2,9 +2,9 @@ Contributors: WebDevStudios, williamsba1, tw2113, mrasharirfan, scottbasgaard, gregrickaby, richaber Tags: search, algolia, autocomplete, instantsearch, relevance search, faceted search, find-as-you-type search, ecommerce, seo, woocommerce, advanced search Requires at least: 5.0 -Tested up to: 6.3.0 +Tested up to: 6.3.1 Requires PHP: 7.4 -Stable tag: 2.6.0 +Stable tag: 2.6.1 License: GNU General Public License v2.0, MIT License Use the power of Algolia to enhance your website's search. Enable Autocomplete and Instantsearch for fast and accurate results. Control the look, feel, and relevance. @@ -125,6 +125,10 @@ All development is handled on [GitHub](https://github.com/WebDevStudios/wp-searc Follow along with the changelog on [Github](https://github.com/WebDevStudios/wp-search-with-algolia/releases). += 2.6.1 = +* Fixed: Performance issues related to delete operations. +* Fixed: Performance issues around WP All Import. + = 2.6.0 = * Added: Support for syncing imported items when "fast mode" from WP All Import enabled. * Added: Support for updating child posts if parent post's slug has been updated. diff --git a/algolia.php b/algolia.php index e3dae501..d1dd2b51 100644 --- a/algolia.php +++ b/algolia.php @@ -3,7 +3,7 @@ * Plugin Name: WP Search with Algolia * Plugin URI: https://github.com/WebDevStudios/wp-search-with-algolia * Description: Integrate the powerful Algolia search service with WordPress - * Version: 2.6.0 + * Version: 2.6.1 * Requires at least: 5.0 * Requires PHP: 7.4 * Author: WebDevStudios @@ -26,7 +26,7 @@ } // The Algolia Search plugin version. -define( 'ALGOLIA_VERSION', '2.6.0' ); +define( 'ALGOLIA_VERSION', '2.6.1' ); // The minmum required PHP version. define( 'ALGOLIA_MIN_PHP_VERSION', '7.4' ); diff --git a/composer.json b/composer.json index 08d67c3e..ff0d2944 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "webdevstudios/wp-search-with-algolia", - "version": "2.6.0", + "version": "2.6.1", "description": "Integrate the powerful Algolia search service with WordPress.", "authors": [ { diff --git a/includes/indices/class-algolia-posts-index.php b/includes/indices/class-algolia-posts-index.php index 21bd7ff5..9a23cc4a 100644 --- a/includes/indices/class-algolia-posts-index.php +++ b/includes/indices/class-algolia-posts-index.php @@ -390,7 +390,20 @@ private function update_post_records( WP_Post $post, array $records ) { // If there are no records, parent `update_records` will take care of the deletion. // In case of posts, we ALWAYS need to delete existing records. if ( ! empty( $records ) ) { - $this->delete_item( $post, true ); + /** + * Filters whether or not to use synchronous wait on record update operations. + * + * @author WebDevStudios + * @since 2.6.1 + * + * @param bool $value Whether or not to use synchronous wait. Default false. + * @param WP_Post $post Current post object being updated. + * @param array $records The records + * + * @return bool + */ + $should_wait = (bool) apply_filters( 'algolia_should_wait_on_delete_item', false, $post, $records ); + $this->delete_item( $post, $should_wait ); } parent::update_records( $post, $records ); diff --git a/includes/indices/class-algolia-searchable-posts-index.php b/includes/indices/class-algolia-searchable-posts-index.php index a1258142..e4bf9611 100644 --- a/includes/indices/class-algolia-searchable-posts-index.php +++ b/includes/indices/class-algolia-searchable-posts-index.php @@ -371,7 +371,20 @@ private function update_post_records( WP_Post $post, array $records ) { // If there are no records, parent `update_records` will take care of the deletion. // In case of posts, we ALWAYS need to delete existing records. if ( ! empty( $records ) ) { - $this->delete_item( $post, true ); + /** + * Filters whether or not to use synchronous wait on record update operations. + * + * @author WebDevStudios + * @since 2.6.1 + * + * @param bool $value Whether or not to use synchronous wait. Default false. + * @param WP_Post $post Current post object being updated. + * @param array $records The records. + * + * @return bool + */ + $should_wait = (bool) apply_filters( 'algolia_should_wait_on_delete_item', false, $post, $records ); + $this->delete_item( $post, $should_wait ); } parent::update_records( $post, $records ); diff --git a/includes/watchers/class-algolia-post-changes-watcher.php b/includes/watchers/class-algolia-post-changes-watcher.php index 7f5eeee2..da0c8d98 100644 --- a/includes/watchers/class-algolia-post-changes-watcher.php +++ b/includes/watchers/class-algolia-post-changes-watcher.php @@ -47,6 +47,16 @@ class Algolia_Post_Changes_Watcher implements Algolia_Changes_Watcher { */ private $posts_updated = []; + /** + * Whether or not we have detected fast mode for a given import. + * + * @author WebDevStudios + * @since 2.6.1 + * + * @var bool + */ + public static $pmxi_is_fast_mode; + /** * Algolia_Post_Changes_Watcher constructor. * @@ -240,10 +250,19 @@ public function track_updated_posts( $post_id ) { */ public function sync_item_for_pmxi( $import_id ) { - $import = new PMXI_Import_Record(); - $import->getById( $import_id ); + if ( null === self::$pmxi_is_fast_mode ) { + try { + $import = new PMXI_Import_Record(); + $import->getBy( 'id', $import_id ); + + self::$pmxi_is_fast_mode = ( ! empty( $import->options['is_fast_mode'] ) ); + } catch ( Exception $exception ) { + error_log( $exception->getMessage() ); // phpcs:ignore -- Legacy. + return; + } + } - if ( empty( $import->options['is_fast_mode'] ) ) { + if ( ! self::$pmxi_is_fast_mode ) { return; } diff --git a/package.json b/package.json index f4625427..28f516b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wp-search-with-algolia", - "version": "2.6.0", + "version": "2.6.1", "description": "Integrate the powerful Algolia search service with WordPress.", "author": "WebDevStudios", "license": "GPL-3.0",