File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
11
11
## [ 4.3.1]
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
+ * Fix PHP error when accessing the connection after disconnect by @SanderMuller in [ #2967 ] ( https://github.com/mongodb/laravel-mongodb/pull/2967 )
14
15
15
16
## [ 4.3.0] - 2024-04-26
16
17
Original file line number Diff line number Diff line change @@ -210,7 +210,7 @@ public function ping(): void
210
210
/** @inheritdoc */
211
211
public function disconnect ()
212
212
{
213
- unset( $ this ->connection ) ;
213
+ $ this ->connection = null ;
214
214
}
215
215
216
216
/**
Original file line number Diff line number Diff line change @@ -38,6 +38,22 @@ public function testReconnect()
38
38
$ this ->assertNotEquals (spl_object_hash ($ c1 ), spl_object_hash ($ c2 ));
39
39
}
40
40
41
+ public function testDisconnectAndCreateNewConnection ()
42
+ {
43
+ $ connection = DB ::connection ('mongodb ' );
44
+ $ this ->assertInstanceOf (Connection::class, $ connection );
45
+ $ client = $ connection ->getMongoClient ();
46
+ $ this ->assertInstanceOf (Client::class, $ client );
47
+ $ connection ->disconnect ();
48
+ $ client = $ connection ->getMongoClient ();
49
+ $ this ->assertNull ($ client );
50
+ DB ::purge ('mongodb ' );
51
+ $ connection = DB ::connection ('mongodb ' );
52
+ $ this ->assertInstanceOf (Connection::class, $ connection );
53
+ $ client = $ connection ->getMongoClient ();
54
+ $ this ->assertInstanceOf (Client::class, $ client );
55
+ }
56
+
41
57
public function testDb ()
42
58
{
43
59
$ connection = DB ::connection ('mongodb ' );
You can’t perform that action at this time.
0 commit comments