Skip to content

Commit 8030f02

Browse files
authored
Merge pull request #2800 from doctrine/2.11.x
Merge release 2.11.3 into 2.12.x
2 parents f66e9e4 + 5224ec4 commit 8030f02

File tree

11 files changed

+109
-88
lines changed

11 files changed

+109
-88
lines changed

.doctrine-project.json

Lines changed: 28 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,142 +5,107 @@
55
"slug": "mongodb-odm",
66
"docsSlug": "doctrine-mongodb-odm",
77
"versions": [
8+
{
9+
"name": "2.12",
10+
"branchName": "2.12.x",
11+
"slug": "latest",
12+
"upcoming": true
13+
},
14+
{
15+
"name": "2.11",
16+
"branchName": "2.11.x",
17+
"slug": "2.11",
18+
"current": true
19+
},
820
{
921
"name": "2.10",
1022
"branchName": "2.10.x",
11-
"slug": "latest",
12-
"upcoming": true,
13-
"aliases": [
14-
"2.10.x"
15-
]
23+
"slug": "2.10",
24+
"maintained": false
1625
},
1726
{
1827
"name": "2.9",
1928
"branchName": "2.9.x",
2029
"slug": "2.9",
21-
"current": true,
22-
"aliases": [
23-
"current",
24-
"stable",
25-
"2.9.x"
26-
]
30+
"maintained": false
2731
},
2832
{
2933
"name": "2.8",
3034
"branchName": "2.8.x",
3135
"slug": "2.8",
32-
"maintained": false,
33-
"aliases": [
34-
"2.8.x"
35-
]
36+
"maintained": false
3637
},
3738
{
3839
"name": "2.7",
3940
"branchName": "2.7.x",
4041
"slug": "2.7",
41-
"maintained": false,
42-
"aliases": [
43-
"2.7.x"
44-
]
42+
"maintained": false
4543
},
4644
{
4745
"name": "2.6",
4846
"branchName": "2.6.x",
4947
"slug": "2.6",
50-
"maintained": false,
51-
"aliases": [
52-
"2.6.x"
53-
]
48+
"maintained": false
5449
},
5550
{
5651
"name": "2.5",
5752
"branchName": "2.5.x",
5853
"slug": "2.5",
59-
"maintained": false,
60-
"aliases": [
61-
"2.5.x"
62-
]
54+
"maintained": false
6355
},
6456
{
6557
"name": "2.4",
6658
"branchName": "2.4.x",
6759
"slug": "2.4",
68-
"maintained": false,
69-
"aliases": [
70-
"2.4.x"
71-
]
60+
"maintained": false
7261
},
7362
{
7463
"name": "2.3",
7564
"branchName": "2.3.x",
7665
"slug": "2.3",
77-
"maintained": false,
78-
"aliases": [
79-
"2.3.x"
80-
]
66+
"maintained": false
8167
},
8268
{
8369
"name": "2.2",
8470
"branchName": "2.2.x",
8571
"slug": "2.2",
86-
"maintained": false,
87-
"aliases": [
88-
"2.2.x"
89-
]
72+
"maintained": false
9073
},
9174
{
9275
"name": "2.1",
9376
"branchName": "2.1.x",
9477
"slug": "2.1",
95-
"maintained": false,
96-
"aliases": [
97-
"2.1.x"
98-
]
78+
"maintained": false
9979
},
10080
{
10181
"name": "2.0",
10282
"branchName": "2.0.x",
10383
"slug": "2.0",
104-
"maintained": false,
105-
"aliases": [
106-
"2.0.x"
107-
]
84+
"maintained": false
10885
},
10986
{
11087
"name": "1.3",
11188
"branchName": "1.3.x",
11289
"slug": "1.3",
113-
"maintained": false,
114-
"aliases": [
115-
"1.3.x"
116-
]
90+
"maintained": false
11791
},
11892
{
11993
"name": "1.2",
12094
"branchName": "1.2.x",
12195
"slug": "1.2",
122-
"maintained": false,
123-
"aliases": [
124-
"1.2.x"
125-
]
96+
"maintained": false
12697
},
12798
{
12899
"name": "1.1",
129100
"branchName": "1.1.x",
130101
"slug": "1.1",
131-
"maintained": false,
132-
"aliases": [
133-
"1.1.x"
134-
]
102+
"maintained": false
135103
},
136104
{
137105
"name": "1.0",
138106
"branchName": "1.0.x",
139107
"slug": "1.0",
140-
"maintained": false,
141-
"aliases": [
142-
"1.0.x"
143-
]
108+
"maintained": false
144109
}
145110
]
146111
}

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ on:
1111
jobs:
1212
coding-standards:
1313
name: "Coding Standards"
14-
uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.2.2"
14+
uses: "doctrine/.github/.github/workflows/coding-standards.yml@7.3.0"

.github/workflows/continuous-integration.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ jobs:
6262
dependencies: "highest"
6363
symfony-version: "stable"
6464
proxy: "lazy-ghost"
65+
# Test with a 8.0 replica set
66+
- topology: "replica_set"
67+
php-version: "8.2"
68+
mongodb-version: "8.0"
69+
driver-version: "stable"
70+
dependencies: "highest"
71+
symfony-version: "stable"
72+
proxy: "lazy-ghost"
6573
# Test with ProxyManager
6674
- php-version: "8.2"
6775
mongodb-version: "6.0"

.github/workflows/release-on-milestone-closed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
release:
1010
name: "Git tag, release & create merge-up PR"
11-
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@7.2.2"
11+
uses: "doctrine/.github/.github/workflows/release-on-milestone-closed.yml@7.3.0"
1212
secrets:
1313
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
1414
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}

.github/workflows/website-schema.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ on:
1818
jobs:
1919
json-validate:
2020
name: "Validate JSON schema"
21-
uses: "doctrine/.github/.github/workflows/website-schema.yml@7.2.2"
21+
uses: "doctrine/.github/.github/workflows/website-schema.yml@7.3.0"

docs/en/reference/custom-mapping-types.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ a ``DateTimeImmutable`` when the data is read from the database.
2525
use Doctrine\ODM\MongoDB\Types\ClosureToPHP;
2626
use Doctrine\ODM\MongoDB\Types\Type;
2727
use MongoDB\BSON\UTCDateTime;
28+
use RuntimeException;
2829
2930
class DateTimeWithTimezoneType extends Type
3031
{
@@ -33,6 +34,10 @@ a ``DateTimeImmutable`` when the data is read from the database.
3334
3435
public function convertToPHPValue($value): DateTimeImmutable
3536
{
37+
if (!isset($value['utc'], $value['tz'])) {
38+
throw new RuntimeException('Database value cannot be converted to date with timezone. Expected array with "utc" and "tz" keys.');
39+
}
40+
3641
$timeZone = new DateTimeZone($value['tz']);
3742
$dateTime = $value['utc']
3843
->toDateTime()
@@ -43,8 +48,13 @@ a ``DateTimeImmutable`` when the data is read from the database.
4348
4449
public function convertToDatabaseValue($value): array
4550
{
46-
if (! isset($value['utc'], $value['tz'])) {
47-
throw new RuntimeException('Database value cannot be converted to date with timezone. Expected array with "utc" and "tz" keys.');
51+
if (!$value instanceof DateTimeImmutable) {
52+
throw new \RuntimeException(
53+
sprintf(
54+
'Expected instance of \DateTimeImmutable, got %s',
55+
gettype($value)
56+
)
57+
);
4858
}
4959
5060
return [

docs/en/reference/events.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -128,65 +128,65 @@ The DocumentManager and UnitOfWork trigger several events during
128128
the life-time of their registered documents.
129129

130130
-
131-
preRemove - The preRemove event occurs for a given document before
131+
``preRemove`` - The preRemove event occurs for a given document before
132132
the respective DocumentManager remove operation for that document
133133
is executed.
134134
-
135-
postRemove - The postRemove event occurs for a document after the
135+
``postRemove`` - The postRemove event occurs for a document after the
136136
document has been removed. It will be invoked after the database
137137
delete operations.
138138
-
139-
prePersist - The prePersist event occurs for a given document
139+
``prePersist`` - The prePersist event occurs for a given document
140140
before the respective DocumentManager persist operation for that
141141
document is executed.
142142
-
143-
postPersist - The postPersist event occurs for a document after
143+
``postPersist`` - The postPersist event occurs for a document after
144144
the document has been made persistent. It will be invoked after the
145145
database insert operations. Generated primary key values are
146146
available in the postPersist event.
147147
-
148-
preUpdate - The preUpdate event occurs before the database update
148+
``preUpdate`` - The preUpdate event occurs before the database update
149149
operations to document data.
150150
-
151-
postUpdate - The postUpdate event occurs after the database update
151+
``postUpdate`` - The postUpdate event occurs after the database update
152152
operations to document data.
153153
-
154-
preLoad - The preLoad event occurs for a document before the
154+
``preLoad`` - The preLoad event occurs for a document before the
155155
document has been loaded into the current DocumentManager from the
156156
database or after the refresh operation has been applied to it.
157157
-
158-
postLoad - The postLoad event occurs for a document after the
158+
``postLoad`` - The postLoad event occurs for a document after the
159159
document has been loaded into the current DocumentManager from the
160160
database or after the refresh operation has been applied to it.
161161
-
162-
loadClassMetadata - The loadClassMetadata event occurs after the
162+
``loadClassMetadata`` - The loadClassMetadata event occurs after the
163163
mapping metadata for a class has been loaded from a mapping source
164164
(attributes/xml).
165165
-
166-
onClassMetadataNotFound - Loading class metadata for a particular
166+
``onClassMetadataNotFound`` - Loading class metadata for a particular
167167
requested class name failed. Manipulating the given event args instance
168168
allows providing fallback metadata even when no actual metadata exists
169169
or could be found. This event is not a lifecycle callback. Support for this
170170
event was added in MongoDB ODM 1.3.
171171
-
172-
preFlush - The preFlush event occurs before the change-sets of all
172+
``preFlush`` - The preFlush event occurs before the change-sets of all
173173
managed documents are computed. This both a lifecycle call back and
174174
and listener.
175175
-
176-
postFlush - The postFlush event occurs after the change-sets of all
176+
``postFlush`` - The postFlush event occurs after the change-sets of all
177177
managed documents are computed.
178178
-
179-
onFlush - The onFlush event occurs after the change-sets of all
179+
``onFlush`` - The onFlush event occurs after the change-sets of all
180180
managed documents are computed. This event is not a lifecycle
181181
callback.
182182
-
183-
onClear - The onClear event occurs after the UnitOfWork has had
183+
``onClear`` - The onClear event occurs after the UnitOfWork has had
184184
its state cleared.
185185
-
186-
documentNotFound - The documentNotFound event occurs when a proxy object
186+
``documentNotFound`` - The documentNotFound event occurs when a proxy object
187187
could not be initialized. This event is not a lifecycle callback.
188188
-
189-
postCollectionLoad - The postCollectionLoad event occurs just after
189+
``postCollectionLoad`` - The postCollectionLoad event occurs just after
190190
collection has been initialized (loaded) and before new elements
191191
are re-added to it.
192192

lib/Doctrine/ODM/MongoDB/SchemaManager.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ final class SchemaManager
4747

4848
private const CODE_SHARDING_ALREADY_INITIALIZED = 23;
4949
private const CODE_COMMAND_NOT_SUPPORTED = 115;
50+
private const CODE_SEARCH_NOT_ENABLED = 31082;
5051

5152
private const ALLOWED_MISSING_INDEX_OPTIONS = [
5253
'background',
@@ -1079,6 +1080,11 @@ private function getWriteOptions(?int $maxTimeMs = null, ?WriteConcern $writeCon
10791080

10801081
private function isSearchIndexCommandException(CommandException $e): bool
10811082
{
1083+
// MongoDB 8.0+: "Using Atlas Search Database Commands and the $listSearchIndexes aggregation stage requires additional configuration."
1084+
if ($e->getCode() === self::CODE_SEARCH_NOT_ENABLED) {
1085+
return true;
1086+
}
1087+
10821088
// MongoDB 6.0.7+ and 7.0+: "Search indexes are only available on Atlas"
10831089
if ($e->getCode() === self::CODE_COMMAND_NOT_SUPPORTED && str_contains($e->getMessage(), 'Search index')) {
10841090
return true;
@@ -1090,7 +1096,7 @@ private function isSearchIndexCommandException(CommandException $e): bool
10901096
}
10911097

10921098
// Older server versions don't support $listSearchIndexes
1093-
// We don't check for an error code here as the code is not documented and we can't rely on it
1099+
// We don't check for an error code here as the code is not documented, and we can't rely on it
10941100
return str_contains($e->getMessage(), 'Unrecognized pipeline stage name: \'$listSearchIndexes\'');
10951101
}
10961102
}

tests/Doctrine/ODM/MongoDB/Tests/Functional/ReadPreferenceTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use MongoDB\Driver\WriteConcern;
1515
use PHPUnit\Framework\Attributes\DataProvider;
1616

17+
use function usleep;
18+
1719
/** @phpstan-type ReadPreferenceTagShape array{dc?: string, usage?: string} */
1820
class ReadPreferenceTest extends BaseTestCase
1921
{
@@ -57,7 +59,13 @@ public function testHintIsSetOnQuery(string $readPreference, array $tags = []):
5759

5860
$this->assertReadPreferenceHint($readPreference, $query->getQuery()['readPreference'], $tags);
5961

60-
$user = $query->getSingleResult();
62+
$retries = 0;
63+
do {
64+
// Wait a bit to ensure replication has caught up.
65+
usleep(1_000 * $retries);
66+
$user = $query->getSingleResult();
67+
} while ($user === null && $retries++ < 100);
68+
6169
self::assertInstanceOf(User::class, $user);
6270

6371
$groups = $user->getGroups();

tests/Doctrine/ODM/MongoDB/Tests/Functional/TimeSeriesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testCreateTimeSeriesDocumentWithoutId(): void
4141
$document->metadata = 'energy';
4242

4343
$this->dm->persist($document);
44-
$this->dm->flush();
44+
$this->dm->flush(['withTransaction' => false]);
4545

4646
$this->assertCount(1, $this->dm->getDocumentCollection(TimeSeriesDocument::class)->find());
4747
}
@@ -57,7 +57,7 @@ public function testCreateTimeSeriesDocumentWithId(): void
5757
$document->metadata = 'energy';
5858

5959
$this->dm->persist($document);
60-
$this->dm->flush();
60+
$this->dm->flush(['withTransaction' => false]);
6161

6262
$this->assertCount(1, $this->dm->getDocumentCollection(TimeSeriesDocument::class)->find());
6363
}

0 commit comments

Comments
 (0)