After starting from scratch I enabled the plugin and got it working with elasticsearch. When I installed memcached is your friend plugin for object cache the host for elasticpress got reset to 127.0.0.1 without the port. I had to disable object cache to be able to reset it to 127.0.0.1:9200.
Which version are you using?
What happens when you try to set the host again? Maybe an old value was stuck in cache?
I was using the current version installed from the w.org repo 12 days ago.
Unfortunately this was related to the other bug I posted https://github.com/10up/ElasticPress/issues/521 so my only choice was to start from scratch.
Is the host and port set as a transient and if so is that necessary?
Yes it is unfortunately. I'd suggest giving 2.1 in the develop branch a try.
@blindpet I believe the issue with The Memcached is Your Friend plugin is its use of private scope on the cache groups it sets, which prevents from Elasticpress (and even some core WordPress functions) from clearing the cache group.
When the ElasticPress stop_the_insanity() tries to clear some of these (specifically specifically 'group_ops' and 'stats') it is unable to due to the private scope.
Memcached Is Your Friend
class WP_Object_Cache {
private $global_groups = array();
private $no_mc_groups = array();
private $cache = array();
private $mc = array();
private $stats = array( 'add' => 0, 'delete' => 0, 'get' => 0, 'get_multi' => 0, );
private $group_ops = array();
private $cache_enabled = true;
private $default_expiration = 0;
Elasticpress
public function stop_the_insanity() {
global $wpdb, $wp_object_cache, $wp_actions, $wp_filter;
$wpdb->queries = array();
if ( is_object( $wp_object_cache ) ) {
$wp_object_cache->group_ops = array();
$wp_object_cache->stats = array();
$wp_object_cache->memcache_debug = array();
Thanks @rveitch for looking into this, do you suggest making the group ops and stats public instead of private?
Hi @blindpet, no problem. Here are the compatibility fixes I made to Memcached is Your Friend on the production server where I encountered the issue myself. They resolved all the related issues for me, but for good measure I would recommend testing before implementing on a production server.
Aside from changes from private to public, I also added $memcache_debug to ensure the group is already present and public before stop_the_insantity() tries clearing it. Hope this helps, good luck!
Changes to memcached-class-object-cache.php:
class WP_Object_Cache {
public $global_groups = array(); // (was private)
public $no_mc_groups = array(); // (was private)
public $cache = array(); // (was private)
public $mc = array(); // (was private)
public $stats = array( 'add' => 0, 'delete' => 0, 'get' => 0, 'get_multi' => 0, ); // (was private)
public $group_ops = array(); // (was private)
public $memcache_debug = array(); // added for ElasticPress compatibility
public $cache_enabled = true; // modified to allow wordpress to properly disable object cache in wp-activate.php +22 (was private)
Is it safe to change private to public? What is the impact of making it public ?
@jdanarola the impact is everything actually works as expected with all other plugins, these private functions only cause problems and I have notified the memcached and redis plugin developers to change it to end PHP crashes
For anybody that finds this I forked the plugin https://github.com/wpbullet/memcached-is-your-friend since the original author was not responding on the forum
@blindpet
Thanks for updating and forking Memcached Is Your Friend.
Most helpful comment
For anybody that finds this I forked the plugin https://github.com/wpbullet/memcached-is-your-friend since the original author was not responding on the forum