php.net |  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: tyrael@php.net 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:
MUST BE VALID
Solve the problem:
46 + 14 = ?
Subscribe to this entry?

 
 [2011-07-18 10:36 UTC] tyrael@php.net
Description:
------------
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 
correctly.


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

var_dump(current($foo));
var_dump(current($foo2));
var_dump(current($foo3));
var_dump(current($foo4));


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"
bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-18 11:30 UTC] gopalv@php.net
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:
http://svn.php.net/viewvc/web/php-
bugs/trunk/include/functions.php?
r1=313350&r2=313349&pathrev=313350
then I came up with a better example, but forgot to fix my 
description about the $versions variable.
 [2011-07-19 01:03 UTC] gopalv@php.net
fixed in svn

http://news.php.net/php.pecl.cvs/15989
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 09:01:27 2024 UTC