Skip to content

Commit c93640e

Browse files
tonivegaToni VegaGromNaN
committed
Replaced a too strict assertion in DatabaseSessionHandler that prevented to use the sessions at all with a more simple sanity check (mongodb#3366)
Set zend.assertions=1 --------- Co-authored-by: Toni Vega <[email protected]> Co-authored-by: Jérôme Tamarelle <[email protected]>
1 parent db71580 commit c93640e

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

Diff for: .github/workflows/build-ci-atlas.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ jobs:
9191
- name: "Run tests"
9292
run: |
9393
export MONGODB_URI="mongodb://127.0.0.1:27017/?directConnection=true"
94-
./vendor/bin/phpunit --coverage-clover coverage.xml --group atlas-search
94+
php -d zend.assertions=1 ./vendor/bin/phpunit --coverage-clover coverage.xml --group atlas-search

Diff for: .github/workflows/build-ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,4 @@ jobs:
118118
- name: "Run tests"
119119
run: |
120120
export MONGODB_URI="mongodb://127.0.0.1:27017/?replicaSet=rs"
121-
./vendor/bin/phpunit --coverage-clover coverage.xml --exclude-group atlas-search
121+
php -d zend.assertions=1 ./vendor/bin/phpunit --coverage-clover coverage.xml --exclude-group atlas-search

Diff for: phpunit.xml.dist

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
<env name="QUEUE_CONNECTION" value="database"/>
2424
<ini name="xdebug.mode" value="coverage"/>
2525
<ini name="memory_limit" value="-1"/>
26+
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
27+
<!-- <ini name="zend.assertions=1" value="1" /> -->
2628
</php>
2729

2830
<source restrictDeprecations="true"

Diff for: src/Session/MongoDbSessionHandler.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use MongoDB\BSON\UTCDateTime;
1818
use MongoDB\Collection;
1919

20-
use function assert;
2120
use function tap;
2221
use function time;
2322

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

61-
return $result ? (string) $result->payload : false;
59+
if ($result instanceof Document) {
60+
return (string) $result->payload;
61+
}
62+
63+
return false;
6264
}
6365

6466
public function write($sessionId, $data): bool

0 commit comments

Comments
 (0)