Skip to content

PHPC-2727 PHPC-2728: Bump libmongocrypt 1.19.2 and add stringOpts support#2033

Draft
GromNaN wants to merge 6 commits into
mongodb:v2.xfrom
GromNaN:PHPC-2728
Draft

PHPC-2727 PHPC-2728: Bump libmongocrypt 1.19.2 and add stringOpts support#2033
GromNaN wants to merge 6 commits into
mongodb:v2.xfrom
GromNaN:PHPC-2728

Conversation

@GromNaN

@GromNaN GromNaN commented Jun 29, 2026

Copy link
Copy Markdown
Member

Bumps libmongocrypt from 1.19.0 to 1.19.2 and adds support for the stringOpts option in ClientEncryption::encrypt() for QE string encryption (prefix, suffix, substring query types with case/diacritic sensitivity).

Jira: https://jira.mongodb.org/browse/PHPC-2727
Jira: https://jira.mongodb.org/browse/PHPC-2728

Implements the stringOpts option for explicit string encryption, supporting
prefix, suffix, and substring query types with case/diacritic sensitivity
options, as required by the QE String Explicit Encryption spec (DRIVERS-3321).
@GromNaN GromNaN changed the title PHPC-2728: Add stringOpts support to ClientEncryption::encrypt() PHPC-2728: Add stringOpts support to ClientEncryption::encrypt() Jun 29, 2026
GromNaN added 2 commits June 29, 2026 19:53
Apply clang-format alignment fixes and add a phpt integration test for
ClientEncryption::encrypt() with the stringOpts option (substringPreview).
@GromNaN GromNaN changed the title PHPC-2728: Add stringOpts support to ClientEncryption::encrypt() PHPC-2728: Add stringOpts support to ClientEncryption::encrypt() Jun 29, 2026
@GromNaN GromNaN changed the title PHPC-2728: Add stringOpts support to ClientEncryption::encrypt() PHPC-2727 PHPC-2728: Bump libmongocrypt to 1.19.2 and add stringOpts support Jun 30, 2026
@GromNaN GromNaN changed the title PHPC-2727 PHPC-2728: Bump libmongocrypt to 1.19.2 and add stringOpts support PHPC-2727 PHPC-2728: Bump libmongocrypt 1.19.2 and add stringOpts support Jun 30, 2026
@GromNaN GromNaN marked this pull request as ready for review June 30, 2026 12:49
@GromNaN GromNaN requested a review from a team as a code owner June 30, 2026 12:49
@GromNaN GromNaN requested review from Copilot and paulinevos and removed request for a team June 30, 2026 12:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Bumps the bundled/system minimum libmongocrypt version to 1.19.2 and wires stringOpts through MongoDB\Driver\ClientEncryption::encrypt() to support QE string encryption options (case/diacritic sensitivity and prefix/suffix/substring parameters).

Changes:

  • Add C driver support for stringOpts by translating PHP arrays into mongoc_client_encryption_encrypt_text_opts_t.
  • Add PHPT coverage for successful substringPreview encryption and for integer range validation errors within stringOpts.
  • Bump libmongocrypt version references to 1.19.2 (current version file + system minimum in config.m4).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/clientEncryption/clientEncryption-encrypt-stringOpts-001.phpt New integration test covering successful encryption with stringOpts (substringPreview).
tests/clientEncryption/clientEncryption-encrypt-stringOpts_error-001.phpt New test covering stringOpts integer range validation error messages.
src/MongoDB/ClientEncryption.c Adds stringOpts parsing and passes resulting text opts into libmongoc encryption options.
src/LIBMONGOCRYPT_VERSION_CURRENT Updates bundled/current libmongocrypt version marker to 1.19.2.
config.m4 Raises the minimum required system libmongocrypt version to 1.19.2.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 30, 2026 13:13
@GromNaN GromNaN requested a review from kevinAlbs June 30, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment thread src/MongoDB/ClientEncryption.c Outdated
Comment on lines +862 to +870
int64_t v = php_array_fetchc_long(prefix_zval, "strMaxQueryLength");

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

mongoc_client_encryption_encrypt_text_prefix_opts_set_str_max_query_length(prefix_opts, (int32_t) v);
Comment thread src/MongoDB/ClientEncryption.c Outdated
bson_value_destroy(&keyid);
}

static mongoc_client_encryption_encrypt_text_opts_t* phongo_clientencryption_encrypt_text_opts_from_zval(zval* options)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The name text_opts is inherited from libmongoc/libmongocrypt.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Heads up: the "text" named C driver API is deprecated for newly added "string" names in CDRIVER-6293. But this is not-yet released. It will be released in C driver 2.4.0.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So, this PR can wait the release of C driver 2.4.0.

@kevinAlbs kevinAlbs left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM with a minor suggestion.

Comment thread src/MongoDB/ClientEncryption.c Outdated
bson_value_destroy(&keyid);
}

static mongoc_client_encryption_encrypt_text_opts_t* phongo_clientencryption_encrypt_text_opts_from_zval(zval* options)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Heads up: the "text" named C driver API is deprecated for newly added "string" names in CDRIVER-6293. But this is not-yet released. It will be released in C driver 2.4.0.

Comment thread src/MongoDB/ClientEncryption.c Outdated
Comment on lines +864 to +868
if (v < 0 || v > INT32_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"strMaxQueryLength\" to be a positive 32-bit integer, %" PRId64 " given", v);
mongoc_client_encryption_encrypt_text_prefix_opts_destroy(prefix_opts);
goto cleanup;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
if (v < 0 || v > INT32_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"strMaxQueryLength\" to be a positive 32-bit integer, %" PRId64 " given", v);
mongoc_client_encryption_encrypt_text_prefix_opts_destroy(prefix_opts);
goto cleanup;
}
if (v < INT32_MIN || v > INT32_MAX) {
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT, "Expected \"strMaxQueryLength\" to be a 32-bit integer, %" PRId64 " given", v);
mongoc_client_encryption_encrypt_text_prefix_opts_destroy(prefix_opts);
goto cleanup;
}

Minor: consider only checking that v fits within an int32 before the (int32_t) cast. libmongocrypt further validates the value is greater than 0. This may help avoid a needed change in the PHP driver if that validation is ever changed in libmongocrypt to include 0.

Similar suggestion applies to other int32 checks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done. Note that the behavior changes slightly: values that are negative but fit in an int32 (e.g. -1) are no longer rejected by the PHP driver and instead reach libmongocrypt, which throws an EncryptionException ("'strMaxQueryLength' must be greater than zero"). Values that overflow int32 (e.g. PHP_INT_MAX) are still caught early as InvalidArgumentException. The phpt test has been updated to cover both cases.

@GromNaN GromNaN marked this pull request as draft July 1, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants