Skip to content

Commit 854b73b

Browse files
committed
ClientEncryption::rewrapManyDataKey options are nullable
1 parent 0a76b61 commit 854b73b

File tree

4 files changed

+37
-6
lines changed

4 files changed

+37
-6
lines changed

src/MongoDB/ClientEncryption.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ static PHP_METHOD(MongoDB_Driver_ClientEncryption, rewrapManyDataKey)
402402
PHONGO_PARSE_PARAMETERS_START(1, 2)
403403
PHONGO_PARAM_ARRAY_OR_OBJECT(zfilter)
404404
Z_PARAM_OPTIONAL
405-
Z_PARAM_ARRAY(options)
405+
Z_PARAM_ARRAY_OR_NULL(options)
406406
PHONGO_PARSE_PARAMETERS_END();
407407

408408
php_phongo_zval_to_bson(zfilter, PHONGO_BSON_NONE, &filter, NULL);

src/MongoDB/ClientEncryption.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ final public function getKeys(): \MongoDB\Driver\Cursor {}
7070
final public function removeKeyAltName(\MongoDB\BSON\Binary $keyId, string $keyAltName): ?object {}
7171

7272
#if PHP_VERSION_ID >= 80000
73-
final public function rewrapManyDataKey(array|object $filter, array $options = []): object {}
73+
final public function rewrapManyDataKey(array|object $filter, ?array $options = null): object {}
7474
#else
7575
/** @param array|object $filter */
76-
final public function rewrapManyDataKey($filter, array $options = []): object {}
76+
final public function rewrapManyDataKey($filter, ?array $options = null): object {}
7777
#endif
7878

7979
final public function __wakeup(): void {}

src/MongoDB/ClientEncryption_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 9b64f6db2b6c568fb134f8512968262b25ab0e78 */
2+
* Stub hash: 706125ea8c95ec1b3720909c8351585e03aa4836 */
33

44
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption___construct, 0, 0, 1)
55
ZEND_ARG_TYPE_INFO(0, options, IS_ARRAY, 0)
@@ -61,14 +61,14 @@ ZEND_END_ARG_INFO()
6161
#if PHP_VERSION_ID >= 80000
6262
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption_rewrapManyDataKey, 0, 1, IS_OBJECT, 0)
6363
ZEND_ARG_TYPE_MASK(0, filter, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL)
64-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
64+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null")
6565
ZEND_END_ARG_INFO()
6666
#endif
6767

6868
#if !(PHP_VERSION_ID >= 80000)
6969
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption_rewrapManyDataKey, 0, 1, IS_OBJECT, 0)
7070
ZEND_ARG_INFO(0, filter)
71-
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 0, "[]")
71+
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null")
7272
ZEND_END_ARG_INFO()
7373
#endif
7474

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
MongoDB\Driver\ClientEncryption::rewrapManyDataKey() accepts null for $options
3+
--SKIPIF--
4+
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php skip_if_not_libmongocrypt(); ?>
6+
<?php skip_if_not_live(); ?>
7+
<?php skip_if_server_version('<', '4.2'); ?>
8+
<?php skip_if_not_clean(CSFLE_KEY_VAULT_DATABASE_NAME, CSFLE_KEY_VAULT_COLLECTION_NAME);
9+
--FILE--
10+
<?php
11+
12+
require_once __DIR__ . "/../utils/basic.inc";
13+
14+
$manager = create_test_manager();
15+
16+
$clientEncryption = $manager->createClientEncryption([
17+
'keyVaultNamespace' => CSFLE_KEY_VAULT_NS,
18+
'kmsProviders' => ['local' => ['key' => new MongoDB\BSON\Binary(CSFLE_LOCAL_KEY, 0)]],
19+
]);
20+
21+
var_dump($clientEncryption->rewrapManyDataKey(['_id' => 'no-matching-key'], null));
22+
23+
?>
24+
===DONE===
25+
<?php exit(0); ?>
26+
--EXPECTF--
27+
object(stdClass)#%d (%d) {
28+
["bulkWriteResult"]=>
29+
NULL
30+
}
31+
===DONE===

0 commit comments

Comments
 (0)