Possibly missing warning for `unserialize('')` - may be confused with "false"
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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)
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 115
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của php/php-src
-
Bug Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Bug Status: Needs Triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Bug Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Flaky hrtime.phpt test Đang mởBug Category: Tests Status: Verified
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Bug SAPI: fpm Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Issue tương tự
-
os:linux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
mpv-player/mpv#18510 · 2 bình luận ·
-
internal.h中,漏掉了1个定义。 Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Broadcast Documentation Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
kovidgoyal/kitty#10516 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100