Skip to content

Commit

Permalink
Mute PHP notice from Session unserialize
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Dec 31, 2023
1 parent efa4676 commit 05a15b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"@test"
],
"fix": "php-cs-fixer fix",
"test": "phpunit --stderr --display-warnings",
"test": "phpunit --stderr",
"test:coverage": "XDEBUG_MODE=coverage phpunit --stderr --coverage-html=tests/coverage",
"zip": "composer archive --format=zip --file=dist"
}
Expand Down
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
colors="true"
stderr="true"
cacheDirectory=".phpunit.cache"
displayDetailsOnIncompleteTests="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
>
<source>
<include>
Expand Down
4 changes: 2 additions & 2 deletions src/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Kirby\Http\Url;
use Kirby\Toolkit\Str;
use Kirby\Toolkit\SymmetricCrypto;
use Throwable;

/**
* @package Kirby Session
Expand Down Expand Up @@ -661,6 +660,7 @@ protected function init(): void
// skip if we don't have the key (only the case for moved sessions)
$hmac = Str::before($data, "\n");
$data = trim(Str::after($data, "\n"));

if (
$this->tokenKey !== null &&
hash_equals(hash_hmac('sha256', $data, $this->tokenKey), $hmac) !== true
Expand All @@ -675,7 +675,7 @@ protected function init(): void
}

// decode the serialized data
$data = unserialize($data);
$data = @unserialize($data);

if ($data === false) {
throw new LogicException([
Expand Down

0 comments on commit 05a15b6

Please sign in to comment.