[wp-trac] [WordPress Trac] #21650: replace serialize() with print_r() in stats() function in wp-includes/cache.php

WordPress Trac wp-trac at lists.automattic.com
Tue Aug 21 13:42:30 UTC 2012


#21650: replace serialize() with print_r() in stats() function in wp-
includes/cache.php
--------------------------+-----------------------------
 Reporter:  bobbingwide   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Cache         |    Version:  3.4.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 In PHP 5.3 it is no longer possible to serialize data that contains a
 SimpleXMLElement object. It produces a fatal error. See
 https://bugs.php.net/bug.php?id=49800

 The stats() function attempts to determine the allocated space for objects
 in the cache by using strlen() of the serialized object.

 This can fail for the reason above.

 Given that the figure returned is simply an estimation of the space
 I propose that the code is changed to use
 print_r( $cache, true ) instead of serialize( $cache )

 ie. to become
 `echo "<li><strong>Group:</strong> $group - ( " . number_format( strlen(
 print_r( $cache, true ) ) / 1024, 2 ) . 'k )</li>';`



 This TRAC was raised after a longish chain of events starting with #18488
 and the final response (today) which led to another chance discovery of a
 similar problem in the debug-bar plugin.

 http://wordpress.org/support/topic/plugin-debug-bar-fatal-error-uncaught-
 exception-serialization-of-simplexmlelement-is-not-allowed

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21650>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list