Call to undefined function cache_get() in Drupal 7? Check your settings.php.

Ran into this one today while setting up a local environment with DDEV:

PHP Fatal error:  Uncaught Error: Call to undefined function cache_get() in /var/www/html/includes/module.inc:754
 Stack trace:
 #0 /var/www/html/includes/module.inc(954): module_implements('system_theme_in...')
 #1 /var/www/html/modules/system/system.module(2511): module_invoke_all('system_theme_in...')
 #2 /var/www/html/includes/theme.inc(798): _system_rebuild_theme_data()
 #3 /var/www/html/includes/theme.maintenance.inc(57): list_themes()
 #4 /var/www/html/includes/bootstrap.inc(2922): _drupal_maintenance_theme()
 #5 /var/www/html/includes/errors.inc(179): drupal_maintenance_theme()
 #6 /var/www/html/includes/bootstrap.inc(2634): _drupal_log_error(Array, true)
 #7 [internal function]: _drupal_exception_handler(Object(Error))
 #8 {main}
 thrown in /var/www/html/includes/module.inc on line 754
 Drush command terminated abnormally due to an unrecoverable error.

It’s not very obvious at all what’s going on here. Clearly, Drupal is somehow failing to load. I at first thought it was the database connection details not getting loaded properly and ensured that they were OK. But the error persisted.

“Strange,” I thought. “The DB connection info is definitely correct.” So I went back to https://www.drupal.org/forum/support/post-installation/2016-06-23/fatal-error-call-to-undefined-function-cache_get, which had some up in search, again. Everyone hitting the error seemed to have syntax errors in their settings.php. I figured that, logically, I must too, and just not be seeing it.

Sure enough:

 

if ($file_exists($dir . '/settings.local.php')) {
  require_once($dir . '/settings.local.php');
}

❝I think you’re looking for the file_exists() function there, buddy.❞

 

So I removed the extraneous $ and, sure enough, the site started working.

This has been another episode of the ongoing worldwide series Is It Plugged In?

This entry was posted in Uncategorized. Bookmark the permalink. Trackbacks are closed, but you can post a comment.