Skip to content

PHPLIB-1702: Always consult server encryptedFieldsMap when dropping collections #1742

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

Open
wants to merge 1 commit into
base: v2.x
Choose a base branch
from

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Aug 8, 2025

@jmikola jmikola requested a review from a team as a code owner August 8, 2025 18:04
@jmikola jmikola requested review from alcaeus and GromNaN August 8, 2025 18:04
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good, I have some comments on the tests.

$client = static::createTestClient();

// Ensure the key vault collection is dropped before each test
$collection = $client->selectCollection('keyvault', 'datakeys', ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll get used to the new name of this method.

Suggested change
$collection = $client->selectCollection('keyvault', 'datakeys', ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]);
$collection = $client->getCollection('keyvault', 'datakeys', ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]);

Why do you need to set the writeConcern, as that doesn't guarantee that all replica are up to date.

$collection->drop();

$this->clientEncryption = $client->createClientEncryption([
'keyVaultNamespace' => 'keyvault.datakeys',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent any typo:

Suggested change
'keyVaultNamespace' => 'keyvault.datakeys',
'keyVaultNamespace' => $collection->getNamespace(),

Otherwise you don't really need the $collection variable.


// Ensure the key vault collection is dropped before each test
$collection = $client->selectCollection('keyvault', 'datakeys', ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]);
$collection->drop();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also drop this collection in tearDown.

$client = static::createTestClient();

// Ensure the key vault collection is dropped before each test
$collection = $client->selectCollection('keyvault', 'datakeys', ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$collection = $client->selectCollection('keyvault', 'datakeys', ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]);
$collection = $client->getCollection('keyvault', 'datakeys', ['writeConcern' => new WriteConcern(WriteConcern::MAJORITY)]);

{
protected ClientEncryption $clientEncryption;

public function setUp(): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both test classes has the same setUp method. They should probably be a single test class with 2 test methods.

Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes LGTM, but should this change target v1.21 for a patch release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants