Chassis / memcache

A Chassis extension to install and configure memcached on your server.
1 stars 5 forks source link

Warning: Memcached::addServers(): server list entry # is not an array #18

Closed tdlm closed 5 years ago

tdlm commented 6 years ago

While setting up Disney Newsroom Chassis instance, we ran across this warning, which disables logging into the back-end.

It seems like the local-config.php being generated by Puppet is to blame since the expected format for the $memcached_servers global is a nested array, like in the current constructor call when the global is not set:

        if ( isset( $memcached_servers ) )
            $this->servers = $memcached_servers;
        else
            $this->servers = array( array( '127.0.0.1', 11211 ) );

Thus, changing the local-config value from a single array to a nested array removes the warning and fixes the issue:

<?php

// This is generated automatically by Puppet. Edit at your own risk.

$memcached_servers = [ [ '127.0.0.1', 11211 ] ];
BronsonQuick commented 6 years ago

Hey @tdlm! Can you please cd extensions/memcache; git pull; vagrant provision for me and see if it works okay? I actually removed the template file we had for this the other day: https://github.com/Chassis/memcache/pull/13/files so I think without it it should "just work". Let me know if it doesn't though!

Sidenote: I was working on a new Chassis feature yesterday that automatically detects and installs updates. chassis__fish__volumessiteschassis__-fish_2018-03-13_17-48-45

There's a typo in the notice there but you can see the general functionality of it. I have to do a little refactoring but I'll ship that later today!

tdlm commented 6 years ago

@BronsonQuick That auto-updater looks awesome!

As for your instructions, I ran them, verified I was up to date on the memcache extension and reprovisioned, but the file stayed in place, so the error persisted.

Deleting the chassis/extensions/memcache/local-config.php file altogether works just fine. Additionally, I cloned the repo just today, so I'm really not sure why the file got created at all given your recent changes (and I confirmed the deleted .pp and .erb files are gone).

Puzzling. I'm thinking I might start over just to see when it gets created.

BronsonQuick commented 6 years ago

Ahh right. Thanks for letting me know about that! I'll try creating a new Chassis install with memcache when I get to the office today and see if I can replicate it. If I can't I'll close this issue. If I can I'll fix it up. Thanks for the issue!

rmccue commented 6 years ago

This is because both Memcache and Memcached use the same global, but take different input formats. This format is IIRC for Memcache, while Memcached requires the other. Total pain, not sure how well we can resolve it.

joehoyle commented 6 years ago

This is how we nastily do it:

        /**
     * If we are PHP 7+ then we are using the memcached extension and dropin, so the
     * $memcached_servers array is slightly differently formatted.
     */
    if ( class_exists( 'Memcached' ) ) {
        $memcached_servers = array( array( "hostname", 11211 ) );
    } else {
        $memcached_servers = array( "hostname:11211" );
    }
rmccue commented 6 years ago

In Chassis we install both extensions to allow users to pick what they want, so this won't work.

mikeselander commented 6 years ago

It would be very useful to add this documentation on the README so that devs can more easily find this. I've struggled with figuring this out more than once.