Bug #72011 [NEW]: DateTime serializes as empty object

From: Date: Tue, 12 Apr 2016 13:52:36 +0000
Subject: Bug #72011 [NEW]: DateTime serializes as empty object
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200508@lists.php.net to get a copy of this message
From:             benjamin dot roth at jaumo dot com
Operating system: Linux
PHP version:      7.0.5
Package:          Date/time related
Bug Type:         Bug
Bug description:DateTime serializes as empty object

Description:
------------
I recognize occasionally that DateTime serializes as an empty object.
Deserializing then throws a fatal error with "Invalid serialization data
for DateTime object"
Also print_r outputs the DateTime Object like 

DateTime Object
(
)

This is the output of a real example when serializing an arbitrary
structure with a DateTime object:

Serialize:
a:4:{s:6:"userId";i:27008573;s:9:"longitude";d:1.5192019999999999;s:8:"latitude";d:48.432855000000004;s:4:"date";O:8:"DateTime":0:{}}

print_r:
Array
(
   [userId] => 27008573
   [longitude] => 1,519202
   [latitude] => 48,432855
   [date] => DateTime Object
       (
       )

)

Unfortunately I was not able to reproduce it reliably, I was only able
to detect it, when it occured in may be one of 100.000 requests. In our
production environment this occurs frequently but I was not able to
track it down.
I noticed this behaviour only in FPM workers not in CLI. WHEN this bug
occurs, the affected FPM worker behaves wrong until it is respawned,
also in following requests.

I know this information is very rough. I am happy to provide any more
information that can help :)

Test script:
---------------
<?php

// This should only demontrate what happens, if bug occurs
// Bug is VERY flaky

$d = new DateTime();
print_r($d);

Expected result:
----------------
DateTime Object
(
   [date] => 2016-04-12 13:35:15.000000
   [timezone_type] => 3
   [timezone] => UTC
)

Actual result:
--------------
DateTime Object
(
)

-- 
Edit bug report at https://bugs.php.net/bug.php?id=72011&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=72011&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=72011&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=72011&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=72011&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=72011&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=72011&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=72011&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=72011&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=72011&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=72011&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=72011&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=72011&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=72011&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72011&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=72011&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=72011&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=72011&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72011&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=72011&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=72011&r=mysqlcfg



Thread (19 messages)

« previous php.bugs (#200508) next »