Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Deprecated
### Removed
### Fixed
* `Client::deleteIds()` now accepts integer document IDs again by casting them to string before `Action::setId()` [#2316](https://github.com/ruflin/Elastica/issues/2316) [#2318](https://github.com/ruflin/Elastica/pull/2318)
### Security


Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public function deleteIds(array $ids, $index, $routing = false): ResponseSet

foreach ($ids as $id) {
$action = new Action(Action::OP_TYPE_DELETE);
$action->setId($id);
$action->setId((string) $id);

if (!empty($routing)) {
$action->setRouting($routing);
Expand Down
21 changes: 21 additions & 0 deletions tests/ClientFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,27 @@ public function testDeleteIdsIdxObjectTypeObject(): void
$this->assertEquals(0, $totalHits);
}

/**
* Integer IDs must be accepted by deleteIds() after strict_types made
* Action::setId(string) reject implicit int-to-string coercion.
*
* @see https://github.com/ruflin/Elastica/issues/2316
*/
#[Group('functional')]
public function testDeleteIdsWithIntegerIds(): void
{
$index = $this->_createIndex();
$index->addDocument(new Document('185755', ['username' => 'hans']));
$index->refresh();

$this->assertEquals(1, $index->search('username:hans')->getTotalHits());

$index->getClient()->deleteIds([185755], $index);
$index->refresh();

$this->assertEquals(0, $index->search('username:hans')->getTotalHits());
}

public function testOneInvalidConnection(): void
{
$client = $this->_getClient([
Expand Down
Loading