@@ -40,17 +40,22 @@ static void phongo_clientencryption_create_datakey(php_phongo_clientencryption_t
40
40
static void phongo_clientencryption_encrypt (php_phongo_clientencryption_t * clientencryption , zval * zvalue , zval * zciphertext , zval * options );
41
41
static void phongo_clientencryption_decrypt (php_phongo_clientencryption_t * clientencryption , zval * zciphertext , zval * zvalue );
42
42
43
- #define RETVAL_OPTIONAL_BSON_T (reply ) \
44
- do { \
45
- RETVAL_NULL(); \
46
- if (!bson_empty(&(reply))) { \
47
- php_phongo_bson_state state = { 0 }; \
48
- if (!php_phongo_bson_to_zval_ex(bson_get_data(&(reply)), (reply).len, &state)) { \
49
- zval_ptr_dtor(&state.zchild); \
50
- goto cleanup; \
51
- } \
52
- RETVAL_ZVAL(&state.zchild, 0, 1); \
53
- } \
43
+ #define RETVAL_BSON_T (reply ) \
44
+ do { \
45
+ php_phongo_bson_state state = { 0 }; \
46
+ if (!php_phongo_bson_to_zval_ex(bson_get_data(&(reply)), (reply).len, &state)) { \
47
+ zval_ptr_dtor(&state.zchild); \
48
+ goto cleanup; \
49
+ } \
50
+ RETVAL_ZVAL(&state.zchild, 0, 1); \
51
+ } while (0)
52
+
53
+ #define RETVAL_OPTIONAL_BSON_T (reply ) \
54
+ do { \
55
+ RETVAL_NULL(); \
56
+ if (!bson_empty(&(reply))) { \
57
+ RETVAL_BSON_T(reply); \
58
+ } \
54
59
} while (0)
55
60
56
61
/* Returns true if keyid is a UUID Binary value with an appropriate data length;
@@ -133,7 +138,8 @@ static PHP_METHOD(MongoDB_Driver_ClientEncryption, addKeyAltName)
133
138
} /* }}} */
134
139
135
140
/* {{{ proto MongoDB\BSON\Binary MongoDB\Driver\ClientEncryption::createDataKey(string $kmsProvider[, array $options])
136
- Creates a new key document and inserts into the key vault collection. */
141
+ Creates a new key document and inserts into the key vault collection and
142
+ returns its identifier (UUID as a BSON binary with subtype 0x04). */
137
143
static PHP_METHOD (MongoDB_Driver_ClientEncryption , createDataKey )
138
144
{
139
145
char * kms_provider = NULL ;
@@ -183,7 +189,12 @@ static PHP_METHOD(MongoDB_Driver_ClientEncryption, deleteKey)
183
189
goto cleanup ;
184
190
}
185
191
186
- RETVAL_OPTIONAL_BSON_T (reply );
192
+ if (bson_empty (& reply )) {
193
+ phongo_throw_exception (PHONGO_ERROR_UNEXPECTED_VALUE , "mongoc_client_encryption_delete_key returned an empty document" );
194
+ goto cleanup ;
195
+ }
196
+
197
+ RETVAL_BSON_T (reply );
187
198
188
199
cleanup :
189
200
bson_value_destroy (& keyid );
0 commit comments