File tree 5 files changed +39
-3
lines changed
5 files changed +39
-3
lines changed Original file line number Diff line number Diff line change
1
+ # https://github.com/actions/labeler
2
+ docs :
3
+ - changed-files :
4
+ - any-glob-to-any-file : ' docs/**'
5
+ github :
6
+ - changed-files :
7
+ - any-glob-to-any-file : ' .github/**'
Original file line number Diff line number Diff line change
1
+ name : " Pull Request Labeler"
2
+ on :
3
+ - pull_request_target
4
+
5
+ jobs :
6
+ labeler :
7
+ permissions :
8
+ contents : read
9
+ pull-requests : write
10
+ runs-on : ubuntu-latest
11
+ steps :
12
+ - uses : actions/labeler@v5
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
12
12
13
13
* Fix memory leak when filling nested fields using dot notation by @GromNaN in [ #2962 ] ( https://github.com/mongodb/laravel-mongodb/pull/2962 )
14
14
* Fix PHP error when accessing the connection after disconnect by @SanderMuller in [ #2967 ] ( https://github.com/mongodb/laravel-mongodb/pull/2967 )
15
+ * Improve error message for invalid configuration by @GromNaN in [ #2975 ] ( https://github.com/mongodb/laravel-mongodb/pull/2975 )
15
16
16
17
## [ 4.3.0] - 2024-04-26
17
18
Original file line number Diff line number Diff line change @@ -215,6 +215,8 @@ public function disconnect()
215
215
216
216
/**
217
217
* Determine if the given configuration array has a dsn string.
218
+ *
219
+ * @deprecated
218
220
*/
219
221
protected function hasDsnString (array $ config ): bool
220
222
{
@@ -263,9 +265,15 @@ protected function getHostDsn(array $config): string
263
265
*/
264
266
protected function getDsn (array $ config ): string
265
267
{
266
- return $ this ->hasDsnString ($ config )
267
- ? $ this ->getDsnString ($ config )
268
- : $ this ->getHostDsn ($ config );
268
+ if (! empty ($ config ['dsn ' ])) {
269
+ return $ this ->getDsnString ($ config );
270
+ }
271
+
272
+ if (! empty ($ config ['host ' ])) {
273
+ return $ this ->getHostDsn ($ config );
274
+ }
275
+
276
+ throw new InvalidArgumentException ('MongoDB connection configuration requires "dsn" or "host" key. ' );
269
277
}
270
278
271
279
/** @inheritdoc */
Original file line number Diff line number Diff line change @@ -206,6 +206,14 @@ public function testConnectionWithoutConfiguredDatabase(): void
206
206
new Connection (['dsn ' => 'mongodb://some-host ' ]);
207
207
}
208
208
209
+ public function testConnectionWithoutConfiguredDsnOrHost (): void
210
+ {
211
+ $ this ->expectException (InvalidArgumentException::class);
212
+ $ this ->expectExceptionMessage ('MongoDB connection configuration requires "dsn" or "host" key. ' );
213
+
214
+ new Connection (['database ' => 'hello ' ]);
215
+ }
216
+
209
217
public function testCollection ()
210
218
{
211
219
$ collection = DB ::connection ('mongodb ' )->getCollection ('unittest ' );
You can’t perform that action at this time.
0 commit comments