PHPC-2486: Require non-null namespace and database arguments in Manager#1963
Merged
alcaeus merged 1 commit intomongodb:v2.xfrom Mar 27, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns MongoDB\Driver\Manager’s internal parameter parsing with its public API contract by disallowing null for database ($db) and namespace ($namespace) arguments in the various execute* methods.
Changes:
- Require non-null database strings for
executeCommand,executeReadCommand,executeWriteCommand, andexecuteReadWriteCommand. - Require non-null namespace strings for
executeQueryandexecuteBulkWrite.
Comments suppressed due to low confidence (1)
src/MongoDB/Manager.c:292
- This change tightens parameter parsing (db/namespace no longer accepts null). There are many PHPTs covering these execute* methods, but none asserting the new failure mode for null inputs; adding regression tests for executeCommand/executeReadCommand/executeWriteCommand/executeReadWriteCommand and executeQuery/executeBulkWrite with a null first argument would help prevent accidental reintroduction (or potential segfaults if arginfo/type checks are bypassed).
PHONGO_PARSE_PARAMETERS_START(2, 3)
Z_PARAM_STRING(db, db_len)
Z_PARAM_OBJECT_OF_CLASS(command, phongo_command_ce)
Z_PARAM_OPTIONAL
Z_PARAM_ZVAL_OR_NULL(options)
PHONGO_PARSE_PARAMETERS_END();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
paulinevos
approved these changes
Mar 26, 2026
Contributor
paulinevos
left a comment
There was a problem hiding this comment.
I know you audited usages, but these are also covered by tests? Do we check coverage in CI actually?
Member
Author
Nope, we don't have any tests for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PHPC-2486
I also audited Server.c to confirm that it uses
Z_PARAM_STRINGin all the right places.