wp-local-docker-v2 icon indicating copy to clipboard operation
wp-local-docker-v2 copied to clipboard

Memcache error when using WP Snapshots CLI from 10updocker

Open cameronterry opened this issue 4 years ago • 2 comments

Describe the bug Running WPSnapshots through 10up Docker on a site using Memcache - for example: VIP local development and this version of object-cache.php - seems to cause an error, claiming Memcache is not found, at the "export database" step.

Additional notes:

  • At a guess, it seems the php.ini for PHP CLI is missing Memcache but PHP-FPM is not: as the caching works through the web version. It also works through 10updocker shell phpfpm and using the WP CLI.
  • Working from the aforementioned guess, I noticed php7.4-memcache was not installed on the host - so I added it and still produced the same error.

Steps to Reproduce

  1. Local site with WordPress and a version of object-cache.php calling new Memcache().
  2. On host machine, run the command 10updocker wpsnapshots push.
  3. Provide the snapshot details
  4. Produces this error:
Project Slug (letters, numbers, _, and - only): ######
Snapshot Description (e.g. Local environment): #########
Include files in snapshot? (Y/n) y
Include database in snapshot? (Y/n) y

Fatal error: Uncaught Error: Class 'Memcache' not found in /var/www/html/wp-content/object-cache.php on line 543

Error: Class 'Memcache' not found in /var/www/html/wp-content/object-cache.php on line 543

Call Stack:
    0.0001     389032   1. {main}() /opt/wpsnapshots/bin/wpsnapshots:0
    0.0024     933408   2. require_once('/opt/wpsnapshots/src/bootstrap.php') /opt/wpsnapshots/bin/wpsnapshots:12
    0.0082    1958824   3. Symfony\Component\Console\Application->run() /opt/wpsnapshots/src/bootstrap.php:35
    0.0122    2262584   4. Symfony\Component\Console\Application->doRun() /opt/wpsnapshots/vendor/symfony/console/Application.php:145
    0.0123    2262584   5. Symfony\Component\Console\Application->doRunCommand() /opt/wpsnapshots/vendor/symfony/console/Application.php:262
    0.0123    2262584   6. WPSnapshots\Command\Push->run() /opt/wpsnapshots/vendor/symfony/console/Application.php:886
    0.0128    2268688   7. WPSnapshots\Command\Push->execute() /opt/wpsnapshots/vendor/symfony/console/Command/Command.php:251
   10.9125    6951296   8. WPSnapshots\Snapshot::create() /opt/wpsnapshots/src/classes/Command/Push.php:165
   10.9131    6982504   9. WPSnapshots\WordPressBridge->load() /opt/wpsnapshots/src/classes/Snapshot.php:178
   10.9185    7122328  10. require_once('/var/www/html/wp-settings.php') /opt/wpsnapshots/src/classes/WordPressBridge.php:183
   10.9390   11590968  11. wp_start_object_cache() /var/www/html/wp-settings.php:131
   10.9394   11741688  12. wp_cache_init() /var/www/html/wp-includes/load.php:683
   10.9394   11741968  13. WP_Object_Cache->__construct() /var/www/html/wp-content/object-cache.php:64

Expected behavior I didn't expect the Class 'Memcache' not found error.

Environment information

  • Device: PC
  • OS: Ubuntu Desktop 20.04 LTS

cameronterry avatar Apr 26 '21 10:04 cameronterry

@cameronterry I think this is a wpsnapshots issue and not related to wp-local-docker since wpsnapshots creates its own docker image that wp-local-docker uses. I think this image: https://hub.docker.com/r/10up/wpsnapshots/tags doesn't have memcached installed thus you are seeing this issue. can you shell into the wpsnapshots container and try installing memcached manually and see if they still have the issue?

tylercherpak avatar Nov 15 '21 15:11 tylercherpak

@tylercherpak I haven't had any success installing php-memcached package on the Snapshots container (or any package for that matter). It returns this error:

:/opt/wpsnapshots# apt install php-memcached 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package php-memcached is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php-memcached' has no installation candidate

That aside, it does suggest the lack of Memcache support is the cause of the error I saw, considering it's not installed.

However there seems to be an additional consideration. It seems the wpsnapshots container used by 10updocker does not have access to the memcache container, so even if the above was resolved, there is network connectivity issue. I used the following commands, testing against MySQL (which obviously works) and comparing the memcached DNS (which is used in wp-config.php) using curl (because telnet wasn't available on the container):

$ root@[...]:/opt/wpsnapshots# curl -vv telnet://mysql:3306
* Rebuilt URL to: telnet://mysql:3306/
*   Trying 10.0.128.0...
* TCP_NODELAY set
* Connected to mysql (10.0.128.0) port 3306 (#0)
J
* RCVD IAC 193
^C


$ root@[...]:/opt/wpsnapshots# curl -vv telnet://memcached:11211
* Rebuilt URL to: telnet://memcached:11211/
* Could not resolve host: memcached
* Closing connection 0
curl: (6) Could not resolve host: memcached

So it seems there is two problems at play:

  1. The wpsnapshots container not having php-memcached package installed
  2. Connectivity between the wpsnapshots container and the memcached container.

I hope this helps.

cameronterry avatar Dec 22 '21 15:12 cameronterry