Skip to content

unserialize() can be passed null - #1622

Merged
cpeel merged 1 commit into
DistributedProofreaders:masterfrom
cpeel:fix-errors
Sep 3, 2026
Merged

cpeel merged 1 commit into
DistributedProofreaders:masterfrom
cpeel:fix-errors

Conversation

@cpeel

@cpeel cpeel commented Sep 3, 2026

Copy link
Copy Markdown
Member

Having the function accept null for the case when a variable isn't included in a POST seems more sensible than checking the POST and passing the function an empty string.

I updated TEST with the latest code, clicked around on a lot of things, and this was the only thing I found from my initial testing.

Having the function accept null for the case when a variable isn't
included in a POST seems more sensible than checking the POST and
passing the function an empty string.
@cpeel
cpeel requested a review from bpfoley September 3, 2026 17:40
@cpeel cpeel self-assigned this Sep 3, 2026
private function unserialize(string $value): mixed
private function unserialize(?string $value): mixed
{
return $value ? unserialize(base64_decode($value)) : null;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to quibble about having an !is_null check here instead of truthy, but the serialization format always emits non-empty strings: "N" is null "b:0" is false etc.
https://www.phpinternalsbook.com/php5/classes_objects/serialization.html

@cpeel
cpeel merged commit 461a75b into DistributedProofreaders:master Sep 3, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants