Automattic / wp-memcached

Memcached Object Cache for WordPress.
https://wordpress.org/plugins/memcached/
GNU General Public License v2.0
157 stars 55 forks source link

Causes fatal error wil all wp-cli commands #148

Closed trulycool closed 1 year ago

trulycool commented 1 year ago

I have tried both the "official" version of this listed on the WP Plugins "memcached", as well as just trying the version from this repo, which is slightly different.

Memcached server & PECL memcache extension are both installed and working. And both versions of the plugin work fine.

...Except that they both cause a fatal error whenever I try to use wp cli to do anything. And because they are drop ins rather than "regular" plugins, --skip-plugins does not work.

Have also tried the Use Memcached plugin, which is a "standard" WP plugin. It also breaks wp cli, but responds to --skip-plugins=use-memcached. However that plugin breaks the rest of my site (which is being used as a headless backend to JS framework frontend, so specifically seems to be breaking the REST API & WPGraphQL...but I digress).

With this particular version (of object-cache.php from this repo), the wp cli error is: Fatal error: Uncaught Error: Class 'Memcache' not found ...on line 1073

The full message is attached as image here: image

...since wp cli in critical to our workflow, and flushing the cache from the cli an often used function, renaming object-cache.php to object-cache.php.OFF is not a particularly good work around.

Am suspecting the bug may be with wp cli, so reporting the issue there too.

Thanks much, Morgan 🙏

trulycool commented 1 year ago

UPDATE: this turns out to be related to the managed VPS where my site runs. And it is now fixed 🙂

The php.ini they gave me access to (as I don’t have sudo) was in ~/public_html/fcgi-bin, and I blithely assumed that would include PHP CLI…

So tho I had enabled the PECL memcache extension for the regular web PHP, it was not available via PHP CLI, which is essentially a different beast, and what wp-cli uses.

Finally figured it out while reporting the error to the wp-cli repo, and looking for solutions to offer there…contacted my VPS support, and had them add it to the actual system php.ini, and now wp-cli works as expected w/ Memcached Object Cache enabled 🙂

Thanks for the excellent plugin; much appreciated!

All the best, Morgan 🙏

dd32 commented 1 year ago

Thanks for following up on this issue with the problem @trulycool, as noted, this was indeed that the extension wasn't properly loaded.