Possibly missing warning for `unserialize('')` - may be confused with "false"
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 45/100
Piste de recherche
Start by reproducing the supplied PHP example, then read ext/standard/var.c around php_unserialize_with_options at the linked condition. Check existing unserialize behavior and tests before deciding whether empty input should warn; done means the expected behavior is agreed and covered by an appropriate regression test.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description
The following code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
$a = 'b:0;'; // serialize(false);
$b = '';
var_dump($a === $b);
var_dump(unserialize($a) === unserialize($b));
Resulted in this output:
bool(false)
bool(true)
But I expected this output instead:
bool(false)
Warning: unserialize(): Empty input in /in/bjBq9 on line 11
bool(true)
Dear Developers, Artists,
Thank you for the marvel, art...
On 2026-09-18, at Libera IRC channel #php, a member ash_worksi raised this issue asking why no warning is raised in PHP, if compared to unserialize(' ');, for example.
My contention is the fact that it doesn't raise a warning like the description says. It's a very narrow edge case, but just like any "non-unserializable" string (...otherwise why would it return false?) it should raise the warning.
unserialize()returning false on it's own does not tell you whether the function failed to unserialize or if the value you unserialized was in factfalse.~ ash_worksi
Later, I tried searching for the actual reason it happens, and the condition involved is likely the following, in the function php_unserialize_with_options:
The condition explicitly checks if the string is empty, and returns "false" by design, and considering the first commits checked, it has been so for at least "20 years ago".
I believe that for so much time, it was discussed already, but just in case, is it still actually expected?
Best and kind regards
PHP Version
PHP 8.5.10 (cli) (built: Sep 19 2026 00:23:53) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.5.10, Copyright (c) Zend Technologies
with Zend OPcache v8.5.10, Copyright (c), by Zend Technologies
Operating System
Kubuntu 26.10 (Docker)
- Langage dominant
- C
- Étoiles
- 40.4k
- Forks
- 8.2k
- Merge moyen
- 2 j 13 h
- PR mergées (30 j)
- 154
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de php/php-src
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
php/php-src#23958 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
Bug Status: Needs Triage
Difficulté 1/5 Moins d'une heure Accessibilité débutants 90/100
Les mainteneurs répondent en général sous 1 jour
-
Bug Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Flaky hrtime.phpt testOuverteBug Category: Tests Status: Verified
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
Bug SAPI: fpm Status: Needs Triage
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
php/php-src#21740 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de php/php-src
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
BasedHardware/omi#20401 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
php/frankenphp#2688 ·
Les mainteneurs répondent en général sous 1 jour
-
area/ysql kind/bug priority/medium
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
yugabyte/yugabyte-db#34584 ·
Les mainteneurs répondent en général sous 1 jour
-
After `require "openssl"`, a top-level `Digest` is `OpenSSL::Digest`, not the `Digest` moduleOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
ExpressLRS/ExpressLRS#3806 ·
Les mainteneurs répondent en général sous 2 jours