Repository navigation
Merge v2.5 into v2.x #2202
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
mongodb-drivers-pr-bot
merged 3 commits into
v2.x
from
merge-v2.5-into-v2.x-1793359444850
Oct 30, 2026
+459
−23
Merged
Merge v2.5 into v2.x #2202
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| name: "FrankenPHP" | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - "v*.*" | ||
| - "feature/*" | ||
| push: | ||
| branches: | ||
| - "v*.*" | ||
| - "feature/*" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| thread-reboot: | ||
| name: "FrankenPHP in-process thread reboot" | ||
| runs-on: "ubuntu-24.04" | ||
|
|
||
| services: | ||
| mongodb: | ||
| # Single-node replica set with a built-in healthcheck, which the runner | ||
| # waits for before running the steps. | ||
| image: "mongodb/mongodb-atlas-local:8.0" | ||
| ports: | ||
| - "27017:27017" | ||
|
|
||
| env: | ||
| # The FrankenPHP container reaches the service through the Docker host. | ||
| MONGODB_URI: "mongodb://host.docker.internal:27017/?directConnection=true&serverSelectionTimeoutMS=2000" | ||
|
|
||
| steps: | ||
| - name: "Checkout" | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| submodules: true | ||
|
|
||
| - name: "Set up Docker buildx" | ||
| uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 | ||
|
|
||
| - name: "Build the image with the driver" | ||
| uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 | ||
| with: | ||
| context: "." | ||
| file: "tests/frankenphp/Dockerfile" | ||
| tags: "mongodb-frankenphp" | ||
| load: true | ||
| # Layer cache shared between runs: dependency layers and the extension | ||
| # build are reused when the sources they depend on did not change. | ||
| cache-from: "type=gha" | ||
| cache-to: "type=gha,mode=max" | ||
|
|
||
| - name: "Run the restart test" | ||
| run: "SKIP_BUILD=1 bash tests/frankenphp/restart-test.sh" | ||
| env: | ||
| IMAGE_NAME: "mongodb-frankenphp" | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --TEST-- | ||
| MongoDB\BSON\Document: Encoding duplicate keys | ||
| --DESCRIPTION-- | ||
| BSON corpus spec prose test #2.1 (encoding) | ||
| https://github.com/mongodb/specifications/blob/master/source/bson-corpus/bson-corpus.md#21-test-encoding | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| require_once __DIR__ . '/../utils/basic.inc'; | ||
|
|
||
| /* PHPC does not expose a BSON builder API. PHP arrays and objects cannot hold | ||
| * duplicate keys, so the duplicate keys below are collapsed by PHP itself | ||
| * before reaching the driver. */ | ||
| $document = MongoDB\BSON\Document::fromPHP(['foo' => 1, 'foo' => 2]); | ||
|
|
||
| echo "PHP collapses duplicate keys, keeping the last value\n"; | ||
| echo $document->toRelaxedExtendedJSON(), "\n"; | ||
| var_dump((string) $document === hex2bin('0e00000010666f6f000200000000')); | ||
|
|
||
| ?> | ||
| ===DONE=== | ||
| <?php exit(0); ?> | ||
| --EXPECT-- | ||
| PHP collapses duplicate keys, keeping the last value | ||
| { "foo" : 2 } | ||
| bool(true) | ||
| ===DONE=== |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| --TEST-- | ||
| MongoDB\BSON\Document: Decoding BSON with duplicate keys | ||
| --DESCRIPTION-- | ||
| BSON corpus spec prose test #2.2 (decoding) | ||
| https://github.com/mongodb/specifications/blob/master/source/bson-corpus/bson-corpus.md#22-test-decoding | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| require_once __DIR__ . '/../utils/basic.inc'; | ||
|
|
||
| /* Duplicate keys are not validated by the driver. This test documents how each | ||
| * decoding API behaves. Bytes represent BSON for { "foo": 1, "foo": 2 } */ | ||
| $document = MongoDB\BSON\Document::fromBSON(hex2bin('1700000010666f6f000100000010666f6f000200000000')); | ||
|
|
||
| echo "Iteration returns both elements in order\n"; | ||
| foreach ($document as $key => $value) { | ||
| var_dump($key, $value); | ||
| } | ||
|
|
||
| echo "\nget() and offsetGet() return the first value\n"; | ||
| var_dump($document->get('foo')); | ||
| var_dump($document['foo']); | ||
| var_dump($document->has('foo')); | ||
|
|
||
| echo "\ntoPHP() keeps the last value for object type maps\n"; | ||
| var_dump($document->toPHP()); | ||
| var_dump($document->toPHP(['root' => 'object'])); | ||
|
|
||
| echo "\ntoPHP() keeps the last value for array type maps\n"; | ||
| var_dump($document->toPHP(['root' => 'array'])); | ||
|
|
||
| echo "\ntoPHP() with the bson type map preserves duplicates\n"; | ||
| $bsonDocument = $document->toPHP(['root' => 'bson']); | ||
| var_dump($bsonDocument instanceof MongoDB\BSON\Document); | ||
| echo $bsonDocument->toRelaxedExtendedJSON(), "\n"; | ||
|
|
||
| echo "\nExtended JSON preserves duplicates\n"; | ||
| echo $document->toRelaxedExtendedJSON(), "\n"; | ||
| echo $document->toCanonicalExtendedJSON(), "\n"; | ||
|
|
||
| ?> | ||
| ===DONE=== | ||
| <?php exit(0); ?> | ||
| --EXPECTF-- | ||
| Iteration returns both elements in order | ||
| string(3) "foo" | ||
| int(1) | ||
| string(3) "foo" | ||
| int(2) | ||
|
|
||
| get() and offsetGet() return the first value | ||
| int(1) | ||
| int(1) | ||
| bool(true) | ||
|
|
||
| toPHP() keeps the last value for object type maps | ||
| object(stdClass)#%d (1) { | ||
| ["foo"]=> | ||
| int(2) | ||
| } | ||
| object(stdClass)#%d (1) { | ||
| ["foo"]=> | ||
| int(2) | ||
| } | ||
|
|
||
| toPHP() keeps the last value for array type maps | ||
| array(1) { | ||
| ["foo"]=> | ||
| int(2) | ||
| } | ||
|
|
||
| toPHP() with the bson type map preserves duplicates | ||
| bool(true) | ||
| { "foo" : 1, "foo" : 2 } | ||
|
|
||
| Extended JSON preserves duplicates | ||
| { "foo" : 1, "foo" : 2 } | ||
| { "foo" : { "$numberInt" : "1" }, "foo" : { "$numberInt" : "2" } } | ||
| ===DONE=== |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| --TEST-- | ||
| MongoDB\BSON\Document: Round-trip of BSON with duplicate keys | ||
| --DESCRIPTION-- | ||
| BSON corpus spec prose test #2.3 (round-trip) | ||
| https://github.com/mongodb/specifications/blob/master/source/bson-corpus/bson-corpus.md#23-test-round-trip | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| require_once __DIR__ . '/../utils/basic.inc'; | ||
|
|
||
| /* Bytes represent BSON for { "foo": 1, "foo": 2 } */ | ||
| $bson = hex2bin('1700000010666f6f000100000010666f6f000200000000'); | ||
| $document = MongoDB\BSON\Document::fromBSON($bson); | ||
|
|
||
| echo "Raw BSON is preserved\n"; | ||
| var_dump((string) $document === $bson); | ||
|
|
||
| echo "\nRound-trip through Extended JSON preserves duplicates\n"; | ||
| $fromJson = MongoDB\BSON\Document::fromJSON($document->toRelaxedExtendedJSON()); | ||
| echo $fromJson->toRelaxedExtendedJSON(), "\n"; | ||
| var_dump((string) $fromJson === $bson); | ||
|
|
||
| echo "\nRound-trip through PHP keeps the last value\n"; | ||
| $roundTrip = MongoDB\BSON\Document::fromPHP($document->toPHP()); | ||
| echo $roundTrip->toRelaxedExtendedJSON(), "\n"; | ||
| var_dump((string) $roundTrip === $bson); | ||
|
|
||
| ?> | ||
| ===DONE=== | ||
| <?php exit(0); ?> | ||
| --EXPECT-- | ||
| Raw BSON is preserved | ||
| bool(true) | ||
|
|
||
| Round-trip through Extended JSON preserves duplicates | ||
| { "foo" : 1, "foo" : 2 } | ||
| bool(true) | ||
|
|
||
| Round-trip through PHP keeps the last value | ||
| { "foo" : 2 } | ||
| bool(false) | ||
| ===DONE=== |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --TEST-- | ||
| MongoDB\BSON\Document: Parsing Extended JSON with duplicate keys | ||
| --DESCRIPTION-- | ||
| BSON corpus spec prose test #2.4 (parsing Extended JSON) | ||
| https://github.com/mongodb/specifications/blob/master/source/bson-corpus/bson-corpus.md#24-test-parsing-extended-json | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| require_once __DIR__ . '/../utils/basic.inc'; | ||
|
|
||
| /* Bytes represent BSON for { "foo": 1, "foo": 2 } */ | ||
| $expected = hex2bin('1700000010666f6f000100000010666f6f000200000000'); | ||
|
|
||
| $document = MongoDB\BSON\Document::fromJSON('{ "foo": 1, "foo": 2 }'); | ||
|
|
||
| echo "Duplicate keys are preserved in order\n"; | ||
| echo $document->toRelaxedExtendedJSON(), "\n"; | ||
| var_dump((string) $document === $expected); | ||
|
|
||
| ?> | ||
| ===DONE=== | ||
| <?php exit(0); ?> | ||
| --EXPECT-- | ||
| Duplicate keys are preserved in order | ||
| { "foo" : 1, "foo" : 2 } | ||
| bool(true) | ||
| ===DONE=== |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| auto_https off | ||
| } | ||
|
|
||
| :80 { | ||
| root * /app/public | ||
| php_server { | ||
| worker { | ||
| file /app/public/worker.php | ||
| # A single worker, so a different instance identifier can only come | ||
| # from a restart of that worker. | ||
| num 1 | ||
| # All requests go to the worker, whatever the requested path is. | ||
| match * | ||
| } | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Builds the extension from this checkout into the FrankenPHP image, so the | ||
| # functional test runs against the PHP build that FrankenPHP embeds (ZTS). | ||
| FROM dunglas/frankenphp:1.13.4-php8.5 | ||
|
|
||
| # Dependencies needed by the bundled libmongoc and libmongocrypt builds. | ||
| RUN apt-get update && \ | ||
| apt-get install --yes --no-install-recommends cmake libssl-dev libsasl2-dev && \ | ||
| rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY config.m4 Makefile.frag phongo.c phongo.h phongo_version.h /usr/src/mongodb/ | ||
| COPY scripts /usr/src/mongodb/scripts | ||
| COPY src /usr/src/mongodb/src | ||
|
|
||
| WORKDIR /usr/src/mongodb | ||
|
|
||
| RUN phpize && \ | ||
| ./configure --with-php-config="$(command -v php-config)" && \ | ||
| make -j "$(nproc)" && \ | ||
| make install && \ | ||
| docker-php-ext-enable mongodb | ||
|
|
||
| COPY tests/frankenphp/Caddyfile /etc/frankenphp/Caddyfile | ||
| COPY tests/frankenphp/worker.php /app/public/worker.php |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.