Skip to content

Commit 730a2ac

Browse files
Merge 5.2 into 5.x (#3330)
2 parents 0d7bc9d + 1265bb1 commit 730a2ac

File tree

8 files changed

+189
-122
lines changed

8 files changed

+189
-122
lines changed

.github/workflows/build-ci-atlas.yml

+21-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ on:
44
push:
55
pull_request:
66

7+
env:
8+
MONGODB_EXT_V1: mongodb-1.21.0
9+
MONGODB_EXT_V2: mongodb-mongodb/[email protected]
10+
711
jobs:
812
build:
913
runs-on: "${{ matrix.os }}"
1014

11-
name: "PHP ${{ matrix.php }} Laravel ${{ matrix.laravel }} Atlas"
15+
name: "PHP/${{ matrix.php }} Laravel/${{ matrix.laravel }} Driver/${{ matrix.driver }}"
1216

1317
strategy:
1418
matrix:
@@ -21,6 +25,13 @@ jobs:
2125
laravel:
2226
- "11.*"
2327
- "12.*"
28+
driver:
29+
- 1
30+
include:
31+
- php: "8.4"
32+
laravel: "12.*"
33+
os: "ubuntu-latest"
34+
driver: 2
2435

2536
steps:
2637
- uses: "actions/checkout@v4"
@@ -39,11 +50,19 @@ jobs:
3950
run: |
4051
docker exec --tty mongodb mongosh --eval "db.runCommand({ serverStatus: 1 })"
4152
53+
- name: Setup cache environment
54+
id: extcache
55+
uses: shivammathur/cache-extensions@v1
56+
with:
57+
php-version: ${{ matrix.php }}
58+
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
59+
key: "extcache-v1"
60+
4261
- name: "Installing php"
4362
uses: "shivammathur/setup-php@v2"
4463
with:
4564
php-version: ${{ matrix.php }}
46-
extensions: "curl,mbstring,xdebug"
65+
extensions: "curl,mbstring,xdebug,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}"
4766
coverage: "xdebug"
4867
tools: "composer"
4968

.github/workflows/build-ci.yml

+23-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ on:
44
push:
55
pull_request:
66

7+
env:
8+
MONGODB_EXT_V1: mongodb-1.21.0
9+
MONGODB_EXT_V2: mongodb-mongodb/[email protected]
10+
711
jobs:
812
build:
913
runs-on: "${{ matrix.os }}"
1014

11-
name: "PHP ${{ matrix.php }} Laravel ${{ matrix.laravel }} MongoDB ${{ matrix.mongodb }} ${{ matrix.mode }}"
15+
name: "PHP/${{ matrix.php }} Laravel/${{ matrix.laravel }} Driver/${{ matrix.driver }} Server/${{ matrix.mongodb }} ${{ matrix.mode }}"
1216

1317
strategy:
1418
matrix:
@@ -29,12 +33,21 @@ jobs:
2933
- "10.*"
3034
- "11.*"
3135
- "12.*"
36+
driver:
37+
- 1
3238
include:
3339
- php: "8.1"
3440
laravel: "10.*"
3541
mongodb: "5.0"
3642
mode: "low-deps"
3743
os: "ubuntu-latest"
44+
driver: 1.x
45+
driver_version: "1.21.0"
46+
- php: "8.4"
47+
laravel: "12.*"
48+
mongodb: "8.0"
49+
os: "ubuntu-latest"
50+
driver: 2
3851
exclude:
3952
- php: "8.1"
4053
laravel: "11.*"
@@ -59,11 +72,19 @@ jobs:
5972
if [ "${{ matrix.mongodb }}" = "4.4" ]; then MONGOSH_BIN="mongo"; else MONGOSH_BIN="mongosh"; fi
6073
docker exec --tty mongodb $MONGOSH_BIN --eval "db.runCommand({ serverStatus: 1 })"
6174
75+
- name: Setup cache environment
76+
id: extcache
77+
uses: shivammathur/cache-extensions@v1
78+
with:
79+
php-version: ${{ matrix.php }}
80+
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
81+
key: "extcache-v1"
82+
6283
- name: "Installing php"
6384
uses: "shivammathur/setup-php@v2"
6485
with:
6586
php-version: ${{ matrix.php }}
66-
extensions: "curl,mbstring,xdebug"
87+
extensions: "curl,mbstring,xdebug,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}"
6788
coverage: "xdebug"
6889
tools: "composer"
6990

.github/workflows/coding-standards.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66

77
env:
8-
PHP_VERSION: "8.2"
8+
PHP_VERSION: "8.4"
99
DRIVER_VERSION: "stable"
1010

1111
jobs:

.github/workflows/static-analysis.yml

+16-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ on:
1313
env:
1414
PHP_VERSION: "8.2"
1515
DRIVER_VERSION: "stable"
16+
MONGODB_EXT_V1: mongodb-1.21.0
17+
MONGODB_EXT_V2: mongodb-mongodb/[email protected]
1618

1719
jobs:
1820
phpstan:
21+
name: "PHP/${{ matrix.php }} Driver/${{ matrix.driver }}"
1922
runs-on: "ubuntu-22.04"
2023
continue-on-error: true
2124
strategy:
@@ -24,6 +27,10 @@ jobs:
2427
- '8.1'
2528
- '8.2'
2629
- '8.3'
30+
- '8.4'
31+
driver:
32+
- 1
33+
- 2
2734
steps:
2835
- name: Checkout
2936
uses: actions/checkout@v4
@@ -35,11 +42,19 @@ jobs:
3542
run: |
3643
echo CHECKED_OUT_SHA=$(git rev-parse HEAD) >> $GITHUB_ENV
3744
45+
- name: Setup cache environment
46+
id: extcache
47+
uses: shivammathur/cache-extensions@v1
48+
with:
49+
php-version: ${{ matrix.php }}
50+
extensions: ${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}
51+
key: "extcache-v1"
52+
3853
- name: Setup PHP
3954
uses: shivammathur/setup-php@v2
4055
with:
4156
php-version: ${{ matrix.php }}
42-
extensions: curl, mbstring
57+
extensions: "curl,mbstring,${{ matrix.driver == 1 && env.MONGODB_EXT_V1 || env.MONGODB_EXT_V2 }}"
4358
tools: composer:v2
4459
coverage: none
4560

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
"license": "MIT",
2424
"require": {
2525
"php": "^8.1",
26-
"ext-mongodb": "^1.21",
26+
"ext-mongodb": "^1.21|^2",
2727
"composer-runtime-api": "^2.0.0",
2828
"illuminate/cache": "^10.36|^11|^12",
2929
"illuminate/container": "^10.0|^11|^12",
3030
"illuminate/database": "^10.30|^11|^12",
3131
"illuminate/events": "^10.0|^11|^12",
3232
"illuminate/support": "^10.0|^11|^12",
33-
"mongodb/mongodb": "^1.21",
33+
"mongodb/mongodb": "^1.21|^2",
3434
"symfony/http-foundation": "^6.4|^7"
3535
},
3636
"require-dev": {

src/Eloquent/Builder.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use MongoDB\Builder\Type\QueryInterface;
1212
use MongoDB\Builder\Type\SearchOperatorInterface;
1313
use MongoDB\Driver\CursorInterface;
14-
use MongoDB\Driver\Exception\WriteException;
14+
use MongoDB\Driver\Exception\BulkWriteException;
1515
use MongoDB\Laravel\Connection;
1616
use MongoDB\Laravel\Helpers\QueriesRelationships;
1717
use MongoDB\Laravel\Query\AggregationBuilder;
@@ -285,7 +285,7 @@ public function createOrFirst(array $attributes = [], array $values = [])
285285

286286
try {
287287
return $this->create(array_merge($attributes, $values));
288-
} catch (WriteException $e) {
288+
} catch (BulkWriteException $e) {
289289
if ($e->getCode() === self::DUPLICATE_KEY_ERROR) {
290290
return $this->where($attributes)->first() ?? throw $e;
291291
}

tests/QueryBuilderTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function testFindWithTimeout()
161161
$id = DB::table('users')->insertGetId(['name' => 'John Doe']);
162162

163163
$subscriber = new class implements CommandSubscriber {
164-
public function commandStarted(CommandStartedEvent $event)
164+
public function commandStarted(CommandStartedEvent $event): void
165165
{
166166
if ($event->getCommandName() !== 'find') {
167167
return;
@@ -171,11 +171,11 @@ public function commandStarted(CommandStartedEvent $event)
171171
Assert::assertSame(1000, $event->getCommand()->maxTimeMS);
172172
}
173173

174-
public function commandFailed(CommandFailedEvent $event)
174+
public function commandFailed(CommandFailedEvent $event): void
175175
{
176176
}
177177

178-
public function commandSucceeded(CommandSucceededEvent $event)
178+
public function commandSucceeded(CommandSucceededEvent $event): void
179179
{
180180
}
181181
};

0 commit comments

Comments
 (0)