-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* avoid database settings lookups on each iteration, add in some except… (#357) * avoid database settings lookups on each iteration, add in some exception catching just in case. * fill in a missed phpdoc * add filter to our delete_item methods second parameter. Default to fa… (#361) * add filter to our delete_item methods second parameter. Default to false to return async behavior. * move the apply filters to an assigned variable and pass the variable to the method * pesky semicolons * changelogs and version bumps
- Loading branch information
Showing
8 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
* @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 ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
* @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 ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]> | ||
* @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; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters