Skip to content

PHPLIB-1545: Deprecate CreateCollection flags option and related constants #1477

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

Merged
merged 1 commit into from
Oct 9, 2024
Merged
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
7 changes: 7 additions & 0 deletions src/Operation/CreateCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
*/
class CreateCollection implements Executable
{
/** @deprecated 1.21 */
public const USE_POWER_OF_2_SIZES = 1;

/** @deprecated 1.21 */
public const NO_PADDING = 2;

/**
Expand Down Expand Up @@ -233,6 +236,10 @@ public function __construct(private string $databaseName, private string $collec
trigger_error('The "autoIndexId" option is deprecated and will be removed in version 2.0', E_USER_DEPRECATED);
}

if (isset($this->options['flags'])) {
trigger_error('The "flags" option is deprecated and will be removed in version 2.0', E_USER_DEPRECATED);
}

if (isset($this->options['pipeline']) && ! is_pipeline($this->options['pipeline'], true /* allowEmpty */)) {
throw new InvalidArgumentException('"pipeline" option is not a valid aggregation pipeline');
}
Expand Down
7 changes: 7 additions & 0 deletions tests/Operation/CreateCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,11 @@ public function testAutoIndexIdOptionIsDeprecated(): void
new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), ['autoIndexId' => false]);
});
}

public function testFlagsOptionIsDeprecated(): void
{
$this->assertDeprecated(function (): void {
new CreateCollection($this->getDatabaseName(), $this->getCollectionName(), ['flags' => CreateCollection::USE_POWER_OF_2_SIZES]);
});
}
}