Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f469634

Browse files
Merge 4.3 into 4.4 (#2968)
2 parents 75b7e7f + 6353520 commit f469634

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
1111
## [4.3.1]
1212

1313
* 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)
1415

1516
## [4.3.0] - 2024年04月26日
1617

‎src/Connection.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public function ping(): void
210210
/** @inheritdoc */
211211
public function disconnect()
212212
{
213-
unset($this->connection);
213+
$this->connection = null;
214214
}
215215

216216
/**

‎tests/ConnectionTest.php‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,22 @@ public function testReconnect()
3838
$this->assertNotEquals(spl_object_hash($c1), spl_object_hash($c2));
3939
}
4040

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+
4157
public function testDb()
4258
{
4359
$connection = DB::connection('mongodb');

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /