repeatin, growing list of "Invalid argument supplied for foreach()" warnings when using APC backend
| Project: | Cache Router |
| Version: | 6.x-1.0-beta8 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
having installed,
CacheRouter 6.x-1.0-beta8
in a,
Drupal 6.12
installation, when i nav to, e.g.,
https://www.mydomain.net/main/admin/build/modules
at the top of the page, i'm getting a list of,
* warning: Invalid argument supplied for foreach() in /home/mydomain/public_html/main/sites/default/modules/cacherouter/engines/apc.php on line 121.
* warning: Invalid argument supplied for foreach() in /home/mydomain/public_html/main/sites/default/modules/cacherouter/engines/apc.php on line 121.
* warning: Invalid argument supplied for foreach() in /home/mydomain/public_html/main/sites/default/modules/cacherouter/engines/apc.php on line 121.
* warning: Invalid argument supplied for foreach() in /home/mydomain/public_html/main/sites/default/modules/cacherouter/engines/apc.php on line 121.
* warning: Invalid argument supplied for foreach() in /home/mydomain/public_html/main/sites/default/modules/cacherouter/engines/apc.php on line 121.
* warning: Invalid argument supplied for foreach() in /home/mydomain/public_html/main/sites/default/modules/cacherouter/engines/apc.php on line 121.
where the list continues to grow in number on some, not all, subsequent visits.
fwiw, i've
Apache/2.2.11 + mod_fastcgi/2.4.6
php 5.2.9 runs as fcgid
apc 3.1.2

#1
I got the same problem with the Drupal 5 version.
When you lookup what's in $lookup, you will see, it's boolean FALSE. On the description of the function you will find "Returns either the cache object or FALSE on failure", so all is right.
You have 2 options to solve this: change the error reporting setting of php, or like me, add an if around the line 121:
<?php// added to remove the warning, when $lookup === FALSE
if ($lookup !== FALSE) {
foreach ($lookup as $k => $v) {
if (substr($k, 0, strlen($key) - 1)) {
apc_delete($k);
unset($lookup[$k]);
}
}
}
?>
#2
#325921: Error when clearing cache and on update.php