Skip to content

Merge 5.4 into 5.x #3370

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-ci-atlas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ jobs:
- name: "Run tests"
run: |
export MONGODB_URI="mongodb://127.0.0.1:27017/?directConnection=true"
./vendor/bin/phpunit --coverage-clover coverage.xml --group atlas-search
php -d zend.assertions=1 ./vendor/bin/phpunit --coverage-clover coverage.xml --group atlas-search
2 changes: 1 addition & 1 deletion .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ jobs:
- name: "Run tests"
run: |
export MONGODB_URI="mongodb://127.0.0.1:27017/?replicaSet=rs"
./vendor/bin/phpunit --coverage-clover coverage.xml --exclude-group atlas-search
php -d zend.assertions=1 ./vendor/bin/phpunit --coverage-clover coverage.xml --exclude-group atlas-search
2 changes: 2 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<env name="QUEUE_CONNECTION" value="database"/>
<ini name="xdebug.mode" value="coverage"/>
<ini name="memory_limit" value="-1"/>
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
<!-- <ini name="zend.assertions=1" value="1" /> -->
</php>

<source restrictDeprecations="true"
Expand Down
8 changes: 5 additions & 3 deletions src/Session/MongoDbSessionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use MongoDB\BSON\UTCDateTime;
use MongoDB\Collection;

use function assert;
use function tap;
use function time;

Expand Down Expand Up @@ -56,9 +55,12 @@ public function read($sessionId): string|false
'typeMap' => ['root' => 'bson'],
],
);
assert($result instanceof Document);

return $result ? (string) $result->payload : false;
if ($result instanceof Document) {
return (string) $result->payload;
}

return false;
}

public function write($sessionId, $data): bool
Expand Down
4 changes: 2 additions & 2 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testDisconnectAndCreateNewConnection()
public function testDb()
{
$connection = DB::connection('mongodb');
$this->assertInstanceOf(Database::class, $connection->getMongoDB());
$this->assertInstanceOf(Database::class, $connection->getDatabase());
$this->assertInstanceOf(Client::class, $connection->getClient());
}

Expand Down Expand Up @@ -199,7 +199,7 @@ public function testConnectionConfig(string $expectedUri, string $expectedDataba
$client = $connection->getClient();

$this->assertSame($expectedUri, (string) $client);
$this->assertSame($expectedDatabaseName, $connection->getMongoDB()->getDatabaseName());
$this->assertSame($expectedDatabaseName, $connection->getDatabase()->getDatabaseName());
$this->assertSame('foo', $connection->getCollection('foo')->getCollectionName());
$this->assertSame('foo', $connection->table('foo')->raw()->getCollectionName());
}
Expand Down
6 changes: 3 additions & 3 deletions tests/FilesystemsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static function provideValidOptions(): Generator
'driver' => 'gridfs',
'bucket' => static fn (Application $app) => $app['db']
->connection('mongodb')
->getMongoDB()
->getDatabase()
->selectGridFSBucket(),
],
];
Expand All @@ -68,7 +68,7 @@ public function testValidOptions(array $options)
// Service used by "bucket-service"
$this->app->singleton('bucket', static fn (Application $app) => $app['db']
->connection('mongodb')
->getMongoDB()
->getDatabase()
->selectGridFSBucket());

$this->app['config']->set('filesystems.disks.' . $this->dataName(), $options);
Expand Down Expand Up @@ -145,6 +145,6 @@ public function testPrefix()

private function getBucket(): Bucket
{
return DB::connection('mongodb')->getMongoDB()->selectGridFSBucket();
return DB::connection('mongodb')->getDatabase()->selectGridFSBucket();
}
}
Loading