Warning
This is a beta release.
While we recommend against production usage due to breaking changes, the code is stable. Please consider whether you can afford the potential upcoming breaking changes before upgrading.
Migration guide
Refactor tasks as objects, and task status and type as enums
This introduces two changes:
- Asynchronous operations now return Tasks as an object instead of an array
- Tasks can be awaited with the new
wait(int $timeoutInMs = 5000, int $intervalInMs = 50): Taskmethod
Awaiting tasks:
// Before
$promise = $this->client->createIndex('new-index', ['primaryKey' => 'objectID']);
$this->index->waitForTask($promise['taskUid']);
// After
$this->client->createIndex('new-index', ['primaryKey' => 'objectID'])->wait();Asserting task status:
// Before
$task = $this->client->getTask($taskUid);
if ($task['status'] === 'succeeded') {
// do something
}
// After
if ($task->getStatus() === TaskStatus::Succeeded) {
// do something
}Asserting task types:
// Before
$task = $this->client->getTask($taskUid);
if ($task['type'] === 'indexCreation') {
// do something
}
// After
$task = $this->client->getTask($taskUid);
if ($task->getType() === TaskType::IndexCreation) {
// do something
}Remove custom exception for JSON parsing
Before: catching SDK-specific JSON exceptions
<?php
try {
$client->index('books')->addDocuments([["title" => "\xB1\x31"]]);
} catch (JsonEncodingException | JsonDecodingException $e) {
// handle JSON errors
}After: catching native PHP JsonException
<?php
try {
$client->index('books')->addDocuments([["title" => "\xB1\x31"]]);
} catch (\JsonException $e) {
// handle JSON errors
}⚠️ Breaking changes
- feat: remove custom json exceptions (#791) @Strift
- Bump to PHP 8.1, improve type safety for Tasks (#735) @norkunas
🚀 Enhancements
- Support sort for
documentsendpoint (#779) @bpolaszek
🐛 Bug Fixes
⚙️ Maintenance/misc
- Update repository config for v2 (#787) @Strift
- fix: reference the correct
php-versionin matrix (#792) @Strift - chore: update ci for v2 (#793) @Strift
- chore: update release drafter (#804) @Strift
- Update dependabot and release template configuration (#806)
- Migrate CI from bors to merge queue (#801) @Strift
- Bump actions/upload-artifact from 4 to 5 (#813) @dependabot[bot]
- Bump actions/download-artifact from 4 to 6 (#812) @dependabot[bot]
Thanks to @Strift, @bpolaszek, and @norkunas! 🎉
See full changelog: v1.16.0...v2.0.0-beta.1