After upgrading to 7.62, I encounter the following error in drush status and blank pages. Please help! We're not able to upgrade our production Drupal sites.

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

Comments

ianchan created an issue. See original summary.

ianchan’s picture

I think it's something in includes/bootstrap.inc

grahamc’s picture

I've just seen this error on a site where the new misc/typo3 directory had not been deployed to the server.

The issue went away when the update was deployed correctly.

ianchan’s picture

The problem does not occur in the 7.63 release.

Thank you for the making the new release available.

xjm’s picture

Category: Bug report » Support request
Priority: Critical » Normal
Status: Active » Fixed

Yes this sounds like a broken deployment or update, which could have happened as a side effect of the issue affecting Drush in 7.62 or something else. Thanks @grahamC and @ianchan for following up!

Status: Fixed » Closed (fixed)

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

bobburns’s picture

I did not see where this was "fixed" - but I troubleshot my same issue by . . .

by adding function cache_get() { return false; } to settings.php - which brought up an error page that stated I could not set "user" with an ini_set in the settings.php file . . .

So I commented it out as thus . . .

# ini_set('session.save_handler', 'user');

which then came up with a "cannot" re-declare error in the log pointing to line 6 of the settings.php which was the => function cache_get() { return false; }

and when I removed it the site launched

See also https://drupal.stackexchange.com/questions/43971/fatal-error-call-to-und...

webchick’s picture

Just confirming I had the same issue moving a site from a PHP 5 hosting situation to a PHP 7.3 hosting situation, and @bobburns's solution of uncommenting that ini_set() line in settings.php seems to have done the trick! Thanks!

spamator12’s picture

Fatal error: Uncaught Error: Call to undefined function cache_get() in /includes/module.inc:733 Stack trace: #0 /includes/module.inc(931): module_implements('system_theme_in...') #1 /modules/system/system.module(2511): module_invoke_all('system_theme_in...') #2 /includes/theme.inc(798): _system_rebuild_theme_data() #3 /includes/theme.maintenance.inc(57): list_themes() #4 /includes/bootstrap.inc(2602): _drupal_maintenance_theme() #5 /includes/errors.inc(179): drupal_maintenance_theme() #6 /includes/bootstrap.inc(2339): _drupal_log_error(Array, true) #7 [internal function]: _drupal_exception_handler(Object(ParseError)) #8 {main} thrown in /includes/module.inc on line 733

nothing seems to work so far...

erindarri’s picture

Another report of this error. Pantheon (php 7.2.12), Drupal 7.67. I don't even have the line about ini_set('session.save_handler', 'user'); in my code. I don't recall when it started, but I think it might have been around the same update as above.

longtom’s picture

got it today in Drupal 7.67

jadhavdevendra’s picture

I faced this issue due to incorrect permission on patheon. Somehow execute permission was not set on two folders inside misc directory. I switched mode to SFTP added execute permission to them and switched back to git mode. That fixed the issue.

MHGR’s picture

I am facing the same issue in Drupal7 while upgrading php version 5.5 to 7.0.28. Please help to resolve the below issue.

Fatal error: Uncaught Error: Call to undefined function cache_get() in ...\includes\module.inc:762 Stack trace: #0 ...\includes\module.inc(962): module_implements('system_theme_in...') #1 ...\modules\system\system.module(2514): module_invoke_all('system_theme_in...') #2 ....\includes\theme.inc(798): _system_rebuild_theme_data() #3 ...\includes\theme.maintenance.inc(57): list_themes() #4 ....\includes\bootstrap.inc(2894): _drupal_maintenance_theme() #5 ....\includes\errors.inc(179): drupal_maintenance_theme() #6 ....\includes\bootstrap.inc(2622): _drupal_log_error(Array, true) #7 [internal function]: _drupal_exception_handler(Object(ParseError)) #8 {main} thrown in ...\includes\module.inc on line 762

navalogan’s picture

Hi,
After the update to 7.67, i got the same issues. Someone find any solution ?
thanks

tpdietz’s picture

Hi,
I also just updated to 7.67 and am having the same issue. Is there any solution to this, yet?
Thanks.

jadhavdevendra’s picture

Either uncomment below line or add if not present.
ini_set('session.save_handler', 'user');

See if this helps.

berramou’s picture

Hello is there is any fix for this,
I have this issue with drupal 6.67, PHP 7.1.30, i didn't have the issue with 6.66 version.
I have tried ini_set('session.save_handler', 'user'); it doesn't work.
Thanks.

liquidcms’s picture

Any solution to this yet?

And on another note.. certainly seems like a step backwards as Drupal issue queue no longer allows people to change status of an issue. Clearly this issue is not closed.

berramou’s picture

For me the issue was Fileinfo PHP extension messing, i install/enabled it on server and it works.
@liquidcms you can check with this command php -r "var_dump(extension_loaded('fileinfo'));"

Rafal Lukawiecki’s picture

Thank you, @berramou and @webchick. In my case, following update to 7.67, and running on FreeBSD, it was also the missing PHP FileInfo dependency. Adding

ini_set('session.save_handler', 'user');
function cache_get() { return false; };

allowed me to see the underlying error, which was reported as

Error: Class 'finfo' not found in TYPO3\PharStreamWrapper\Phar\Reader->determineFileType() (line 155 of /usr/local/www/vhosts/s833369-rafal/public/misc/typo3/phar-stream-wrapper/src/Phar/Reader.php).
Drush command terminated abnormally due to an unrecoverable error.

I hope this helps someone.

DrPal43’s picture

I got that issue when changing my php versions to 7.2.

7.2 doesn't use ini_set('session.save_hanlder','user') anymore.

session_set_save_handler(); is the replacement.

Hope this helps someone.

https://stackoverflow.com/questions/55785829/ini-setsession-save-handler...

DrPal43’s picture

php 7.2 doesn't like ini_set('session.save_handler', 'user'); in the settings.php.

replace:
ini_set('session.save_handler', 'user');
with:
session_set_save_handler(new SessionHandler());

This fixed the issue.

gramie’s picture

@berramou, thank you for finding that! It was the problem for me too. Once I enabled fileinfo, everything worked!

dexnob’s picture

@DrPal43 thanks, that worked for me #21

alfthecat’s picture

Adding session_set_save_handler(new SessionHandler()); to settings.php as mentioned in #22 fixed the issue for me. Thanks @DrPal43!!!

Studio FJ’s picture

My site is Drupal 7.69 started having this same issue today. My settings.php file does not have:

ini_set('session.save_handler', 'user');

I downloaded a fresh Drupal core and do not see that line in default.settings.php either. Where is that code normally located?

Notes:
1) Fileinfo PHP is enabled
2) My php version is 7.3 and has been since it's release
3) I do not have Drush installed on my server
4) I updated to Drupal 7.69 with no issues earlier this month
5) The site randomly went down today

PHP Fatal error: Uncaught Error: Call to undefined function cache_get() in /public_html/includes/module.inc:762
Stack trace:
#0 public_html/includes/module.inc(962): module_implements('system_theme_in...')
#1 public_html/modules/system/system.module(2518): module_invoke_all('system_theme_in...')
#2 public_html/includes/theme.inc(798): _system_rebuild_theme_data()
#3 public_html/includes/theme.maintenance.inc(57): list_themes()
#4 public_html/includes/bootstrap.inc(2896): _drupal_maintenance_theme()
#5 public_html/includes/errors.inc(179): drupal_maintenance_theme()
#6 public_html/includes/bootstrap.inc(2621): _drupal_log_error(Array, true)
#7 [internal function]: _drupal_exception_handler(Object(Error))
#8 {main}
thrown in public_html/includes/module.inc on line 762

alfthecat’s picture

Hi @Studio FJ,

I experienced the same thing, this happened suddenly yesterday.

Just add the following line to your settings.php:

session_set_save_handler(new SessionHandler());

If you have drush, flush your site's caches via the command line.

hughworm’s picture

To overcome this I've gone simple and added

require_once DRUPAL_ROOT . '/includes/cache.inc';

at line 762 of module.inc, just before it uses cached_get().

Seems to have fixed it (I also had to change the session handler thing).

alfthecat’s picture

After running into this issue again, even with the session_set_save_handler(new SessionHandler()); added to settings.php, adding the solution in #28 from @hughworm solved it.

BTW, shouldn't this issue be an active bug report?

scottop’s picture

php 7.2 doesn't like ini_set('session.save_handler', 'user'); in the settings.php.

replace:
ini_set('session.save_handler', 'user');
with:
session_set_save_handler(new SessionHandler());

from @drpal43, comment 22. This worked for me. Thank you.

tapas_talukder’s picture

This is basically for PHP latest version issues where session.save_handlerdoes not working. So please remove the bellow line from settings.php
ini_set('session.save_handler', 'user');

or

Replace the line by session_set_save_handler(new SessionHandler());

----------------------------
Current line
ini_set('session.save_handler', 'user');
Needs to Replaced by
session_set_save_handler(new SessionHandler());

kropotkinthinks’s picture

The solution from @DrPal43 worked for me too. I did the following, in settings.php:

#ini_set('session.save_handler', 'user');
session_set_save_handler(new SessionHandler());

Commented out the ini_set for session.save_handler and added the session_set_save_handler

hassan.farooq121’s picture

#8 worked for me

shaesen’s picture

php 7.2 doesn't like ini_set('session.save_handler', 'user'); in the settings.php.

replace:
ini_set('session.save_handler', 'user');
with:
session_set_save_handler(new SessionHandler());

This solved it for me too !

Stefaan

mchaplin’s picture

I found the position of the

session_set_save_handler(new SessionHandler());

in the file to be critical.

It worked for me when placed AFTER all the ini_set statements.

andresc75’s picture

Version: 7.62 » 10.0.x-dev

- Updated to 7.71 (from 7.67) with no errors,
- Upgraded php to 7.2 (from 5)
RESULT: Site returned error 500

Add these lines of code to "index.php"
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

and get "Call to undefined function cache_get() in /var/www/drupal/includes/module.inc:762" (following other errors)

Modified setting.php as described in #22 SOLVED MY PROBLEM

Thank you!

andrewmk’s picture

And for me it was a missing memcached extension for php. Adding:

function cache_get() { return false; };

To the beginning of settings.php let me see the actual error which was:

<h1>Additional uncaught exception thrown while handling exception.</h1><h2>Original</h2><p>Error: Class &amp;#039;Memcached&amp;#039; not found in include_once()

(Don't forget to remove the dummy cache_get after you've fixed the problem!)

twfahey’s picture

Just adding my story on this error for any future explorers -- In my case, I had neglected a ";" at the end of my settings.local.php file, and this was what wound up manifesting as the error! I would have expected invalid syntax or some other more pointed error, but obviously a very rare edge case! I just happened to be adding in a `$base_url` for this D7 site, and was moving too quickly and forgot my semicolon, so it might be the easy answer for some :)

sam-elayyoub’s picture

I got to this issue for one of my sites after upgrading the server to 7.4

quick Solution:
I changed line 57 in includes/cache.inc to return false instead of the cache id.

function cache_get($cid, $bin = 'cache') {
  return false;
}
subir_ghosh’s picture

I removed

ini_set('session.save_handler', 'user');

And it worked.

Phew! What a relief. Thanks everyone.

rfay’s picture

My experience was odd and similar to @twfahey in https://www.drupal.org/project/drupal/issues/3026449#comment-13931291 - It was a simple syntax error in generated (development) settings.ddev.php. I had a double-quote after the driver statement, a complete syntax error, and ended up with this stack trace instead of anything useful.

ressa’s picture

Thanks @Rafal Lukawiecki. My Drupal 7 site WSOD'ed after upgrading to PHP 8.1. With function cache_get() { return false; }; at the top of settings.php I could see the Undefined constant PDO::MYSQL_ATTR_SSL_CA in Drush\Sql\Sqlmysql->creds() error, so I could install the missing PHP package. Here are the packages I needed:

sudo apt install php8.1-cli php8.1-curl php8.1-gd php8.1-mbstring php8.1-sqlite3 php8.1-xml

# don't forget a restart :-)
sudo systemctl restart apache2

# Remove older versions
sudo apt purge php7.2\*
sudo apt purge php7.3\*

# See installed PHP packages and versions
sudo dpkg --get-selections | grep -i php

# Switch between PHP versions
sudo update-alternatives --config php
bburg’s picture

There seems to be two causes of this issue. One, being when you upgrade to PHP7, you need to change

ini_set('session.save_handler', 'user');

with:

session_set_save_handler(new SessionHandler());

I hope most people are on PHP 7 by now though...

The other cause is when you have a syntax error in your settings.php file. This was the case for me, and the settings file was out of version control on this particular site, so my IDE never had a chance to catch it.

I was able to validate the file on the sever with the command line

php -l settings.php

keypetery’s picture

#22 and #43 worked for me.

Running D7.94
Shared hosting service had recently updated to PHP 8.1

Changed settings.php as follows and error warning disappeared:

# ini_set('session.save_handler', 'user');
session_set_save_handler(new SessionHandler());

Thanks DrPal43 and bburg!