|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59856 apc_fetch() doesn't set the array pointer to the first element
Submitted: 2011-07-18 10:36 UTC Modified: 2011-07-19 01:03 UTC
From: Assigned:
Status: Closed Package: APC (PECL)
PHP Version: 5.3.6 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
30 - 21 = ?
Subscribe to this entry?

 [2011-07-18 10:36 UTC]
yesterday I noticed that the following code isn't working if 
the $versions array is coming from apc (apc_fetch), as the 
internal pointer for that array isn't at the first element.
I think that we should set that, as unserialize, json_decode, 
and every other method that I can came up with sets this 

Reproduce code:
$foo = array('bar', 'baz');
$foo2 = unserialize(serialize($foo));
$foo3 = json_decode(json_encode($foo));
apc_store('test', $foo);
$foo4 = apc_fetch('test');


Expected result:
string(3) "bar"
string(3) "bar"
string(3) "bar"
string(3) "bar"

Actual result:
string(3) "bar"
string(3) "bar"
string(3) "bar"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-18 11:30 UTC]
For a stop-gap fix, you can try apc.serializer = php;

I will look into this in a bit.
 [2011-07-18 12:42 UTC] tyra3l at gmail dot com
apc.serializer = php
fixes the problem for me

it also works if I cast the $foo4 to an array (which was a 
little bit of a suprise, as I didn't expected any change if 
I cast something to the same type)

I also noticed that my description was a little bit messy, 
originally I planned to use the original code example as is:
then I came up with a better example, but forgot to fix my 
description about the $versions variable.
 [2011-07-19 01:03 UTC]
fixed in svn
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Nov 30 00:01:24 2020 UTC