Opened 9 months ago
Last modified 9 months ago
#21650 new defect (bug)
replace serialize() with print_r() in stats() function in wp-includes/cache.php
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Cache | Version: | 3.4.1 |
| Severity: | minor | Keywords: | has-patch |
| Cc: |
Description
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.
Attachments (1)
Change History (4)
bobbingwide — 9 months ago
- Severity changed from normal to minor
The way this estimation is presented is very misleading; it makes you think you're viewing the size of the cache in memory, rather than the lenght of it's serialization.
comment:3
wonderboymusic — 9 months ago
- Keywords has-patch added

Replace serialize() with print_r() to avoid Fatal error (WP 3.5)