Skip to content

PHPC-2197: Support queryable encryption range indexes #1409

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 2 commits into from
May 30, 2023
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
157 changes: 156 additions & 1 deletion src/MongoDB/ClientEncryption.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ zend_class_entry* php_phongo_clientencryption_ce;
/* Forward declarations */
static void phongo_clientencryption_create_datakey(php_phongo_clientencryption_t* clientencryption, zval* return_value, char* kms_provider, zval* options);
static void phongo_clientencryption_encrypt(php_phongo_clientencryption_t* clientencryption, zval* zvalue, zval* zciphertext, zval* options);
static void phongo_clientencryption_encrypt_expression(php_phongo_clientencryption_t* clientencryption, zval* zexpr, zval* return_value, zval* options);
static void phongo_clientencryption_decrypt(php_phongo_clientencryption_t* clientencryption, zval* zciphertext, zval* zvalue);

#define RETVAL_BSON_T(reply) \
Expand Down Expand Up @@ -216,6 +217,24 @@ static PHP_METHOD(MongoDB_Driver_ClientEncryption, encrypt)
phongo_clientencryption_encrypt(intern, value, return_value, options);
}

/* Encrypts a value with a given key and algorithm */
static PHP_METHOD(MongoDB_Driver_ClientEncryption, encryptExpression)
{
zval* expr = NULL;
zval* options = NULL;
php_phongo_clientencryption_t* intern;

intern = Z_CLIENTENCRYPTION_OBJ_P(getThis());

PHONGO_PARSE_PARAMETERS_START(1, 2)
Z_PARAM_ZVAL(expr)
Z_PARAM_OPTIONAL
Z_PARAM_ARRAY_OR_NULL(options)
PHONGO_PARSE_PARAMETERS_END();

phongo_clientencryption_encrypt_expression(intern, expr, return_value, options);
}

/* Decrypts an encrypted value (BSON binary of subtype 6). Returns the original BSON value */
static PHP_METHOD(MongoDB_Driver_ClientEncryption, decrypt)
{
Expand Down Expand Up @@ -823,6 +842,76 @@ static void phongo_clientencryption_create_datakey(php_phongo_clientencryption_t
bson_value_destroy(&keyid);
}

static mongoc_client_encryption_encrypt_range_opts_t* phongo_clientencryption_encrypt_range_opts_from_zval(zval* options)
{
mongoc_client_encryption_encrypt_range_opts_t* opts;

opts = mongoc_client_encryption_encrypt_range_opts_new();

if (!options || Z_TYPE_P(options) != IS_ARRAY) {
return opts;
}

if (php_array_existsc(options, "sparsity")) {
int64_t sparsity = php_array_fetchc_long(options, "sparsity");

if (sparsity < 0 || sparsity > INT64_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"sparsity\" range option to be a positive 64-bit integer, %" PRId64 " given", sparsity);
goto cleanup;
}

mongoc_client_encryption_encrypt_range_opts_set_sparsity(opts, sparsity);
}

if (php_array_existsc(options, "precision")) {
int64_t precision = php_array_fetchc_long(options, "precision");

if (precision < 0 || precision > INT32_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"precision\" range option to be a positive 32-bit integer, %" PRId64 " given", precision);
goto cleanup;
}

mongoc_client_encryption_encrypt_range_opts_set_precision(opts, (int32_t) precision);
}

if (php_array_existsc(options, "min")) {
bson_value_t min = { 0 };

php_phongo_zval_to_bson_value(php_array_fetchc(options, "min"), PHONGO_BSON_NONE, &min);

if (EG(exception)) {
bson_value_destroy(&min);
goto cleanup;
}

mongoc_client_encryption_encrypt_range_opts_set_min(opts, &min);
bson_value_destroy(&min);
}

if (php_array_existsc(options, "max")) {
bson_value_t max = { 0 };

php_phongo_zval_to_bson_value(php_array_fetchc(options, "max"), PHONGO_BSON_NONE, &max);

if (EG(exception)) {
bson_value_destroy(&max);
goto cleanup;
}

mongoc_client_encryption_encrypt_range_opts_set_max(opts, &max);
bson_value_destroy(&max);
}

return opts;

cleanup:
if (opts) {
mongoc_client_encryption_encrypt_range_opts_destroy(opts);
}

return NULL;
}

static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_opts_from_zval(zval* options)
{
mongoc_client_encryption_encrypt_opts_t* opts;
Expand Down Expand Up @@ -890,6 +979,20 @@ 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"));

if (!range_opts) {
/* Exception already thrown */
goto cleanup;
}

mongoc_client_encryption_encrypt_opts_set_range_opts(opts, range_opts);
mongoc_client_encryption_encrypt_range_opts_destroy(range_opts);
}

return opts;

cleanup:
Expand All @@ -902,13 +1005,17 @@ static mongoc_client_encryption_encrypt_opts_t* phongo_clientencryption_encrypt_

static void phongo_clientencryption_encrypt(php_phongo_clientencryption_t* clientencryption, zval* zvalue, zval* zciphertext, zval* options)
{
mongoc_client_encryption_encrypt_opts_t* opts;
mongoc_client_encryption_encrypt_opts_t* opts = NULL;
bson_value_t ciphertext = { 0 };
bson_value_t value = { 0 };
bson_error_t error = { 0 };

php_phongo_zval_to_bson_value(zvalue, PHONGO_BSON_NONE, &value);

if (EG(exception)) {
goto cleanup;
}

opts = phongo_clientencryption_encrypt_opts_from_zval(options);

if (!opts) {
Expand All @@ -935,6 +1042,45 @@ static void phongo_clientencryption_encrypt(php_phongo_clientencryption_t* clien
bson_value_destroy(&value);
}

static void phongo_clientencryption_encrypt_expression(php_phongo_clientencryption_t* clientencryption, zval* zexpr, zval* return_value, zval* options)
{
mongoc_client_encryption_encrypt_opts_t* opts = NULL;
bson_t expr = BSON_INITIALIZER;
bson_t expr_encrypted = BSON_INITIALIZER;
bson_error_t error = { 0 };

php_phongo_zval_to_bson(zexpr, PHONGO_BSON_NONE, &expr, NULL);

if (EG(exception)) {
goto cleanup;
}

opts = phongo_clientencryption_encrypt_opts_from_zval(options);

if (!opts) {
/* Exception already thrown */
goto cleanup;
}

if (!mongoc_client_encryption_encrypt_expression(clientencryption->client_encryption, &expr, opts, &expr_encrypted, &error)) {
phongo_throw_exception_from_bson_error_t(&error);
goto cleanup;
}

if (!php_phongo_bson_to_zval(&expr_encrypted, return_value)) {
/* Exception already thrown */
goto cleanup;
}

cleanup:
if (opts) {
mongoc_client_encryption_encrypt_opts_destroy(opts);
}

bson_destroy(&expr);
bson_destroy(&expr_encrypted);
}

static void phongo_clientencryption_decrypt(php_phongo_clientencryption_t* clientencryption, zval* zciphertext, zval* zvalue)
{
bson_value_t ciphertext = { 0 };
Expand All @@ -943,6 +1089,10 @@ static void phongo_clientencryption_decrypt(php_phongo_clientencryption_t* clien

php_phongo_zval_to_bson_value(zciphertext, PHONGO_BSON_NONE, &ciphertext);

if (EG(exception)) {
goto cleanup;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added for consistency but we don't actually test for this since decrypt() expects a Binary and that is always going to successfully encode to BSON.

This is also mentioned in the commit message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean it's inaccessible code, intentionally added? That seems strange to me. A comment in the code would be more appropriate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #1412 (comment) for a recent discussion about this very issue in @alcaeus' PR.

I think ideally we'd use assertions here, as is sometimes done in libmongoc; however, there's no prior art in PHPC for doing so.

I created PHPC-2235 to track this, but I'd prefer to leave this in place for now since it'd be easily detected by tooling should we end up integrating that.

}

if (!mongoc_client_encryption_decrypt(clientencryption->client_encryption, &ciphertext, &value, &error)) {
phongo_throw_exception_from_bson_error_t(&error);
goto cleanup;
Expand Down Expand Up @@ -973,6 +1123,11 @@ static void phongo_clientencryption_encrypt(php_phongo_clientencryption_t* clien
phongo_throw_exception_no_cse(PHONGO_ERROR_RUNTIME, "Cannot encrypt value.");
}

static void phongo_clientencryption_encrypt_expression(php_phongo_clientencryption_t* clientencryption, zval* zexpr, zval* return_value, zval* options)
{
phongo_throw_exception_no_cse(PHONGO_ERROR_RUNTIME, "Cannot encrypt expression.");
}

static void phongo_clientencryption_decrypt(php_phongo_clientencryption_t* clientencryption, zval* zciphertext, zval* zvalue)
{
phongo_throw_exception_no_cse(PHONGO_ERROR_RUNTIME, "Cannot decrypt value.");
Expand Down
19 changes: 19 additions & 0 deletions src/MongoDB/ClientEncryption.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,24 @@ final class ClientEncryption
*/
public const ALGORITHM_UNINDEXED = UNKNOWN;

/**
* @var string
* @cvalue MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW
*/
public const ALGORITHM_RANGE_PREVIEW = UNKNOWN;

/**
* @var string
* @cvalue MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY
*/
public const QUERY_TYPE_EQUALITY = UNKNOWN;

/**
* @var string
* @cvalue MONGOC_ENCRYPT_QUERY_TYPE_RANGEPREVIEW
*/
public const QUERY_TYPE_RANGE_PREVIEW = UNKNOWN;

final public function __construct(array $options) {}

final public function addKeyAltName(\MongoDB\BSON\Binary $keyId, string $keyAltName): ?object {}
Expand All @@ -61,6 +73,13 @@ final public function encrypt(mixed $value, ?array $options = null): \MongoDB\BS
final public function encrypt($value, ?array $options = null): \MongoDB\BSON\Binary {}
#endif

#if PHP_VERSION_ID >= 80000
final public function encryptExpression(array|object $expr, ?array $options = null): object {}
#else
/** @param array|object $expr */
final public function encryptExpression($expr, ?array $options = null): object {}
#endif

final public function getKey(\MongoDB\BSON\Binary $keyId): ?object {}

final public function getKeyByAltName(string $keyAltName): ?object {}
Expand Down
52 changes: 46 additions & 6 deletions src/MongoDB/ClientEncryption_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 706125ea8c95ec1b3720909c8351585e03aa4836 */
* Stub hash: cb36443aeb49b72044a915964006559b4beba4ab */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption___construct, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, options, IS_ARRAY, 0)
Expand Down Expand Up @@ -45,6 +45,20 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryp
ZEND_END_ARG_INFO()
#endif

#if PHP_VERSION_ID >= 80000
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption_encryptExpression, 0, 1, IS_OBJECT, 0)
ZEND_ARG_TYPE_MASK(0, expr, MAY_BE_ARRAY|MAY_BE_OBJECT, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null")
ZEND_END_ARG_INFO()
#endif

#if !(PHP_VERSION_ID >= 80000)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption_encryptExpression, 0, 1, IS_OBJECT, 0)
ZEND_ARG_INFO(0, expr)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, options, IS_ARRAY, 1, "null")
ZEND_END_ARG_INFO()
#endif

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_MongoDB_Driver_ClientEncryption_getKey, 0, 1, IS_OBJECT, 1)
ZEND_ARG_OBJ_INFO(0, keyId, MongoDB\\BSON\\Binary, 0)
ZEND_END_ARG_INFO()
Expand Down Expand Up @@ -92,6 +106,12 @@ static ZEND_METHOD(MongoDB_Driver_ClientEncryption, encrypt);
#if !(PHP_VERSION_ID >= 80000)
static ZEND_METHOD(MongoDB_Driver_ClientEncryption, encrypt);
#endif
#if PHP_VERSION_ID >= 80000
static ZEND_METHOD(MongoDB_Driver_ClientEncryption, encryptExpression);
#endif
#if !(PHP_VERSION_ID >= 80000)
static ZEND_METHOD(MongoDB_Driver_ClientEncryption, encryptExpression);
#endif
static ZEND_METHOD(MongoDB_Driver_ClientEncryption, getKey);
static ZEND_METHOD(MongoDB_Driver_ClientEncryption, getKeyByAltName);
static ZEND_METHOD(MongoDB_Driver_ClientEncryption, getKeys);
Expand Down Expand Up @@ -121,6 +141,12 @@ static const zend_function_entry class_MongoDB_Driver_ClientEncryption_methods[]
#endif
#if !(PHP_VERSION_ID >= 80000)
ZEND_ME(MongoDB_Driver_ClientEncryption, encrypt, arginfo_class_MongoDB_Driver_ClientEncryption_encrypt, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
#endif
#if PHP_VERSION_ID >= 80000
ZEND_ME(MongoDB_Driver_ClientEncryption, encryptExpression, arginfo_class_MongoDB_Driver_ClientEncryption_encryptExpression, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
#endif
#if !(PHP_VERSION_ID >= 80000)
ZEND_ME(MongoDB_Driver_ClientEncryption, encryptExpression, arginfo_class_MongoDB_Driver_ClientEncryption_encryptExpression, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
#endif
ZEND_ME(MongoDB_Driver_ClientEncryption, getKey, arginfo_class_MongoDB_Driver_ClientEncryption_getKey, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
ZEND_ME(MongoDB_Driver_ClientEncryption, getKeyByAltName, arginfo_class_MongoDB_Driver_ClientEncryption_getKeyByAltName, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
Expand All @@ -145,39 +171,53 @@ static zend_class_entry *register_class_MongoDB_Driver_ClientEncryption(void)
class_entry->ce_flags |= ZEND_ACC_FINAL;

zval const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value;
zend_string *const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value_str = zend_string_init(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC, sizeof(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC) - 1, 1);
zend_string *const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value_str = zend_string_init(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC, strlen(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC), 1);
ZVAL_STR(&const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value, const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value_str);
zend_string *const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_name = zend_string_init_interned("AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC", sizeof("AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_name, &const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_AEAD_AES_256_CBC_HMAC_SHA_512_DETERMINISTIC_name);

zval const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value;
zend_string *const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value_str = zend_string_init(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM, sizeof(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM) - 1, 1);
zend_string *const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value_str = zend_string_init(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM, strlen(MONGOC_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM), 1);
ZVAL_STR(&const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value, const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value_str);
zend_string *const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_name = zend_string_init_interned("AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM", sizeof("AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_name, &const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM_name);

zval const_ALGORITHM_INDEXED_value;
zend_string *const_ALGORITHM_INDEXED_value_str = zend_string_init(MONGOC_ENCRYPT_ALGORITHM_INDEXED, sizeof(MONGOC_ENCRYPT_ALGORITHM_INDEXED) - 1, 1);
zend_string *const_ALGORITHM_INDEXED_value_str = zend_string_init(MONGOC_ENCRYPT_ALGORITHM_INDEXED, strlen(MONGOC_ENCRYPT_ALGORITHM_INDEXED), 1);
ZVAL_STR(&const_ALGORITHM_INDEXED_value, const_ALGORITHM_INDEXED_value_str);
zend_string *const_ALGORITHM_INDEXED_name = zend_string_init_interned("ALGORITHM_INDEXED", sizeof("ALGORITHM_INDEXED") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_ALGORITHM_INDEXED_name, &const_ALGORITHM_INDEXED_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_ALGORITHM_INDEXED_name);

zval const_ALGORITHM_UNINDEXED_value;
zend_string *const_ALGORITHM_UNINDEXED_value_str = zend_string_init(MONGOC_ENCRYPT_ALGORITHM_UNINDEXED, sizeof(MONGOC_ENCRYPT_ALGORITHM_UNINDEXED) - 1, 1);
zend_string *const_ALGORITHM_UNINDEXED_value_str = zend_string_init(MONGOC_ENCRYPT_ALGORITHM_UNINDEXED, strlen(MONGOC_ENCRYPT_ALGORITHM_UNINDEXED), 1);
ZVAL_STR(&const_ALGORITHM_UNINDEXED_value, const_ALGORITHM_UNINDEXED_value_str);
zend_string *const_ALGORITHM_UNINDEXED_name = zend_string_init_interned("ALGORITHM_UNINDEXED", sizeof("ALGORITHM_UNINDEXED") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_ALGORITHM_UNINDEXED_name, &const_ALGORITHM_UNINDEXED_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_ALGORITHM_UNINDEXED_name);

zval const_ALGORITHM_RANGE_PREVIEW_value;
zend_string *const_ALGORITHM_RANGE_PREVIEW_value_str = zend_string_init(MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW, strlen(MONGOC_ENCRYPT_ALGORITHM_RANGEPREVIEW), 1);
ZVAL_STR(&const_ALGORITHM_RANGE_PREVIEW_value, const_ALGORITHM_RANGE_PREVIEW_value_str);
zend_string *const_ALGORITHM_RANGE_PREVIEW_name = zend_string_init_interned("ALGORITHM_RANGE_PREVIEW", sizeof("ALGORITHM_RANGE_PREVIEW") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_ALGORITHM_RANGE_PREVIEW_name, &const_ALGORITHM_RANGE_PREVIEW_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_ALGORITHM_RANGE_PREVIEW_name);

zval const_QUERY_TYPE_EQUALITY_value;
zend_string *const_QUERY_TYPE_EQUALITY_value_str = zend_string_init(MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY, sizeof(MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY) - 1, 1);
zend_string *const_QUERY_TYPE_EQUALITY_value_str = zend_string_init(MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY, strlen(MONGOC_ENCRYPT_QUERY_TYPE_EQUALITY), 1);
ZVAL_STR(&const_QUERY_TYPE_EQUALITY_value, const_QUERY_TYPE_EQUALITY_value_str);
zend_string *const_QUERY_TYPE_EQUALITY_name = zend_string_init_interned("QUERY_TYPE_EQUALITY", sizeof("QUERY_TYPE_EQUALITY") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_QUERY_TYPE_EQUALITY_name, &const_QUERY_TYPE_EQUALITY_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_QUERY_TYPE_EQUALITY_name);

zval const_QUERY_TYPE_RANGE_PREVIEW_value;
zend_string *const_QUERY_TYPE_RANGE_PREVIEW_value_str = zend_string_init(MONGOC_ENCRYPT_QUERY_TYPE_RANGEPREVIEW, strlen(MONGOC_ENCRYPT_QUERY_TYPE_RANGEPREVIEW), 1);
ZVAL_STR(&const_QUERY_TYPE_RANGE_PREVIEW_value, const_QUERY_TYPE_RANGE_PREVIEW_value_str);
zend_string *const_QUERY_TYPE_RANGE_PREVIEW_name = zend_string_init_interned("QUERY_TYPE_RANGE_PREVIEW", sizeof("QUERY_TYPE_RANGE_PREVIEW") - 1, 1);
zend_declare_class_constant_ex(class_entry, const_QUERY_TYPE_RANGE_PREVIEW_name, &const_QUERY_TYPE_RANGE_PREVIEW_value, ZEND_ACC_PUBLIC, NULL);
zend_string_release(const_QUERY_TYPE_RANGE_PREVIEW_name);

return class_entry;
}
4 changes: 4 additions & 0 deletions tests/clientEncryption/clientEncryption-constants.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ var_dump(MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_DETERMIN
var_dump(MongoDB\Driver\ClientEncryption::AEAD_AES_256_CBC_HMAC_SHA_512_RANDOM);
var_dump(MongoDB\Driver\ClientEncryption::ALGORITHM_INDEXED);
var_dump(MongoDB\Driver\ClientEncryption::ALGORITHM_UNINDEXED);
var_dump(MongoDB\Driver\ClientEncryption::ALGORITHM_RANGE_PREVIEW);
var_dump(MongoDB\Driver\ClientEncryption::QUERY_TYPE_EQUALITY);
var_dump(MongoDB\Driver\ClientEncryption::QUERY_TYPE_RANGE_PREVIEW);

?>
===DONE===
Expand All @@ -17,5 +19,7 @@ string(43) "AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
string(36) "AEAD_AES_256_CBC_HMAC_SHA_512-Random"
string(7) "Indexed"
string(9) "Unindexed"
string(12) "RangePreview"
string(8) "equality"
string(12) "rangePreview"
===DONE===
Loading