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

Remove deprecation on Reindex #2151

Merged
merged 2 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Changed `$origin` and `$scale` parameter types of `Elastica\Query\FunctionScore::addDecayFunction()` to allow `float|int|string` [#2144](https://github.com/ruflin/Elastica/pull/2144)
* Changed `$key` parameter type of `Elastica\Multi\Search::addSearch()` to allow `int|string|null` [#2144](https://github.com/ruflin/Elastica/pull/2144)
* Changed `$options` parameter type of `Elastica\Index::create()` to only allow `array<string, mixed>` [#2147](https://github.com/ruflin/Elastica/pull/2147)
* Changed `Elastica\Reindex::setWaitForCompletion()` to only allow `bool` [#2151](https://github.com/ruflin/Elastica/pull/2151)
### Added
* Added support for PHP 8.2 [#2136](https://github.com/ruflin/Elastica/pull/2136)
### Changed
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,6 @@ parameters:
count: 1
path: tests/QueryBuilderTest.php

-
message: "#^Parameter \\#1 \\$value of method Elastica\\\\Reindex\\:\\:setWaitForCompletion\\(\\) expects bool, string given\\.$#"
count: 1
path: tests/ReindexTest.php

-
message: "#^Expression \"\\$index\\-\\>search\\('elastica search'\\)\\[3\\]\" on a separate line does not do anything\\.$#"
count: 1
Expand Down
13 changes: 2 additions & 11 deletions src/Reindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,9 @@ public function run(): Response
return $this->_lastResponse;
}

/**
* @param bool $value
*/
public function setWaitForCompletion($value): void
public function setWaitForCompletion(bool $value): void
{
if (\is_bool($value)) {
$value = $value ? 'true' : 'false';
} else {
\trigger_deprecation('ruflin/elastica', '7.2.0', 'Passing anything else than a boolean as 1st argument to "%s()" is deprecated, pass a boolean instead. It will be removed in 8.0.', __METHOD__);
}

$this->setParam(self::WAIT_FOR_COMPLETION, $value);
$this->setParam(self::WAIT_FOR_COMPLETION, $value ? 'true' : 'false');
}

public function setWaitForActiveShards($value): void
Expand Down
18 changes: 0 additions & 18 deletions tests/ReindexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,24 +149,6 @@ public function testReindexWithFalseSetOnWaitForCompletion(): void
$this->assertNotEmpty($reindex->getTaskId());
}

/**
* @group functional
* @group legacy
*/
public function testReindexWithDeprecatedConstantSetOnWaitForCompletion(): void
{
$oldIndex = $this->_createIndex('idx1', true, 2);
$this->_addDocs($oldIndex, 10);

$newIndex = $this->_createIndex('idx2', true, 2);

$reindex = new Reindex($oldIndex, $newIndex);
$reindex->setWaitForCompletion(Reindex::WAIT_FOR_COMPLETION_FALSE);
$reindex->run();

$this->assertNotEmpty($reindex->getTaskId());
}

/**
* @group functional
*/
Expand Down