Skip to content

Commit 837285d

Browse files
Merge v1.20 into v1.x (#1699)
2 parents 9b9f774 + 2ef0ff2 commit 837285d

11 files changed

+225
-198
lines changed

src/MongoDB/BulkWrite.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static inline bool php_phongo_bulkwrite_bson_array_has_valid_keys(bson_t* array)
149149
* success; otherwise, false is returned and an exception is thrown. */
150150
static bool php_phongo_bulkwrite_opts_append_array(bson_t* opts, const char* key, zval* zarr)
151151
{
152-
zval* value = php_array_fetch(zarr, key);
152+
zval* value = php_array_fetch_deref(zarr, key);
153153
bson_t b = BSON_INITIALIZER;
154154

155155
if (Z_TYPE_P(value) != IS_OBJECT && Z_TYPE_P(value) != IS_ARRAY) {
@@ -185,7 +185,7 @@ static bool php_phongo_bulkwrite_opts_append_array(bson_t* opts, const char* key
185185
* success; otherwise, false is returned and an exception is thrown. */
186186
static bool php_phongo_bulkwrite_opts_append_document(bson_t* opts, const char* key, zval* zarr)
187187
{
188-
zval* value = php_array_fetch(zarr, key);
188+
zval* value = php_array_fetch_deref(zarr, key);
189189
bson_t b = BSON_INITIALIZER;
190190

191191
if (Z_TYPE_P(value) != IS_OBJECT && Z_TYPE_P(value) != IS_ARRAY) {
@@ -246,10 +246,10 @@ static bool php_phongo_bulkwrite_opt_hint(bson_t* boptions, zval* zoptions)
246246
/* The "hint" option (or "$hint" modifier) must be a string or document.
247247
* Check for both types and merge into BSON options accordingly. */
248248
if (zoptions && php_array_existsc(zoptions, "hint")) {
249-
zend_uchar type = Z_TYPE_P(php_array_fetchc(zoptions, "hint"));
249+
zend_uchar type = Z_TYPE_P(php_array_fetchc_deref(zoptions, "hint"));
250250

251251
if (type == IS_STRING) {
252-
zval* value = php_array_fetchc(zoptions, "hint");
252+
zval* value = php_array_fetchc_deref(zoptions, "hint");
253253

254254
if (!bson_append_utf8(boptions, "hint", 4, Z_STRVAL_P(value), Z_STRLEN_P(value))) {
255255
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Error appending \"hint\" option");
@@ -343,7 +343,7 @@ static PHP_METHOD(MongoDB_Driver_BulkWrite, __construct)
343343
}
344344

345345
if (options && php_array_existsc(options, "let")) {
346-
zval* value = php_array_fetch(options, "let");
346+
zval* value = php_array_fetchc_deref(options, "let");
347347

348348
if (Z_TYPE_P(value) != IS_OBJECT && Z_TYPE_P(value) != IS_ARRAY) {
349349
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"let\" option to be array or object, %s given", zend_get_type_by_const(Z_TYPE_P(value)));
@@ -361,7 +361,7 @@ static PHP_METHOD(MongoDB_Driver_BulkWrite, __construct)
361361
}
362362

363363
if (options && php_array_existsc(options, "comment")) {
364-
zval* value = php_array_fetch(options, "comment");
364+
zval* value = php_array_fetchc_deref(options, "comment");
365365

366366
intern->comment = ecalloc(1, sizeof(bson_value_t));
367367
phongo_zval_to_bson_value(value, intern->comment);

src/MongoDB/ClientEncryption.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ static PHP_METHOD(MongoDB_Driver_ClientEncryption, rewrapManyDataKey)
426426
}
427427

428428
if (options && php_array_existsc(options, "masterKey")) {
429-
zval* zmasterkey = php_array_fetchc(options, "masterKey");
429+
zval* zmasterkey = php_array_fetchc_deref(options, "masterKey");
430430

431431
if (Z_TYPE_P(zmasterkey) != IS_OBJECT && Z_TYPE_P(zmasterkey) != IS_ARRAY) {
432432
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"masterKey\" option to be array or object, %s given", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(zmasterkey));
@@ -549,7 +549,7 @@ static mongoc_client_encryption_opts_t* phongo_clientencryption_opts_from_zval(z
549549
}
550550

551551
if (php_array_existsc(options, "keyVaultClient")) {
552-
zval* key_vault_client = php_array_fetch(options, "keyVaultClient");
552+
zval* key_vault_client = php_array_fetchc_deref(options, "keyVaultClient");
553553

554554
if (Z_TYPE_P(key_vault_client) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(key_vault_client), php_phongo_manager_ce)) {
555555
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"keyVaultClient\" option to be %s, %s given", ZSTR_VAL(php_phongo_manager_ce->name), PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(key_vault_client));
@@ -597,7 +597,7 @@ static mongoc_client_encryption_opts_t* phongo_clientencryption_opts_from_zval(z
597597
}
598598

599599
if (php_array_existsc(options, "kmsProviders")) {
600-
zval* kms_providers = php_array_fetchc(options, "kmsProviders");
600+
zval* kms_providers = php_array_fetchc_deref(options, "kmsProviders");
601601
bson_t bson_providers = BSON_INITIALIZER;
602602

603603
if (Z_TYPE_P(kms_providers) != IS_ARRAY && Z_TYPE_P(kms_providers) != IS_OBJECT) {
@@ -615,7 +615,7 @@ static mongoc_client_encryption_opts_t* phongo_clientencryption_opts_from_zval(z
615615
}
616616

617617
if (php_array_existsc(options, "tlsOptions")) {
618-
zval* tls_options = php_array_fetchc(options, "tlsOptions");
618+
zval* tls_options = php_array_fetchc_deref(options, "tlsOptions");
619619
bson_t bson_options = BSON_INITIALIZER;
620620

621621
if (Z_TYPE_P(tls_options) != IS_ARRAY && Z_TYPE_P(tls_options) != IS_OBJECT) {
@@ -706,7 +706,7 @@ static mongoc_client_encryption_datakey_opts_t* phongo_clientencryption_datakey_
706706
}
707707

708708
if (php_array_existsc(options, "keyAltNames")) {
709-
zval* zkeyaltnames = php_array_fetchc(options, "keyAltNames");
709+
zval* zkeyaltnames = php_array_fetchc_deref(options, "keyAltNames");
710710
HashTable* ht_data;
711711
uint32_t keyaltnames_count;
712712
char** keyaltnames;
@@ -768,7 +768,7 @@ static mongoc_client_encryption_datakey_opts_t* phongo_clientencryption_datakey_
768768
}
769769

770770
if (php_array_existsc(options, "keyMaterial")) {
771-
zval* keyMaterial = php_array_fetchc(options, "keyMaterial");
771+
zval* keyMaterial = php_array_fetchc_deref(options, "keyMaterial");
772772

773773
if (Z_TYPE_P(keyMaterial) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(keyMaterial), php_phongo_binary_ce)) {
774774
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"keyMaterial\" option to be %s, %s given", ZSTR_VAL(php_phongo_binary_ce->name), PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(keyMaterial));
@@ -779,7 +779,7 @@ static mongoc_client_encryption_datakey_opts_t* phongo_clientencryption_datakey_
779779
}
780780

781781
if (php_array_existsc(options, "masterKey")) {
782-
zval* zmasterkey = php_array_fetchc(options, "masterKey");
782+
zval* zmasterkey = php_array_fetchc_deref(options, "masterKey");
783783
bson_t masterkey = BSON_INITIALIZER;
784784

785785
if (Z_TYPE_P(zmasterkey) != IS_OBJECT && Z_TYPE_P(zmasterkey) != IS_ARRAY) {
@@ -931,7 +931,7 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
931931
}
932932

933933
if (php_array_existsc(options, "contentionFactor")) {
934-
mongoc_client_encryption_encrypt_opts_set_contention_factor(opts, php_array_fetch_long(options, "contentionFactor"));
934+
mongoc_client_encryption_encrypt_opts_set_contention_factor(opts, php_array_fetchc_long(options, "contentionFactor"));
935935
}
936936

937937
if (php_array_existsc(options, "keyId")) {
@@ -953,7 +953,7 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
953953
int plen;
954954
zend_bool pfree;
955955

956-
keyaltname = php_array_fetch_string(options, "keyAltName", &plen, &pfree);
956+
keyaltname = php_array_fetchc_string(options, "keyAltName", &plen, &pfree);
957957
mongoc_client_encryption_encrypt_opts_set_keyaltname(opts, keyaltname);
958958

959959
if (pfree) {
@@ -966,7 +966,7 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
966966
int plen;
967967
zend_bool pfree;
968968

969-
algorithm = php_array_fetch_string(options, "algorithm", &plen, &pfree);
969+
algorithm = php_array_fetchc_string(options, "algorithm", &plen, &pfree);
970970
mongoc_client_encryption_encrypt_opts_set_algorithm(opts, algorithm);
971971

972972
if (pfree) {
@@ -979,7 +979,7 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
979979
int plen;
980980
zend_bool pfree;
981981

982-
querytype = php_array_fetch_string(options, "queryType", &plen, &pfree);
982+
querytype = php_array_fetchc_string(options, "queryType", &plen, &pfree);
983983
mongoc_client_encryption_encrypt_opts_set_query_type(opts, querytype);
984984

985985
if (pfree) {
@@ -990,7 +990,7 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
990990
if (php_array_existsc(options, "rangeOpts")) {
991991
mongoc_client_encryption_encrypt_range_opts_t* range_opts;
992992

993-
range_opts = phongo_clientencryption_encrypt_range_opts_from_zval(php_array_fetchc(options, "rangeOpts"));
993+
range_opts = phongo_clientencryption_encrypt_range_opts_from_zval(php_array_fetchc_deref(options, "rangeOpts"));
994994

995995
if (!range_opts) {
996996
/* Exception already thrown */

src/MongoDB/Manager.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static bool php_phongo_manager_merge_context_options(zval* zdriverOptions)
7070
return true;
7171
}
7272

73-
zcontext = php_array_fetchc(zdriverOptions, "context");
73+
zcontext = php_array_fetchc_deref(zdriverOptions, "context");
7474
context = php_stream_context_from_zval(zcontext, 1);
7575

7676
if (!context) {
@@ -734,7 +734,7 @@ static PHP_METHOD(MongoDB_Driver_Manager, startSession)
734734
}
735735

736736
if (options && php_array_existsc(options, "defaultTransactionOptions")) {
737-
zval* txn_options = php_array_fetchc(options, "defaultTransactionOptions");
737+
zval* txn_options = php_array_fetchc_deref(options, "defaultTransactionOptions");
738738

739739
/* Thrown exception and return if the defaultTransactionOptions is not an array */
740740
if (Z_TYPE_P(txn_options) != IS_ARRAY) {

src/MongoDB/Query.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ zend_class_entry* php_phongo_query_ce;
3636
* otherwise, false is returned and an exception is thrown. */
3737
static bool php_phongo_query_opts_append_string(bson_t* opts, const char* opts_key, zval* zarr, const char* zarr_key)
3838
{
39-
zval* value = php_array_fetch(zarr, zarr_key);
39+
zval* value = php_array_fetch_deref(zarr, zarr_key);
4040

4141
if (Z_TYPE_P(value) != IS_STRING) {
4242
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"%s\" %s to be string, %s given", zarr_key, zarr_key[0] == '$' ? "modifier" : "option", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(value));
@@ -55,7 +55,7 @@ static bool php_phongo_query_opts_append_string(bson_t* opts, const char* opts_k
5555
* success; otherwise, false is returned and an exception is thrown. */
5656
static bool php_phongo_query_opts_append_document(bson_t* opts, const char* opts_key, zval* zarr, const char* zarr_key)
5757
{
58-
zval* value = php_array_fetch(zarr, zarr_key);
58+
zval* value = php_array_fetch_deref(zarr, zarr_key);
5959
bson_t b = BSON_INITIALIZER;
6060

6161
if (Z_TYPE_P(value) != IS_OBJECT && Z_TYPE_P(value) != IS_ARRAY) {
@@ -172,7 +172,7 @@ static bool php_phongo_query_init_hint(php_phongo_query_t* intern, zval* options
172172
/* The "hint" option (or "$hint" modifier) must be a string or document.
173173
* Check for both types and merge into BSON options accordingly. */
174174
if (php_array_existsc(options, "hint")) {
175-
zend_uchar type = Z_TYPE_P(php_array_fetchc(options, "hint"));
175+
zend_uchar type = Z_TYPE_P(php_array_fetchc_deref(options, "hint"));
176176

177177
if (type == IS_STRING) {
178178
PHONGO_QUERY_OPT_STRING("hint", options, "hint");
@@ -183,7 +183,7 @@ static bool php_phongo_query_init_hint(php_phongo_query_t* intern, zval* options
183183
return false;
184184
}
185185
} else if (modifiers && php_array_existsc(modifiers, "$hint")) {
186-
zend_uchar type = Z_TYPE_P(php_array_fetchc(modifiers, "$hint"));
186+
zend_uchar type = Z_TYPE_P(php_array_fetchc_deref(modifiers, "$hint"));
187187

188188
if (type == IS_STRING) {
189189
PHONGO_QUERY_OPT_STRING("hint", modifiers, "$hint");
@@ -244,7 +244,7 @@ static bool php_phongo_query_init_readconcern(php_phongo_query_t* intern, zval*
244244
return true;
245245
}
246246

247-
read_concern = php_array_fetchc(options, "readConcern");
247+
read_concern = php_array_fetchc_deref(options, "readConcern");
248248

249249
if (Z_TYPE_P(read_concern) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(read_concern), php_phongo_readconcern_ce)) {
250250
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"readConcern\" option to be %s, %s given", ZSTR_VAL(php_phongo_readconcern_ce->name), PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(read_concern));
@@ -331,7 +331,7 @@ bool phongo_query_init(zval* return_value, zval* filter, zval* options)
331331
}
332332

333333
if (php_array_existsc(options, "modifiers")) {
334-
modifiers = php_array_fetchc(options, "modifiers");
334+
modifiers = php_array_fetchc_deref(options, "modifiers");
335335

336336
if (Z_TYPE_P(modifiers) != IS_ARRAY) {
337337
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"modifiers\" option to be array, %s given", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(modifiers));

src/MongoDB/ReadPreference.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ static PHP_METHOD(MongoDB_Driver_ReadPreference, __construct)
273273
}
274274

275275
if (options && php_array_exists(options, "hedge")) {
276-
zval* hedge = php_array_fetchc(options, "hedge");
276+
zval* hedge = php_array_fetchc_deref(options, "hedge");
277277

278278
if (Z_TYPE_P(hedge) == IS_ARRAY || Z_TYPE_P(hedge) == IS_OBJECT) {
279279
bson_t* hedge_doc = bson_new();

src/MongoDB/Session.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ mongoc_transaction_opt_t* php_mongodb_session_parse_transaction_options(zval* op
378378
}
379379

380380
if (php_array_existsc(options, "readConcern")) {
381-
zval* read_concern = php_array_fetchc(options, "readConcern");
381+
zval* read_concern = php_array_fetchc_deref(options, "readConcern");
382382

383383
if (Z_TYPE_P(read_concern) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(read_concern), php_phongo_readconcern_ce)) {
384384
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"readConcern\" option to be %s, %s given", ZSTR_VAL(php_phongo_readconcern_ce->name), PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(read_concern));
@@ -396,7 +396,7 @@ mongoc_transaction_opt_t* php_mongodb_session_parse_transaction_options(zval* op
396396
}
397397

398398
if (php_array_existsc(options, "readPreference")) {
399-
zval* read_preference = php_array_fetchc(options, "readPreference");
399+
zval* read_preference = php_array_fetchc_deref(options, "readPreference");
400400

401401
if (Z_TYPE_P(read_preference) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(read_preference), php_phongo_readpreference_ce)) {
402402
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"readPreference\" option to be %s, %s given", ZSTR_VAL(php_phongo_readpreference_ce->name), PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(read_preference));
@@ -414,7 +414,7 @@ mongoc_transaction_opt_t* php_mongodb_session_parse_transaction_options(zval* op
414414
}
415415

416416
if (php_array_existsc(options, "writeConcern")) {
417-
zval* write_concern = php_array_fetchc(options, "writeConcern");
417+
zval* write_concern = php_array_fetchc_deref(options, "writeConcern");
418418

419419
if (Z_TYPE_P(write_concern) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(write_concern), php_phongo_writeconcern_ce)) {
420420
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"writeConcern\" option to be %s, %s given", ZSTR_VAL(php_phongo_writeconcern_ce->name), PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(write_concern));

0 commit comments

Comments
 (0)