@@ -51,8 +51,11 @@ function __construct($search = null) { parent::__construct('user', $search); }
5151 $ memcache = new \Memcached ();
5252 $ memcacheVersion = 'memcached ' ;
5353 $ memcache ->addServer (MEMCACHE_HOST , MEMCACHE_PORT );
54- if (!empty (MEMCACHE_USER ) && !empty (MEMCACHE_PASSWORD ))
54+ if (!empty (MEMCACHE_USER ) && !empty (MEMCACHE_PASSWORD )) {
55+ $ memcacheVersion = 'memcached-bin ' ;
56+ $ memcache ->setOption (Memcached::OPT_BINARY_PROTOCOL , true );
5557 $ memcache ->setSaslAuthData (MEMCACHE_USER , MEMCACHE_PASSWORD );
58+ }
5659 $ memcache_stats = $ memcache ->getStats ();
5760 } else if (extension_loaded ('memcache ' )) {
5861 // This extension does not support SASL authentication
@@ -203,10 +206,11 @@ function memcache_get_key($key, &$found = false) {
203206
204207 function memcache_ref () {
205208 global $ memcache ;
209+ global $ memcacheVersion ;
206210
207211 // Listing keys is not supported using the legacy Memcache module
208212 // PHP 7 and newer do not support this extension anymore
209- if (! extension_loaded ( 'memcached ' ) )
213+ if ($ memcacheVersion != 'memcached ' )
210214 return array ();
211215
212216 $ items = $ memcache ->getAllKeys ();
@@ -659,6 +663,10 @@ function sort_list(&$list) {
659663 </table>
660664 </div>
661665 <?php endif ; ?>
666+ <?php elseif ($ memcacheVersion == 'memcached-bin ' ): ?>
667+ <p style="text-align: center">
668+ When SASL authentication is enabled on the <a href="https://pecl.php.net/package/memcached">memcached extension</a> we can not support listing keys
669+ </p>
662670 <?php else : ?>
663671 <p style="text-align: center">
664672 Legacy <a href="https://pecl.php.net/package/memcache">memcache extension</a> does not support listing keys
0 commit comments