File tree Expand file tree Collapse file tree 5 files changed +39
-3
lines changed Expand file tree Collapse file tree 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.
1212
1313* Fix memory leak when filling nested fields using dot notation by @GromNaN in [ #2962 ] ( https://github.com/mongodb/laravel-mongodb/pull/2962 )
1414* 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 )
1516
1617## [ 4.3.0] - 2024-04-26
1718
Original file line number Diff line number Diff line change @@ -215,6 +215,8 @@ public function disconnect()
215215
216216 /**
217217 * Determine if the given configuration array has a dsn string.
218+ *
219+ * @deprecated
218220 */
219221 protected function hasDsnString (array $ config ): bool
220222 {
@@ -263,9 +265,15 @@ protected function getHostDsn(array $config): string
263265 */
264266 protected function getDsn (array $ config ): string
265267 {
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. ' );
269277 }
270278
271279 /** @inheritdoc */
Original file line number Diff line number Diff line change @@ -206,6 +206,14 @@ public function testConnectionWithoutConfiguredDatabase(): void
206206 new Connection (['dsn ' => 'mongodb://some-host ' ]);
207207 }
208208
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+
209217 public function testCollection ()
210218 {
211219 $ collection = DB ::connection ('mongodb ' )->getCollection ('unittest ' );
You can’t perform that action at this time.
0 commit comments