Changeset 2608099
- Timestamp:
- 10/01/2021 11:19:32 PM (4 years ago)
- Location:
- wp-search-with-algolia
- Files:
-
- 8 added
- 16 edited
- 1 copied
-
tags/2.1.0 (copied) (copied from wp-search-with-algolia/trunk)
-
tags/2.1.0/README.txt (modified) (2 diffs)
-
tags/2.1.0/algolia.php (modified) (2 diffs)
-
tags/2.1.0/includes/indices/class-algolia-index.php (modified) (8 diffs)
-
tags/2.1.0/includes/indices/class-algolia-searchable-posts-index.php (modified) (1 diff)
-
tags/2.1.0/includes/libraries/algoliasearch-client-php/src/Algolia.php (modified) (1 diff)
-
tags/2.1.0/includes/libraries/algoliasearch-client-php/src/Config/PersonalizationConfig.php (added)
-
tags/2.1.0/includes/libraries/algoliasearch-client-php/src/Config/RecommendConfig.php (added)
-
tags/2.1.0/includes/libraries/algoliasearch-client-php/src/Config/RecommendationConfig.php (modified) (1 diff)
-
tags/2.1.0/includes/libraries/algoliasearch-client-php/src/PersonalizationClient.php (added)
-
tags/2.1.0/includes/libraries/algoliasearch-client-php/src/RecommendClient.php (added)
-
tags/2.1.0/includes/libraries/algoliasearch-client-php/src/RecommendationClient.php (modified) (1 diff)
-
tags/2.1.0/includes/libraries/algoliasearch-client-php/src/SearchClient.php (modified) (3 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/algolia.php (modified) (2 diffs)
-
trunk/includes/indices/class-algolia-index.php (modified) (8 diffs)
-
trunk/includes/indices/class-algolia-searchable-posts-index.php (modified) (1 diff)
-
trunk/includes/libraries/algoliasearch-client-php/src/Algolia.php (modified) (1 diff)
-
trunk/includes/libraries/algoliasearch-client-php/src/Config/PersonalizationConfig.php (added)
-
trunk/includes/libraries/algoliasearch-client-php/src/Config/RecommendConfig.php (added)
-
trunk/includes/libraries/algoliasearch-client-php/src/Config/RecommendationConfig.php (modified) (1 diff)
-
trunk/includes/libraries/algoliasearch-client-php/src/PersonalizationClient.php (added)
-
trunk/includes/libraries/algoliasearch-client-php/src/RecommendClient.php (added)
-
trunk/includes/libraries/algoliasearch-client-php/src/RecommendationClient.php (modified) (1 diff)
-
trunk/includes/libraries/algoliasearch-client-php/src/SearchClient.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-search-with-algolia/tags/2.1.0/README.txt
r2572427 r2608099 5 5 Tested up to: 5.8 6 6 Requires PHP: 7.2 7 Stable tag: 2. 0.17 Stable tag: 2.1.0 8 8 License: GNU General Public License v2.0, MIT License 9 9 … … 107 107 Follow along with the changelog on [Github](https://github.com/WebDevStudios/wp-search-with-algolia/releases). 108 108 109 = 2.1.0 = 110 * Add algolia_update_records filter to allow inspection and filtering records during update operation. 111 * Add algolia_re_index_records filter to allow inspection and filtering records during re-index operation. 112 * Catch some Aloglia PHP Client exceptions that were previously uncaught during record updating and re-indexing. 113 * Fix an issue where SearchIndex::saveObjects was called twice during re-index operations. 114 * Update Algolia PHP API Client to 3.1.0 115 109 116 = 2.0.1 = 110 117 * Fix for users that enable intstantsearch but not autocomplete by adding algoliasearch client as direct dependency of both -
wp-search-with-algolia/tags/2.1.0/algolia.php
r2572427 r2608099 4 4 * Plugin URI: https://github.com/WebDevStudios/wp-search-with-algolia 5 5 * Description: Integrate the powerful Algolia search service with WordPress 6 * Version: 2. 0.16 * Version: 2.1.0 7 7 * Requires at least: 5.0 8 8 * Requires PHP: 7.2 … … 27 27 28 28 // The Algolia Search plugin version. 29 define( 'ALGOLIA_VERSION', '2. 0.1' );29 define( 'ALGOLIA_VERSION', '2.1.0' ); 30 30 31 31 // The minmum required PHP version. -
wp-search-with-algolia/tags/2.1.0/includes/indices/class-algolia-index.php
r2465306 r2608099 59 59 */ 60 60 protected $contains_only; 61 62 /** 63 * Whether the reindexing operation is running or not. 64 * 65 * @author WebDevStudios <[email protected]> 66 * @since 2.1.0 67 * 68 * @var bool 69 */ 70 protected $reindexing = false; 61 71 62 72 /** … … 323 333 */ 324 334 protected function update_records( $item, array $records ) { 335 325 336 if ( empty( $records ) ) { 326 337 $this->delete_item( $item ); … … 328 339 } 329 340 330 $index = $this->get_index(); 331 $records = $this->sanitize_json_data( $records ); 332 $index->saveObjects( $records ); 341 /** 342 * If update_records is called from re_index, 343 * skip sanitizing and saving records here, 344 * as it will trigger duplicate API calls. 345 */ 346 if ( true === $this->reindexing ) { 347 return; 348 } 349 350 /** 351 * Filters the records to be updated. 352 * 353 * @since 2.1.0 354 * 355 * @param array $records Array of records to update. 356 * @param object $item The item to update records for. 357 * @param string $index_id The index ID without prefix. 358 */ 359 $records = apply_filters( 360 'algolia_update_records', 361 $records, 362 $item, 363 $this->get_id() 364 ); 365 366 try { 367 $sanitized_records = $this->sanitize_json_data( $records ); 368 } catch ( \Throwable $throwable ) { 369 error_log( $throwable->getMessage() ); // phpcs:ignore -- Need a real logger. 370 } 371 372 // Don't saveObjects if sanitize_json_data failed. 373 if ( empty( $sanitized_records ) ) { 374 return; 375 } 376 377 $index = $this->get_index(); 378 379 try { 380 $index->saveObjects( $sanitized_records ); 381 } catch ( \Throwable $throwable ) { 382 error_log( $throwable->getMessage() ); // phpcs:ignore -- Need a real logger. 383 } 333 384 } 334 385 … … 385 436 386 437 $batch_size = (int) $this->get_re_index_batch_size(); 438 387 439 if ( $batch_size < 1 ) { 388 440 throw new InvalidArgumentException( 'Re-index batch size can not be lower than 1.' ); … … 396 448 397 449 $records = array(); 450 451 /** 452 * Set the reindexing bit to true. 453 */ 454 $this->reindexing = true; 455 398 456 foreach ( $items as $item ) { 399 457 if ( ! $this->should_index( $item ) ) { … … 411 469 412 470 if ( ! empty( $records ) ) { 471 472 /** 473 * Filters the records to be reindexed. 474 * 475 * @since 2.1.0 476 * 477 * @param array $records Array of records to re-index. 478 * @param int $page Page to re-index. 479 * @param string $index_id The index ID without prefix. 480 */ 481 $records = apply_filters( 482 'algolia_re_index_records', 483 $records, 484 $page, 485 $this->get_id() 486 ); 487 488 try { 489 $sanitized_records = $this->sanitize_json_data( $records ); 490 } catch ( \Throwable $throwable ) { 491 error_log( $throwable->getMessage() ); // phpcs:ignore -- Need a real logger. 492 } 493 } 494 495 // Don't saveObjects if sanitize_json_data failed. 496 if ( ! empty( $sanitized_records ) ) { 497 413 498 $index = $this->get_index(); 414 499 415 $records = $this->sanitize_json_data( $records ); 416 417 $index->saveObjects( $records ); 418 } 500 try { 501 $index->saveObjects( $sanitized_records ); 502 } catch ( \Throwable $throwable ) { 503 error_log( $throwable->getMessage() ); // phpcs:ignore -- Need a real logger. 504 } 505 } 506 507 /** 508 * Set the reindexing bit back to false. 509 */ 510 $this->reindexing = false; 419 511 420 512 if ( $page === $max_num_pages ) { … … 506 598 * Here we use a private function introduced in WP 4.1. 507 599 * 600 * Since WPSWA v 1.1.0, minimum suppported WordPress version is 5.0. 601 * 508 602 * @author WebDevStudios <[email protected]> 509 603 * @since 1.0.0 … … 513 607 * @return mixed The sanitized data that shall be encoded to JSON. 514 608 * 515 * @throws Exception If depth is less than zero.609 * @throws Exception If depth limit is reached. 516 610 */ 517 611 protected function sanitize_json_data( $data ) { 518 if ( function_exists( '_wp_json_sanity_check' ) ) { 519 return _wp_json_sanity_check( $data, 512 ); 520 } 521 522 return $data; 612 return _wp_json_sanity_check( $data, 512 ); 523 613 } 524 614 -
wp-search-with-algolia/tags/2.1.0/includes/indices/class-algolia-searchable-posts-index.php
r2350155 r2608099 468 468 } 469 469 /** 470 * Get post records count.470 * Set post records count. 471 471 * 472 472 * @author WebDevStudios <[email protected]> -
wp-search-with-algolia/tags/2.1.0/includes/libraries/algoliasearch-client-php/src/Algolia.php
r2571200 r2608099 11 11 final class Algolia 12 12 { 13 const VERSION = '3. 0.2';13 const VERSION = '3.1.0'; 14 14 15 15 /** -
wp-search-with-algolia/tags/2.1.0/includes/libraries/algoliasearch-client-php/src/Config/RecommendationConfig.php
r2571200 r2608099 3 3 namespace Algolia\AlgoliaSearch\Config; 4 4 5 /** 6 * @deprecated Please use Algolia\AlgoliaSearch\Config\PersonalizationConfig instead 7 */ 5 8 final class RecommendationConfig extends AbstractConfig 6 9 { -
wp-search-with-algolia/tags/2.1.0/includes/libraries/algoliasearch-client-php/src/RecommendationClient.php
r2571200 r2608099 8 8 use Algolia\AlgoliaSearch\RetryStrategy\ClusterHosts; 9 9 10 /** 11 * @deprecated Please use Algolia\AlgoliaSearch\PersonalizationClient instead 12 */ 10 13 final class RecommendationClient 11 14 { -
wp-search-with-algolia/tags/2.1.0/includes/libraries/algoliasearch-client-php/src/SearchClient.php
r2571200 r2608099 155 155 } 156 156 157 public function search($queries, $requestOptions = []) 158 { 159 return $this->multipleQueries($queries, $requestOptions); 160 } 161 157 162 public function multipleQueries($queries, $requestOptions = []) 158 163 { … … 261 266 /** 262 267 * @deprecated endpoint will be deprecated 263 * @see RecommendationClient268 * @see PersonalizationClient 264 269 */ 265 270 public function getPersonalizationStrategy($requestOptions = []) … … 270 275 /** 271 276 * @deprecated endpoint will be deprecated 272 * @see RecommendationClient277 * @see PersonalizationClient 273 278 */ 274 279 public function setPersonalizationStrategy($strategy, $requestOptions = []) -
wp-search-with-algolia/trunk/README.txt
r2572427 r2608099 5 5 Tested up to: 5.8 6 6 Requires PHP: 7.2 7 Stable tag: 2. 0.17 Stable tag: 2.1.0 8 8 License: GNU General Public License v2.0, MIT License 9 9 … … 107 107 Follow along with the changelog on [Github](https://github.com/WebDevStudios/wp-search-with-algolia/releases). 108 108 109 = 2.1.0 = 110 * Add algolia_update_records filter to allow inspection and filtering records during update operation. 111 * Add algolia_re_index_records filter to allow inspection and filtering records during re-index operation. 112 * Catch some Aloglia PHP Client exceptions that were previously uncaught during record updating and re-indexing. 113 * Fix an issue where SearchIndex::saveObjects was called twice during re-index operations. 114 * Update Algolia PHP API Client to 3.1.0 115 109 116 = 2.0.1 = 110 117 * Fix for users that enable intstantsearch but not autocomplete by adding algoliasearch client as direct dependency of both -
wp-search-with-algolia/trunk/algolia.php
r2572427 r2608099 4 4 * Plugin URI: https://github.com/WebDevStudios/wp-search-with-algolia 5 5 * Description: Integrate the powerful Algolia search service with WordPress 6 * Version: 2. 0.16 * Version: 2.1.0 7 7 * Requires at least: 5.0 8 8 * Requires PHP: 7.2 … … 27 27 28 28 // The Algolia Search plugin version. 29 define( 'ALGOLIA_VERSION', '2. 0.1' );29 define( 'ALGOLIA_VERSION', '2.1.0' ); 30 30 31 31 // The minmum required PHP version. -
wp-search-with-algolia/trunk/includes/indices/class-algolia-index.php
r2465306 r2608099 59 59 */ 60 60 protected $contains_only; 61 62 /** 63 * Whether the reindexing operation is running or not. 64 * 65 * @author WebDevStudios <[email protected]> 66 * @since 2.1.0 67 * 68 * @var bool 69 */ 70 protected $reindexing = false; 61 71 62 72 /** … … 323 333 */ 324 334 protected function update_records( $item, array $records ) { 335 325 336 if ( empty( $records ) ) { 326 337 $this->delete_item( $item ); … … 328 339 } 329 340 330 $index = $this->get_index(); 331 $records = $this->sanitize_json_data( $records ); 332 $index->saveObjects( $records ); 341 /** 342 * If update_records is called from re_index, 343 * skip sanitizing and saving records here, 344 * as it will trigger duplicate API calls. 345 */ 346 if ( true === $this->reindexing ) { 347 return; 348 } 349 350 /** 351 * Filters the records to be updated. 352 * 353 * @since 2.1.0 354 * 355 * @param array $records Array of records to update. 356 * @param object $item The item to update records for. 357 * @param string $index_id The index ID without prefix. 358 */ 359 $records = apply_filters( 360 'algolia_update_records', 361 $records, 362 $item, 363 $this->get_id() 364 ); 365 366 try { 367 $sanitized_records = $this->sanitize_json_data( $records ); 368 } catch ( \Throwable $throwable ) { 369 error_log( $throwable->getMessage() ); // phpcs:ignore -- Need a real logger. 370 } 371 372 // Don't saveObjects if sanitize_json_data failed. 373 if ( empty( $sanitized_records ) ) { 374 return; 375 } 376 377 $index = $this->get_index(); 378 379 try { 380 $index->saveObjects( $sanitized_records ); 381 } catch ( \Throwable $throwable ) { 382 error_log( $throwable->getMessage() ); // phpcs:ignore -- Need a real logger. 383 } 333 384 } 334 385 … … 385 436 386 437 $batch_size = (int) $this->get_re_index_batch_size(); 438 387 439 if ( $batch_size < 1 ) { 388 440 throw new InvalidArgumentException( 'Re-index batch size can not be lower than 1.' ); … … 396 448 397 449 $records = array(); 450 451 /** 452 * Set the reindexing bit to true. 453 */ 454 $this->reindexing = true; 455 398 456 foreach ( $items as $item ) { 399 457 if ( ! $this->should_index( $item ) ) { … … 411 469 412 470 if ( ! empty( $records ) ) { 471 472 /** 473 * Filters the records to be reindexed. 474 * 475 * @since 2.1.0 476 * 477 * @param array $records Array of records to re-index. 478 * @param int $page Page to re-index. 479 * @param string $index_id The index ID without prefix. 480 */ 481 $records = apply_filters( 482 'algolia_re_index_records', 483 $records, 484 $page, 485 $this->get_id() 486 ); 487 488 try { 489 $sanitized_records = $this->sanitize_json_data( $records ); 490 } catch ( \Throwable $throwable ) { 491 error_log( $throwable->getMessage() ); // phpcs:ignore -- Need a real logger. 492 } 493 } 494 495 // Don't saveObjects if sanitize_json_data failed. 496 if ( ! empty( $sanitized_records ) ) { 497 413 498 $index = $this->get_index(); 414 499 415 $records = $this->sanitize_json_data( $records ); 416 417 $index->saveObjects( $records ); 418 } 500 try { 501 $index->saveObjects( $sanitized_records ); 502 } catch ( \Throwable $throwable ) { 503 error_log( $throwable->getMessage() ); // phpcs:ignore -- Need a real logger. 504 } 505 } 506 507 /** 508 * Set the reindexing bit back to false. 509 */ 510 $this->reindexing = false; 419 511 420 512 if ( $page === $max_num_pages ) { … … 506 598 * Here we use a private function introduced in WP 4.1. 507 599 * 600 * Since WPSWA v 1.1.0, minimum suppported WordPress version is 5.0. 601 * 508 602 * @author WebDevStudios <[email protected]> 509 603 * @since 1.0.0 … … 513 607 * @return mixed The sanitized data that shall be encoded to JSON. 514 608 * 515 * @throws Exception If depth is less than zero.609 * @throws Exception If depth limit is reached. 516 610 */ 517 611 protected function sanitize_json_data( $data ) { 518 if ( function_exists( '_wp_json_sanity_check' ) ) { 519 return _wp_json_sanity_check( $data, 512 ); 520 } 521 522 return $data; 612 return _wp_json_sanity_check( $data, 512 ); 523 613 } 524 614 -
wp-search-with-algolia/trunk/includes/indices/class-algolia-searchable-posts-index.php
r2350155 r2608099 468 468 } 469 469 /** 470 * Get post records count.470 * Set post records count. 471 471 * 472 472 * @author WebDevStudios <[email protected]> -
wp-search-with-algolia/trunk/includes/libraries/algoliasearch-client-php/src/Algolia.php
r2571200 r2608099 11 11 final class Algolia 12 12 { 13 const VERSION = '3. 0.2';13 const VERSION = '3.1.0'; 14 14 15 15 /** -
wp-search-with-algolia/trunk/includes/libraries/algoliasearch-client-php/src/Config/RecommendationConfig.php
r2571200 r2608099 3 3 namespace Algolia\AlgoliaSearch\Config; 4 4 5 /** 6 * @deprecated Please use Algolia\AlgoliaSearch\Config\PersonalizationConfig instead 7 */ 5 8 final class RecommendationConfig extends AbstractConfig 6 9 { -
wp-search-with-algolia/trunk/includes/libraries/algoliasearch-client-php/src/RecommendationClient.php
r2571200 r2608099 8 8 use Algolia\AlgoliaSearch\RetryStrategy\ClusterHosts; 9 9 10 /** 11 * @deprecated Please use Algolia\AlgoliaSearch\PersonalizationClient instead 12 */ 10 13 final class RecommendationClient 11 14 { -
wp-search-with-algolia/trunk/includes/libraries/algoliasearch-client-php/src/SearchClient.php
r2571200 r2608099 155 155 } 156 156 157 public function search($queries, $requestOptions = []) 158 { 159 return $this->multipleQueries($queries, $requestOptions); 160 } 161 157 162 public function multipleQueries($queries, $requestOptions = []) 158 163 { … … 261 266 /** 262 267 * @deprecated endpoint will be deprecated 263 * @see RecommendationClient268 * @see PersonalizationClient 264 269 */ 265 270 public function getPersonalizationStrategy($requestOptions = []) … … 270 275 /** 271 276 * @deprecated endpoint will be deprecated 272 * @see RecommendationClient277 * @see PersonalizationClient 273 278 */ 274 279 public function setPersonalizationStrategy($strategy, $requestOptions = [])
Note: See TracChangeset
for help on using the changeset viewer.