php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59635 APCIterator returns expired items with APC_LIST_ACTIVE
Submitted: 2011-02-23 18:09 UTC Modified: 2016-11-18 21:46 UTC
From: marc-bennewitz at arcor dot de Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.3.4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marc-bennewitz at arcor dot de
New email:
PHP Version: OS:

 

 [2011-02-23 18:09 UTC] marc-bennewitz at arcor dot de
Description:
------------
APCIterator returns expired items with APC_LIST_ACTIVE and apc.use_request_time disabled

Reproduce code:
---------------
ini_set('apc.use_request_time', 0);

apc_store('key0', 'value0', 100);
apc_store('key1', 'value1', 1);
apc_store('key2', 'value2', 2);

sleep(2);

$it = new APCIterator('user', '/key./', APC_ITER_DTIME, 1, APC_LIST_ACTIVE);
var_dump( iterator_to_array($it) );

Expected result:
----------------
array(1) {
  ["key0"]=>
  array(1) {
    ["deletion_time"]=>
    int(0)
  }
}

Actual result:
--------------
array(3) {
  ["key0"]=>
  array(1) {
    ["deletion_time"]=>
    int(0)
  }
  ["key1"]=>
  array(1) {
    ["deletion_time"]=>
    int(0)
  }
  ["key2"]=>
  array(1) {
    ["deletion_time"]=>
    int(0)
  }
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-24 11:06 UTC] gopalv@php.net
Interesting, apc only moves stuff off the ACTIVE list when a fetch() happens.

So changing the code to do 

- sleep(2)
+ sleep(3);
+ apc_fetch('key1');
+ apc_fetch('key2');

Would work just fine. But I'll have to fix it to skip expired entries in fetch_active()
 [2016-11-18 21:46 UTC] kalle@php.net
-Status: Open +Status: Wont fix
 [2016-11-18 21:46 UTC] kalle@php.net
APC is no longer supported in favor of opcache that comes bundled with PHP, if you wish to use the user cache, then look at PECL/APCu.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Dec 02 22:01:23 2020 UTC