-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Client Side Encryption
-
None
-
None
-
PHP Drivers
-
Not Needed
-
-
None
-
None
-
None
-
None
-
None
-
None
use MongoDB\BSON\Binary; use MongoDB\Client; class TestDropEncryptedCollection extends TestCase { public function testDropEncryptedCollection(): void { $collectionName = $this->getCollectionName(); $encryptedClient = new Client( $this->getUri(), [], [ 'autoEncryption' => $autoEncryptionOptions = [ 'keyVaultNamespace' => 'encryption.datakeys', 'kmsProviders' => [ 'local' => [ 'key' => new Binary(random_bytes(96)), ], ], //'encryptedFieldsMap' => [], ], ], ); $clientEncryption = $encryptedClient->createClientEncryption($autoEncryptionOptions); $database = $encryptedClient->getDatabase($this->getDatabaseName()); $database->drop(); $database->createEncryptedCollection($collectionName, $clientEncryption, 'local', null, [ 'encryptedFields' => [ 'fields' => [ [ 'keyId' => null, 'path' => 'ssn', 'bsonType' => 'string', ], ], ], ]); $collectionNames = iterator_to_array($database->listCollectionNames()); self::assertCount(3, $collectionNames); $database->dropCollection($collectionName); //$database->dropCollection($collectionName, ['encryptedFields' => []]); $collectionNames = iterator_to_array($database->listCollectionNames()); self::assertCount(0, $collectionNames); } }
When an encrypted collection is dropped, and autoEncryption is enabled, the metadata collections (.esc and .ecoc) must be automatically dropped.
They are removed only in one of the conditions:
- The autoEncryption.encryptedFieldsMap is set in the client driver options. With any value (even an empty array)
- The option encryptedFields is set drop options
$database->dropCollection($collectionName, ['encryptedFields' => []]);
- is related to
-
PHPLIB-851 Queryable encryption support for createCollection and dropCollection
-
- Closed
-