Bug #80483 [Dup]: DateTime Object with 5-digit year can't unserialized
| From: | kontakt at nico-bayati dot de | Date: | Fri, 04 Dec 2020 14:58:28 +0000 |
| Subject: | Bug #80483 [Dup]: DateTime Object with 5-digit year can't unserialized | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230851@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80483&edit=1
ID: 80483
User updated by: kontakt at nico-bayati dot de
Reported by: kontakt at nico-bayati dot de
Summary: DateTime Object with 5-digit year can't unserialized
Status: Duplicate
Type: Bug
Package: Date/time related
Operating System: Debian GNU/Linux 4.19.0
PHP Version: Irrelevant
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
oh, I missed the bug report, sorry about that I guess I can say goodbye to my data for now, because
it hasn't been fixed for a while.
You might want to mention in the documentation that only 4-digit years are safe for serialization.
Thank you.
Previous Comments:
------------------------------------------------------------------------
[2020-12-04 12:51:35] cmb@php.net
This appears to be a duplicate of bug #75035.
------------------------------------------------------------------------
[2020-12-04 08:41:00] kontakt at nico-bayati dot de
Description:
------------
Maybe it is not a mistake, but I would like a consistent handling here. If 5-digit years are not
desired, they should not be entered, otherwise it would be desirable that I can unserialize
serialized objects, which contain 5-digit years
Tested with php 7.2, 7.3 and 7.4.
Thank you.
Test script:
---------------
<?php
$the_date = new DateTime();
$the_date->setTime(0, 0, 0);
$the_date->SetDate(20201, 01, 01);
var_dump($the_date);
$serialized = serialize($the_date);
var_dump($serialized);
var_dump(unserialize($serialized));
Actual result:
--------------
/home/nico/test/unserialize.php:7:
class DateTime#1 (3) {
public $date =>
string(27) "20201-01-01 00:00:00.000000"
public $timezone_type =>
int(3)
public $timezone =>
string(13) "Europe/Berlin"
}
/home/nico/test/unserialize.php:10:
string(126) "O:8:"DateTime":3:{s:4:"date";s:27:"20201-01-01
00:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:13:"Europe/Berlin";}"
PHP Fatal error: Uncaught Error: Invalid serialization data for DateTime object in
/home/nico/test/unserialize.php:11
Stack trace:
#0 [internal function]: DateTime->__wakeup()
#1 /home/nico/test/unserialize.php(11): unserialize('O:8:"DateTime":...')
#2 {main}
thrown in /home/nico/test/unserialize.php on line 11
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80483&edit=1