Plugin Directory

Changeset 2608099


Ignore:
Timestamp:
10/01/2021 11:19:32 PM (4 years ago)
Author:
richaber
Message:

Tagging 2.1.0

Location:
wp-search-with-algolia
Files:
8 added
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-search-with-algolia/tags/2.1.0/README.txt

    r2572427 r2608099  
    55Tested up to: 5.8
    66Requires PHP: 7.2
    7 Stable tag: 2.0.1
     7Stable tag: 2.1.0
    88License: GNU General Public License v2.0, MIT License
    99
     
    107107Follow along with the changelog on [Github](https://github.com/WebDevStudios/wp-search-with-algolia/releases).
    108108
     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
    109116= 2.0.1 =
    110117* 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  
    44 * Plugin URI:        https://github.com/WebDevStudios/wp-search-with-algolia
    55 * Description:       Integrate the powerful Algolia search service with WordPress
    6  * Version:           2.0.1
     6 * Version:           2.1.0
    77 * Requires at least: 5.0
    88 * Requires PHP:      7.2
     
    2727
    2828// The Algolia Search plugin version.
    29 define( 'ALGOLIA_VERSION', '2.0.1' );
     29define( 'ALGOLIA_VERSION', '2.1.0' );
    3030
    3131// The minmum required PHP version.
  • wp-search-with-algolia/tags/2.1.0/includes/indices/class-algolia-index.php

    r2465306 r2608099  
    5959     */
    6060    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;
    6171
    6272    /**
     
    323333     */
    324334    protected function update_records( $item, array $records ) {
     335
    325336        if ( empty( $records ) ) {
    326337            $this->delete_item( $item );
     
    328339        }
    329340
    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        }
    333384    }
    334385
     
    385436
    386437        $batch_size = (int) $this->get_re_index_batch_size();
     438
    387439        if ( $batch_size < 1 ) {
    388440            throw new InvalidArgumentException( 'Re-index batch size can not be lower than 1.' );
     
    396448
    397449        $records = array();
     450
     451        /**
     452         * Set the reindexing bit to true.
     453         */
     454        $this->reindexing = true;
     455
    398456        foreach ( $items as $item ) {
    399457            if ( ! $this->should_index( $item ) ) {
     
    411469
    412470        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
    413498            $index = $this->get_index();
    414499
    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;
    419511
    420512        if ( $page === $max_num_pages ) {
     
    506598     * Here we use a private function introduced in WP 4.1.
    507599     *
     600     * Since WPSWA v 1.1.0, minimum suppported WordPress version is 5.0.
     601     *
    508602     * @author WebDevStudios <[email protected]>
    509603     * @since  1.0.0
     
    513607     * @return mixed The sanitized data that shall be encoded to JSON.
    514608     *
    515      * @throws Exception If depth is less than zero.
     609     * @throws Exception If depth limit is reached.
    516610     */
    517611    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 );
    523613    }
    524614
  • wp-search-with-algolia/tags/2.1.0/includes/indices/class-algolia-searchable-posts-index.php

    r2350155 r2608099  
    468468    }
    469469    /**
    470      * Get post records count.
     470     * Set post records count.
    471471     *
    472472     * @author WebDevStudios <[email protected]>
  • wp-search-with-algolia/tags/2.1.0/includes/libraries/algoliasearch-client-php/src/Algolia.php

    r2571200 r2608099  
    1111final class Algolia
    1212{
    13     const VERSION = '3.0.2';
     13    const VERSION = '3.1.0';
    1414
    1515    /**
  • wp-search-with-algolia/tags/2.1.0/includes/libraries/algoliasearch-client-php/src/Config/RecommendationConfig.php

    r2571200 r2608099  
    33namespace Algolia\AlgoliaSearch\Config;
    44
     5/**
     6 * @deprecated Please use Algolia\AlgoliaSearch\Config\PersonalizationConfig instead
     7 */
    58final class RecommendationConfig extends AbstractConfig
    69{
  • wp-search-with-algolia/tags/2.1.0/includes/libraries/algoliasearch-client-php/src/RecommendationClient.php

    r2571200 r2608099  
    88use Algolia\AlgoliaSearch\RetryStrategy\ClusterHosts;
    99
     10/**
     11 * @deprecated Please use Algolia\AlgoliaSearch\PersonalizationClient instead
     12 */
    1013final class RecommendationClient
    1114{
  • wp-search-with-algolia/tags/2.1.0/includes/libraries/algoliasearch-client-php/src/SearchClient.php

    r2571200 r2608099  
    155155    }
    156156
     157    public function search($queries, $requestOptions = [])
     158    {
     159        return $this->multipleQueries($queries, $requestOptions);
     160    }
     161
    157162    public function multipleQueries($queries, $requestOptions = [])
    158163    {
     
    261266    /**
    262267     * @deprecated endpoint will be deprecated
    263      * @see RecommendationClient
     268     * @see PersonalizationClient
    264269     */
    265270    public function getPersonalizationStrategy($requestOptions = [])
     
    270275    /**
    271276     * @deprecated endpoint will be deprecated
    272      * @see RecommendationClient
     277     * @see PersonalizationClient
    273278     */
    274279    public function setPersonalizationStrategy($strategy, $requestOptions = [])
  • wp-search-with-algolia/trunk/README.txt

    r2572427 r2608099  
    55Tested up to: 5.8
    66Requires PHP: 7.2
    7 Stable tag: 2.0.1
     7Stable tag: 2.1.0
    88License: GNU General Public License v2.0, MIT License
    99
     
    107107Follow along with the changelog on [Github](https://github.com/WebDevStudios/wp-search-with-algolia/releases).
    108108
     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
    109116= 2.0.1 =
    110117* 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  
    44 * Plugin URI:        https://github.com/WebDevStudios/wp-search-with-algolia
    55 * Description:       Integrate the powerful Algolia search service with WordPress
    6  * Version:           2.0.1
     6 * Version:           2.1.0
    77 * Requires at least: 5.0
    88 * Requires PHP:      7.2
     
    2727
    2828// The Algolia Search plugin version.
    29 define( 'ALGOLIA_VERSION', '2.0.1' );
     29define( 'ALGOLIA_VERSION', '2.1.0' );
    3030
    3131// The minmum required PHP version.
  • wp-search-with-algolia/trunk/includes/indices/class-algolia-index.php

    r2465306 r2608099  
    5959     */
    6060    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;
    6171
    6272    /**
     
    323333     */
    324334    protected function update_records( $item, array $records ) {
     335
    325336        if ( empty( $records ) ) {
    326337            $this->delete_item( $item );
     
    328339        }
    329340
    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        }
    333384    }
    334385
     
    385436
    386437        $batch_size = (int) $this->get_re_index_batch_size();
     438
    387439        if ( $batch_size < 1 ) {
    388440            throw new InvalidArgumentException( 'Re-index batch size can not be lower than 1.' );
     
    396448
    397449        $records = array();
     450
     451        /**
     452         * Set the reindexing bit to true.
     453         */
     454        $this->reindexing = true;
     455
    398456        foreach ( $items as $item ) {
    399457            if ( ! $this->should_index( $item ) ) {
     
    411469
    412470        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
    413498            $index = $this->get_index();
    414499
    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;
    419511
    420512        if ( $page === $max_num_pages ) {
     
    506598     * Here we use a private function introduced in WP 4.1.
    507599     *
     600     * Since WPSWA v 1.1.0, minimum suppported WordPress version is 5.0.
     601     *
    508602     * @author WebDevStudios <[email protected]>
    509603     * @since  1.0.0
     
    513607     * @return mixed The sanitized data that shall be encoded to JSON.
    514608     *
    515      * @throws Exception If depth is less than zero.
     609     * @throws Exception If depth limit is reached.
    516610     */
    517611    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 );
    523613    }
    524614
  • wp-search-with-algolia/trunk/includes/indices/class-algolia-searchable-posts-index.php

    r2350155 r2608099  
    468468    }
    469469    /**
    470      * Get post records count.
     470     * Set post records count.
    471471     *
    472472     * @author WebDevStudios <[email protected]>
  • wp-search-with-algolia/trunk/includes/libraries/algoliasearch-client-php/src/Algolia.php

    r2571200 r2608099  
    1111final class Algolia
    1212{
    13     const VERSION = '3.0.2';
     13    const VERSION = '3.1.0';
    1414
    1515    /**
  • wp-search-with-algolia/trunk/includes/libraries/algoliasearch-client-php/src/Config/RecommendationConfig.php

    r2571200 r2608099  
    33namespace Algolia\AlgoliaSearch\Config;
    44
     5/**
     6 * @deprecated Please use Algolia\AlgoliaSearch\Config\PersonalizationConfig instead
     7 */
    58final class RecommendationConfig extends AbstractConfig
    69{
  • wp-search-with-algolia/trunk/includes/libraries/algoliasearch-client-php/src/RecommendationClient.php

    r2571200 r2608099  
    88use Algolia\AlgoliaSearch\RetryStrategy\ClusterHosts;
    99
     10/**
     11 * @deprecated Please use Algolia\AlgoliaSearch\PersonalizationClient instead
     12 */
    1013final class RecommendationClient
    1114{
  • wp-search-with-algolia/trunk/includes/libraries/algoliasearch-client-php/src/SearchClient.php

    r2571200 r2608099  
    155155    }
    156156
     157    public function search($queries, $requestOptions = [])
     158    {
     159        return $this->multipleQueries($queries, $requestOptions);
     160    }
     161
    157162    public function multipleQueries($queries, $requestOptions = [])
    158163    {
     
    261266    /**
    262267     * @deprecated endpoint will be deprecated
    263      * @see RecommendationClient
     268     * @see PersonalizationClient
    264269     */
    265270    public function getPersonalizationStrategy($requestOptions = [])
     
    270275    /**
    271276     * @deprecated endpoint will be deprecated
    272      * @see RecommendationClient
     277     * @see PersonalizationClient
    273278     */
    274279    public function setPersonalizationStrategy($strategy, $requestOptions = [])
Note: See TracChangeset for help on using the changeset viewer.