Skip to content

Merge v1.20 into v1.x #1699

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

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/MongoDB/BulkWrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static inline bool php_phongo_bulkwrite_bson_array_has_valid_keys(bson_t* array)
* success; otherwise, false is returned and an exception is thrown. */
static bool php_phongo_bulkwrite_opts_append_array(bson_t* opts, const char* key, zval* zarr)
{
zval* value = php_array_fetch(zarr, key);
zval* value = php_array_fetch_deref(zarr, key);
bson_t b = BSON_INITIALIZER;

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

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

if (type == IS_STRING) {
zval* value = php_array_fetchc(zoptions, "hint");
zval* value = php_array_fetchc_deref(zoptions, "hint");

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

if (options && php_array_existsc(options, "let")) {
zval* value = php_array_fetch(options, "let");
zval* value = php_array_fetchc_deref(options, "let");

if (Z_TYPE_P(value) != IS_OBJECT && Z_TYPE_P(value) != IS_ARRAY) {
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)));
Expand All @@ -361,7 +361,7 @@ static PHP_METHOD(MongoDB_Driver_BulkWrite, __construct)
}

if (options && php_array_existsc(options, "comment")) {
zval* value = php_array_fetch(options, "comment");
zval* value = php_array_fetchc_deref(options, "comment");

intern->comment = ecalloc(1, sizeof(bson_value_t));
phongo_zval_to_bson_value(value, intern->comment);
Expand Down
24 changes: 12 additions & 12 deletions src/MongoDB/ClientEncryption.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ static PHP_METHOD(MongoDB_Driver_ClientEncryption, rewrapManyDataKey)
}

if (options && php_array_existsc(options, "masterKey")) {
zval* zmasterkey = php_array_fetchc(options, "masterKey");
zval* zmasterkey = php_array_fetchc_deref(options, "masterKey");

if (Z_TYPE_P(zmasterkey) != IS_OBJECT && Z_TYPE_P(zmasterkey) != IS_ARRAY) {
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));
Expand Down Expand Up @@ -550,7 +550,7 @@ static mongoc_client_encryption_opts_t* phongo_clientencryption_opts_from_zval(z
}

if (php_array_existsc(options, "keyVaultClient")) {
zval* key_vault_client = php_array_fetch(options, "keyVaultClient");
zval* key_vault_client = php_array_fetchc_deref(options, "keyVaultClient");

if (Z_TYPE_P(key_vault_client) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(key_vault_client), php_phongo_manager_ce)) {
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));
Expand Down Expand Up @@ -598,7 +598,7 @@ static mongoc_client_encryption_opts_t* phongo_clientencryption_opts_from_zval(z
}

if (php_array_existsc(options, "kmsProviders")) {
zval* kms_providers = php_array_fetchc(options, "kmsProviders");
zval* kms_providers = php_array_fetchc_deref(options, "kmsProviders");
bson_t bson_providers = BSON_INITIALIZER;

if (Z_TYPE_P(kms_providers) != IS_ARRAY && Z_TYPE_P(kms_providers) != IS_OBJECT) {
Expand All @@ -616,7 +616,7 @@ static mongoc_client_encryption_opts_t* phongo_clientencryption_opts_from_zval(z
}

if (php_array_existsc(options, "tlsOptions")) {
zval* tls_options = php_array_fetchc(options, "tlsOptions");
zval* tls_options = php_array_fetchc_deref(options, "tlsOptions");
bson_t bson_options = BSON_INITIALIZER;

if (Z_TYPE_P(tls_options) != IS_ARRAY && Z_TYPE_P(tls_options) != IS_OBJECT) {
Expand Down Expand Up @@ -707,7 +707,7 @@ static mongoc_client_encryption_datakey_opts_t* phongo_clientencryption_datakey_
}

if (php_array_existsc(options, "keyAltNames")) {
zval* zkeyaltnames = php_array_fetchc(options, "keyAltNames");
zval* zkeyaltnames = php_array_fetchc_deref(options, "keyAltNames");
HashTable* ht_data;
uint32_t keyaltnames_count;
char** keyaltnames;
Expand Down Expand Up @@ -769,7 +769,7 @@ static mongoc_client_encryption_datakey_opts_t* phongo_clientencryption_datakey_
}

if (php_array_existsc(options, "keyMaterial")) {
zval* keyMaterial = php_array_fetchc(options, "keyMaterial");
zval* keyMaterial = php_array_fetchc_deref(options, "keyMaterial");

if (Z_TYPE_P(keyMaterial) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(keyMaterial), php_phongo_binary_ce)) {
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));
Expand All @@ -780,7 +780,7 @@ static mongoc_client_encryption_datakey_opts_t* phongo_clientencryption_datakey_
}

if (php_array_existsc(options, "masterKey")) {
zval* zmasterkey = php_array_fetchc(options, "masterKey");
zval* zmasterkey = php_array_fetchc_deref(options, "masterKey");
bson_t masterkey = BSON_INITIALIZER;

if (Z_TYPE_P(zmasterkey) != IS_OBJECT && Z_TYPE_P(zmasterkey) != IS_ARRAY) {
Expand Down Expand Up @@ -932,7 +932,7 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
}

if (php_array_existsc(options, "contentionFactor")) {
mongoc_client_encryption_encrypt_opts_set_contention_factor(opts, php_array_fetch_long(options, "contentionFactor"));
mongoc_client_encryption_encrypt_opts_set_contention_factor(opts, php_array_fetchc_long(options, "contentionFactor"));
}

if (php_array_existsc(options, "keyId")) {
Expand All @@ -954,7 +954,7 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
int plen;
zend_bool pfree;

keyaltname = php_array_fetch_string(options, "keyAltName", &plen, &pfree);
keyaltname = php_array_fetchc_string(options, "keyAltName", &plen, &pfree);
mongoc_client_encryption_encrypt_opts_set_keyaltname(opts, keyaltname);

if (pfree) {
Expand All @@ -967,7 +967,7 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
int plen;
zend_bool pfree;

algorithm = php_array_fetch_string(options, "algorithm", &plen, &pfree);
algorithm = php_array_fetchc_string(options, "algorithm", &plen, &pfree);
mongoc_client_encryption_encrypt_opts_set_algorithm(opts, algorithm);

if (pfree) {
Expand All @@ -980,7 +980,7 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
int plen;
zend_bool pfree;

querytype = php_array_fetch_string(options, "queryType", &plen, &pfree);
querytype = php_array_fetchc_string(options, "queryType", &plen, &pfree);
mongoc_client_encryption_encrypt_opts_set_query_type(opts, querytype);

if (pfree) {
Expand All @@ -991,7 +991,7 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_
if (php_array_existsc(options, "rangeOpts")) {
mongoc_client_encryption_encrypt_range_opts_t* range_opts;

range_opts = phongo_clientencryption_encrypt_range_opts_from_zval(php_array_fetchc(options, "rangeOpts"));
range_opts = phongo_clientencryption_encrypt_range_opts_from_zval(php_array_fetchc_deref(options, "rangeOpts"));

if (!range_opts) {
/* Exception already thrown */
Expand Down
4 changes: 2 additions & 2 deletions src/MongoDB/Manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static bool php_phongo_manager_merge_context_options(zval* zdriverOptions)
return true;
}

zcontext = php_array_fetchc(zdriverOptions, "context");
zcontext = php_array_fetchc_deref(zdriverOptions, "context");
context = php_stream_context_from_zval(zcontext, 1);

if (!context) {
Expand Down Expand Up @@ -734,7 +734,7 @@ static PHP_METHOD(MongoDB_Driver_Manager, startSession)
}

if (options && php_array_existsc(options, "defaultTransactionOptions")) {
zval* txn_options = php_array_fetchc(options, "defaultTransactionOptions");
zval* txn_options = php_array_fetchc_deref(options, "defaultTransactionOptions");

/* Thrown exception and return if the defaultTransactionOptions is not an array */
if (Z_TYPE_P(txn_options) != IS_ARRAY) {
Expand Down
12 changes: 6 additions & 6 deletions src/MongoDB/Query.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ zend_class_entry* php_phongo_query_ce;
* otherwise, false is returned and an exception is thrown. */
static bool php_phongo_query_opts_append_string(bson_t* opts, const char* opts_key, zval* zarr, const char* zarr_key)
{
zval* value = php_array_fetch(zarr, zarr_key);
zval* value = php_array_fetch_deref(zarr, zarr_key);

if (Z_TYPE_P(value) != IS_STRING) {
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));
Expand All @@ -55,7 +55,7 @@ static bool php_phongo_query_opts_append_string(bson_t* opts, const char* opts_k
* success; otherwise, false is returned and an exception is thrown. */
static bool php_phongo_query_opts_append_document(bson_t* opts, const char* opts_key, zval* zarr, const char* zarr_key)
{
zval* value = php_array_fetch(zarr, zarr_key);
zval* value = php_array_fetch_deref(zarr, zarr_key);
bson_t b = BSON_INITIALIZER;

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

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

if (type == IS_STRING) {
PHONGO_QUERY_OPT_STRING("hint", modifiers, "$hint");
Expand Down Expand Up @@ -244,7 +244,7 @@ static bool php_phongo_query_init_readconcern(php_phongo_query_t* intern, zval*
return true;
}

read_concern = php_array_fetchc(options, "readConcern");
read_concern = php_array_fetchc_deref(options, "readConcern");

if (Z_TYPE_P(read_concern) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(read_concern), php_phongo_readconcern_ce)) {
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));
Expand Down Expand Up @@ -331,7 +331,7 @@ bool phongo_query_init(zval* return_value, zval* filter, zval* options)
}

if (php_array_existsc(options, "modifiers")) {
modifiers = php_array_fetchc(options, "modifiers");
modifiers = php_array_fetchc_deref(options, "modifiers");

if (Z_TYPE_P(modifiers) != IS_ARRAY) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"modifiers\" option to be array, %s given", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(modifiers));
Expand Down
2 changes: 1 addition & 1 deletion src/MongoDB/ReadPreference.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ static PHP_METHOD(MongoDB_Driver_ReadPreference, __construct)
}

if (options && php_array_exists(options, "hedge")) {
zval* hedge = php_array_fetchc(options, "hedge");
zval* hedge = php_array_fetchc_deref(options, "hedge");

if (Z_TYPE_P(hedge) == IS_ARRAY || Z_TYPE_P(hedge) == IS_OBJECT) {
bson_t* hedge_doc = bson_new();
Expand Down
6 changes: 3 additions & 3 deletions src/MongoDB/Session.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ mongoc_transaction_opt_t* php_mongodb_session_parse_transaction_options(zval* op
}

if (php_array_existsc(options, "readConcern")) {
zval* read_concern = php_array_fetchc(options, "readConcern");
zval* read_concern = php_array_fetchc_deref(options, "readConcern");

if (Z_TYPE_P(read_concern) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(read_concern), php_phongo_readconcern_ce)) {
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));
Expand All @@ -396,7 +396,7 @@ mongoc_transaction_opt_t* php_mongodb_session_parse_transaction_options(zval* op
}

if (php_array_existsc(options, "readPreference")) {
zval* read_preference = php_array_fetchc(options, "readPreference");
zval* read_preference = php_array_fetchc_deref(options, "readPreference");

if (Z_TYPE_P(read_preference) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(read_preference), php_phongo_readpreference_ce)) {
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));
Expand All @@ -414,7 +414,7 @@ mongoc_transaction_opt_t* php_mongodb_session_parse_transaction_options(zval* op
}

if (php_array_existsc(options, "writeConcern")) {
zval* write_concern = php_array_fetchc(options, "writeConcern");
zval* write_concern = php_array_fetchc_deref(options, "writeConcern");

if (Z_TYPE_P(write_concern) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(write_concern), php_phongo_writeconcern_ce)) {
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));
Expand Down
Loading