Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: BC Break starting v4.10.0 for batch operations in SearchClient #744

Open
TalkMarc opened this issue Jan 8, 2025 · 1 comment
Open
Assignees

Comments

@TalkMarc
Copy link

TalkMarc commented Jan 8, 2025

Description

The following commit changed the method signature of multiple SearchClient methods, causing existing implementations to break when updating to algoliasearch-client-php v4.10.0 or higher:
50bc69c#diff-54160c7bd8737a7321b4384faa37eda8798b45865a44cab860fb736b08a60057R2945-R2962

Since the commit adds a new parameter in the middle of the established ones, existing code calling these methods with requestOptions (and possibly waitForTasks) will break as the arguments are now misaligned. Missing type checks furthermore causes this to surface as an obscure error (see log output). Only implementations that explicitly used named arguments aren't affected.

The method doc-block also erroneously hints the new batchSize parameter type to be an array.

Minor releases shouldn't contain BC-breaking changes for publicly supported methods. If a new parameter is added, it should be appended at the end as to not break existing method calls for dependents.

Client

Search

Version

4.10, 4.12

Relevant log output

In SearchClient.php line 3112:
                                         
  [Error]                                
  Cannot use a scalar value as an array  
                                         

Exception trace:
  at /srv/sylius/vendor/algolia/algoliasearch-client-php/lib/Api/SearchClient.php:3112
 Algolia\AlgoliaSearch\Api\SearchClient->sendRequest() at /srv/sylius/vendor/algolia/algoliasearch-client-php/lib/Api/SearchClient.php:355
 Algolia\AlgoliaSearch\Api\SearchClient->batch() at /srv/sylius/vendor/algolia/algoliasearch-client-php/lib/Api/SearchClient.php:3028
 Algolia\AlgoliaSearch\Api\SearchClient->chunkedBatch() at /srv/sylius/vendor/algolia/algoliasearch-client-php/lib/Api/SearchClient.php:2961
 Algolia\AlgoliaSearch\Api\SearchClient->saveObjects() at /srv/sylius/src/Client/AlgoliaIndexClientV4.php:27
@gimmer
Copy link

gimmer commented Jan 17, 2025

This change broke our catch up indexing script. As it stands right now, we've fixed it by type hinting arguments in various functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants