Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Uncaught Error: Call to undefined function cache_get() due to PHP version mismatch #1964

Closed
danepowell opened this issue Aug 29, 2019 · 3 comments

Comments

@danepowell
Copy link
Contributor

danepowell commented Aug 29, 2019

Issue Type

  • Bug Report / Support Request

Your Environment

Vagrant 2.2.5
VirtualBox 6.0.10r132072
ansible 2.8.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/dane/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.16 (default, Apr  6 2019, 01:42:57) [GCC 8.3.0]

Your OS

  • Linux (Ubuntu 19.04)

Full console output

vagrant@local:/var/www/drupalvm$ drush si
PHP Fatal error:  Uncaught Error: Call to undefined function cache_get() in /var/www/drupalvm/includes/module.inc:762
Stack trace:
#0 /var/www/drupalvm/includes/module.inc(962): module_implements('system_theme_in...')
#1 /var/www/drupalvm/modules/system/system.module(2514): module_invoke_all('system_theme_in...')
#2 /var/www/drupalvm/includes/theme.inc(798): _system_rebuild_theme_data()
#3 /var/www/drupalvm/includes/theme.maintenance.inc(57): list_themes()
#4 /var/www/drupalvm/includes/bootstrap.inc(2935): _drupal_maintenance_theme()
#5 /var/www/drupalvm/includes/errors.inc(179): drupal_maintenance_theme()
#6 /var/www/drupalvm/includes/bootstrap.inc(2647): _drupal_log_error(Array, true)
#7 [internal function]: _drupal_exception_handler(Object(Error))
#8 {main}
  thrown in /var/www/drupalvm/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/drupalvm/includes/module.inc:762
Stack trace:
#0 /var/www/drupalvm/includes/module.inc(962): module_implements('system_theme_in...')
#1 /var/www/drupalvm/modules/system/system.module(2514): module_invoke_all('system_theme_in...')
#2 /var/www/drupalvm/includes/theme.inc(798): _system_rebuild_theme_data()
#3 /var/www/drupalvm/includes/theme.maintenance.inc(57): list_themes()
#4 /var/www/drupalvm/includes/bootstrap.inc(2935): _drupal_maintenance_theme()
#5 /var/www/drupalvm/includes/errors.inc(179): drupal_maintenance_theme()
#6 /var/www/drupalvm/includes/bootstrap.inc(2647): _drupal_log_error(Array, true)
#7 [internal function]: _drupal_exception_handler(Object(Error))
#8 {main}
  thrown in /var/www/drupalvm/includes/module.inc, line 762

Summary

When I try to run any Drush command (or just drush) inside my VM, I get the above error. This is a Drupal 7 codebase.

I think the problem is that even though I've configured the VM to use PHP 7.1, the CLI still uses PHP 7.3. And the MySQL extension is missing for PHP 7.3 (it's only present for 7.1).

As a workaround, I can run this in the VM: sudo apt-get install php7.3-mysql

However, it seems like there's a bug in DrupalVM here, with one of two possible fixes:

  1. The PHP CLI version should be pinned similarly to the web server version, so that it has the same extensions available
  2. The native PHP should have the MySQL extension installed

My config.yml:

vagrant_hostname: local.foo.edu
vagrant_machine_name: foo
vagrant_ip: 192.168.23.33

drupal_build_composer: false
drupal_build_composer_project: false
drupal_install_site: false

drupal_core_path: "/var/www/drupalvm"

php_version: "7.1"

Seems similar to #1498

@geerlingguy
Copy link
Owner

geerlingguy commented Aug 29, 2019

I'm not sure why the 7.3 version would still be installed...

The php-versions role sets it here:

https://github.com/geerlingguy/ansible-role-php-versions/blob/master/vars/Debian.yml#L14

And that overrides what's set in the php-mysql role here:

https://github.com/geerlingguy/ansible-role-php-mysql/blob/master/vars/Debian.yml#L2

Is it possible this was a VM that was initially created with 7.3, then you changed the PHP version? There could be a bug in the process of changing PHP versions (but even that should work correctly).

@geerlingguy
Copy link
Owner

This is definitely related to #1963, which I'm about to fix through an upstream role update.

geerlingguy added a commit that referenced this issue Aug 29, 2019
…en installing different PHP version.
@geerlingguy
Copy link
Owner

I believe the above commit fixes this issue. Please try the latest master release and see if it's still an issue (I will be tagging a new release soon, as well).

dhaley pushed a commit to NREL/drupal-vm that referenced this issue Sep 4, 2019
…eerlingguy#1964: Purge php-common package when installing different PHP version.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants