Hi,

I was looking forward to using this module,

Got this error? When I went to Drupal Performance and hit the clear all caches button

Fatal error: Class 'APCIterator' not found in /var/www/thesitenamehere/web/sites/all/modules/apc/drupal_apc_cache.inc on line 243

Sorry, I am not that advanced at server stuff and someone else has installed APC on the server.

As for the module followed the instructions including:

Did standard set up, by putting

/**
* Add APC Caching.
*/
$conf['cache_backends'] = array('sites/all/modules/apc/drupal_apc_cache.inc');
$conf['cache_class_cache'] = 'DrupalAPCCache';
$conf['cache_class_cache_bootstrap'] = 'DrupalAPCCache';
//$conf['apc_show_debug'] = TRUE; // Remove the slashes to use debug mode.

in the settings.php file

Then changed

variable_get('cache_default_class', 'DrupalDatabaseCache')

to

variable_get('cache_default_class', 'DrupalAPCCache')

in includes/cache.inc

I did all this obviously after I had installed and enabled the APC module in the Drupal modules manager.

Have since taken the code out of the settings.php file and set the cache.inc file back to variable_get('cache_default_class', 'DrupalDatabaseCache') and disabled the module. Without issue. But still interested in using this module. Because of the obvious performance benefits.

Thanks and all the best from Josh

CommentFileSizeAuthor
#10 1587110_apc_cache_backends.patch921 bytesMrHaroldA
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

seaarg’s picture

Category: support » bug

I can confirm this bug, It happened to me following instructions from readme.txt

hansrossel’s picture

You need at least APC version 3.1.1, because this class was then introduced: http://pecl.php.net/package-changelog.php?package=APC.

hansrossel’s picture

Component: Code » Documentation
Category: bug » task

I think this is rather a documentation issue, just need to specify in the readme.txt that the APC version needs to be higher than 3.1.1.

jlhs’s picture

Thankyou hansrossel

Unfortunately we have APC version 3.1.3p1-2 installed and still we got that error.

All the best

seaarg’s picture

hansrossel, thanks for the info, I have APC v 3.0.19 installed, will try to upgrade.

hansrossel’s picture

jlhs, not sure what your issue is then maybe some setting in php.ini, or maybe you still need a higher version of APC anyway. I had the error on APC 3.0.9 and upgraded to the latest stable version which is 3.1.9. and this solved this issue.

jlhs’s picture

Thankyou for the advice hansrossel,

I will ask the server admin, to install the latest stable version of APC

ohthehugemanatee’s picture

Reporting the same problem with APC 3.1.9 installed from apt on Ubuntu 12.04 LTS. There must be a php.ini issue here.

ohthehugemanatee’s picture

ahhh - this is a simple problem. Lots of caching modules (including APC) tell you to add their system to settings.php with a line like this:

$conf['cache_backends'] = array('sites/all/modules/apc/drupal_apc_cache.inc');

But then they overwrite each other. I had Varnish configuration later on in settings.php, which was using the same structure. Better is:

$conf['cache_backends'][] = 'sites/all/modules/apc/drupal_apc_cache.inc';

This should probably be updated in the documentation...

MrHaroldA’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Category: task » bug
Status: Active » Needs review
FileSize
921 bytes

Here's a patch with the suggested documentation change by ohthehugemanatee.

The suggested core-hack is somewhat ugly too:

/*****************
* 2. Testing
****************/
To be able to test this module open DRUPAL_ROOT/includes/cache.inc and search
for `variable_get('cache_default_class', 'DrupalDatabaseCache')`. and change
this to DrupalAPCCache. This is because the $conf[''] array in settings.php
is not always loaded properly.

-Mania-’s picture

Getting the error even with #9. :/

-Mania-’s picture

Sorry, I was mistaken, the problem was with the old APC version as previously been noted also.

R.Muilwijk’s picture

Status: Needs review » Fixed

Though your problem was fixed with the the APC version the patch in #10 is still valuable and committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dahousecat’s picture

I am still getting this error.

It only occurs when I run the cron via the drush command.

Exact error I'm getting is:

PHP Fatal error: Class 'APCIterator' not found in /var/www/sites/all/modules/thirdparty/apc/drupal_apc_cache.inc on line 245
Drush command terminated abnormally due to an unrecoverable error.
Error: Class 'APCIterator' not found in /var/www/sites/all/modules/thirdparty/apc/drupal_apc_cache.inc, line 245

I am using APC 3.1.13.

Any suggestions?

jvsteiner’s picture

Issue summary: View changes

Im also using APC 3.1.13. I had this same problem as well. I was able to get the error to stop occurring by putting "apc.enable_cli = 1" in my apc.ini file. I tried this because I read elsewhere that cli needs to be enabled explicitly. It seems to have worked to some degree, since drush no longer terminated abnormally, however, it revealed another problem (warning) on the very next line: Invalid argument supplied for foreach() drupal_apc_cache.inc:246

the relevant portion of drupal_apc_cache.inc contains a bug:

  protected function deletePrefix($prefix) {
    $match = $this->escapeStringForRegex($this->binKey() . $prefix);
    $ator = new APCIterator('user', '/^' . $match . '/', APC_ITER_KEY); //<- BUG
    foreach ($iterator as $key => $data) {
      apc_delete($key);
     }
   }

$ator should be $iterator. changing it worked for me.