Skip to content

Commit

Permalink
Deprecate Reindex::WAIT_FOR_COMPLETION_FALSE
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu committed Jun 3, 2022
1 parent 5970392 commit ef19a69
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
* Updated `symfony/phpunit-bridge` to `6.0` by @franmomu [#2067](https://github.com/ruflin/Elastica/pull/2067)
### Deprecated
* Deprecated `Elastica\Reindex::WAIT_FOR_COMPLETION_FALSE`, use a boolean as parameter instead by @franmomu [#2070](https://github.com/ruflin/Elastica/pull/2070)
* Passing anything else than a boolean as 1st argument to `Reindex::setWaitForCompletion`, pass a boolean instead by @franmomu [#2070](https://github.com/ruflin/Elastica/pull/2070)
### Removed
* Removed `egeloen/http-adapter` as suggested package since the project is abandoned by @franmomu [#2069](https://github.com/ruflin/Elastica/pull/2069)
* Removed `0` as valid request data using Analyze API by @franmomu [#2068](https://github.com/ruflin/Elastica/pull/2068)
Expand Down
6 changes: 6 additions & 0 deletions src/Reindex.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class Reindex extends Param
public const REFRESH_FALSE = 'false';
public const REFRESH_WAIT_FOR = 'wait_for';
public const WAIT_FOR_COMPLETION = 'wait_for_completion';

/**
* @deprecated since version 7.2.0, use a boolean as parameter instead.
*/
public const WAIT_FOR_COMPLETION_FALSE = 'false';
public const WAIT_FOR_ACTIVE_SHARDS = 'wait_for_active_shards';
public const TIMEOUT = 'timeout';
Expand Down Expand Up @@ -80,6 +84,8 @@ public function setWaitForCompletion($value): void
{
if (\is_bool($value)) {
$value = $value ? 'true' : 'false';
} else {
\trigger_deprecation('ruflin/elastica', '7.1.6', '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);
Expand Down
16 changes: 14 additions & 2 deletions tests/ReindexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,25 @@ public function testReindexWithFalseSetOnWaitForCompletion(): void
$newIndex = $this->_createIndex('idx2', true, 2);

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

$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(false);
$reindex->setWaitForCompletion(Reindex::WAIT_FOR_COMPLETION_FALSE);
$reindex->run();

$this->assertNotEmpty($reindex->getTaskId());
Expand Down

0 comments on commit ef19a69

Please sign in to comment.