php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58989 apc_store loses data on storing object
Submitted: 2009-12-14 05:39 UTC Modified: 2009-12-15 14:47 UTC
From: ben at downstairs dot com Assigned:
Status: Not a bug Package: APC (PECL)
PHP Version: 5.3.0 OS: suse linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ben at downstairs dot com
New email:
PHP Version: OS:

 

 [2009-12-14 05:39 UTC] ben at downstairs dot com
Description:
------------
When storing data that came from a SimpleXMLObject to an apc cache with apc_store the data will be lost upon retrieval.


Seems related to bug #8118.

Reproduce code:
---------------
$data = ""XML File from Youtube API"";
$xml = simplexml_load_string($data);
foreach ($xml->entry as $entry)
{
$media = $entry->children('http://search.yahoo.com/mrss/');
$title = $media->group->title;
$videos[] = array("title" => $title);
}

storing and refetching $videos will yield an empty array (keys intact, data lost).

typecasting $title to string works around this.

so "$title = (string) $media->group->title;" in above example fixes it.


Expected result:
----------------
Expected array I stored to cache.

Actual result:
--------------
Got array with keys intact but no data.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-14 11:54 UTC] rasmus@php.net
You can't cache internal magic objects.  Only user-space 
ones.
 [2009-12-15 04:28 UTC] ben at downstairs dot com
Might I suggest having APC throw a warning-message when it's about to store data it doesn't like in some way?

I for one was completely unaware there's stuff like "magic objects" out of "user space" ;)
 [2009-12-15 14:47 UTC] shire@php.net
Adding a warning for IS_RESOURCE seems like a good idea to me, any objects for reasons I'm not aware of?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 14:01:31 2024 UTC