Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am receing the following error, once i selected Memcache as the cache Handler
Call to undefined function variable_init()
This is the code that generates the error
// Memcache module's cache_get function requires variables to be loaded
//if (isset($conf['authcache_handler']) && $conf['authcache_handler'] == 'memcache.inc' && $vars_exist = cache_get('variables', 'cache')) {
//TODO D7: simg: not sure if cache_get(variables) still needed?
if (variable_get('cache_class_cache_page', '') == 'MemCacheDrupal') {
$conf = variable_init($conf);
}
And this are the settins that i have in my settings.php
include_once('sites/all/modules/contrib/memcache/memcache.inc');
$conf['cache_inc_via_authcache'] = 'sites/all/modules/contrib/memcache/memcache.inc';
$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';
$conf['cache_backends'][] = 'sites/all/modules/contrib/authcache/authcache.inc';
$conf['cache_default_class'] = 'MemCacheDrupal';
#$conf['cache_class_cache_block'] = 'MemCacheDrupal';
$conf['cache_class_cache_page'] = 'MemCacheDrupal';
#$conf['session_inc'] = 'sites/all/modules/contrib/memcache/memcache-session.inc';
$conf['memcache_servers'] = array(
'localhost:11211' => 'default',
'localhost:11211' => 'filter',
'localhost:11211' => 'menu',
'localhost:11211' => 'block',
'localhost:11211' => 'page',
'localhost:11211' => 'users',
'localhost:11211' => 'session',
);
$conf['memcache_bins'] = array(
'cache' => 'default',
'cache_filter' => 'filter',
'cache_menu' => 'menu',
'cache_page' => 'page',
'cache_block' => 'block',
'users' => 'users',
'session' => 'session',
);
$conf['memcache_options'] = array(
Memcached::OPT_COMPRESSION => FALSE,
Memcached::OPT_DISTRIBUTION => Memcached::DISTRIBUTION_CONSISTENT,
);
Comment | File | Size | Author |
---|---|---|---|
Captura de pantalla 2012-09-14 a la(s) 13.39.41.png | 51.78 KB | sirviejo |
Comments
Comment #1
simg CreditAttribution: simg commentedIf you change that section of code to:
that should fix the undefined function error.
Note: I'm guessing you're probably (evidently) the first person to attempt to use the D7 version of authcache with memcache. ( I use filecache ). If you find / report any errors, you should get a pretty good response / fix time :)
Comment #2
sirviejo CreditAttribution: sirviejo commentedThanks for your quick response simg, that bypass the error.
Once i did that i receive another undefined function error saying that db_query is not defined.
And that is because the DRUPAL_BOOTSTRAP_PAGE_CACHE is the second phase and DRUPAL_BOOTSTRAP_DATABASE is the third.
That is why, i think it's incorrect to call any query depending function inside the DRUPAL_BOOTSTRAP_PAGE_CACHE phase.
Comment #3
simg CreditAttribution: simg commentedwhat is the exact error message (ie file name & line number ) ?
I'm not aware of any reason why authcache would try and call db_query for the exact reason you mention.
Comment #4
sirviejo CreditAttribution: sirviejo commentedwhe you receive a cache miss in the variable_initialize (first time you render the page befor caching), you will need to proceed with variable rebuild. This force you to need the database access.
Please let me know if i am making a mistake here.
Regards.
Comment #5
simg CreditAttribution: simg commentedoh, that's a shame. bootstrapping the database is something of an overhead which means the memcache option will be slower than it otherwise could be (it might be possible to optimise this in future).
for now, could you try modifying the lines in authcache.inc 65 - 69 to look like the following:
Or, just download the latest dev version as it now contains the above code.
I suspect you'll get significantly better performance right now using FileCache (which was already somewhat faster than MemCache)
Comment #6
sirviejo CreditAttribution: sirviejo commentedyes if i apply this change the module starts working.Anyways i do not get why only for using memcached the database is required (it should not!)
Comment #7
simg CreditAttribution: simg commented>why only for using memcached the database is required (it should not!)
because the memcache code apparently calls variable_initialize and it's variable_initialize which requires database access :/
edit: wasn't intending to be rude by closing this issue, just trying to keep the issue queue under control :)