Fix for r41108 (as per comment on bug 15642): Also disallow blocking anonymous users
[lhc/web/wiklou.git] / includes / memcached-client.php
index 21f0c83..cf98bb9 100644 (file)
@@ -57,7 +57,6 @@
  * $val = $mc->get('key');
  *
  * @author  Ryan T. Dean <rtdean@cytherianage.net>
- * @package memcached-client
  * @version 0.1.2
  */
 
@@ -69,7 +68,7 @@
  * memcached client class implemented using (p)fsockopen()
  *
  * @author  Ryan T. Dean <rtdean@cytherianage.net>
- * @addtogroup Cache
+ * @ingroup Cache
  */
 class memcached
 {
@@ -153,7 +152,7 @@ class memcached
    /**
     * At how many bytes should we compress?
     *
-    * @var     integer 
+    * @var     integer
     * @access  private
     */
    var $_compress_threshold;
@@ -193,7 +192,7 @@ class memcached
    /**
     * Total # of bit buckets we have
     *
-    * @var     integer 
+    * @var     integer
     * @access  private
     */
    var $_bucketcount;
@@ -201,7 +200,7 @@ class memcached
    /**
     * # of total servers we have
     *
-    * @var     integer 
+    * @var     integer
     * @access  private
     */
    var $_active;
@@ -402,6 +401,10 @@ class memcached
       $fname = 'memcached::get';
       wfProfileIn( $fname );
 
+      if ( $this->_debug ) {
+         $this->_debugprint( "get($key)\n" );
+      }
+
       if (!$this->_active) {
         wfProfileOut( $fname );
          return false;
@@ -429,7 +432,7 @@ class memcached
 
       if ($this->_debug)
          foreach ($val as $k => $v)
-            $this->_debugprint(@sprintf("MemCache: sock %s got %s => %s\r\n", serialize($sock), $k, $v));
+            $this->_debugprint(sprintf("MemCache: sock %s got %s\n", serialize($sock), $k));
 
       wfProfileOut( $fname );
       return @$val[$key];
@@ -453,7 +456,7 @@ class memcached
 
       $this->stats['get_multi']++;
       $sock_keys = array();
-      
+
       foreach ($keys as $key)
       {
          $sock = $this->get_sock($key);
@@ -495,7 +498,7 @@ class memcached
 
       if ($this->_debug)
          foreach ($val as $k => $v)
-            $this->_debugprint(sprintf("MemCache: got %s => %s\r\n", $k, $v));
+            $this->_debugprint(sprintf("MemCache: got %s\n", $k));
 
       return $val;
    }
@@ -792,6 +795,11 @@ class memcached
       $realkey = is_array($key) ? $key[1] : $key;
       for ($tries = 0; $tries<20; $tries++)
       {
+            // temp logging for strange bug
+                if( !isset($this->_buckets[$hv % $this->_bucketcount]) ) {
+                   wfDebugLog( "memcached", "Invalid bucket hash '$hv' from key '$realkey' given!" );
+                   continue;
+                }
          $host = $this->_buckets[$hv % $this->_bucketcount];
          $sock = $this->sock_to_host($host);
          if (is_resource($sock)) {
@@ -980,9 +988,7 @@ class memcached
 
       if ($this->_debug)
       {
-         if ($flags & memcached::COMPRESSED)
-            $val = 'compressed data';
-         $this->_debugprint(sprintf("MemCache: %s %s => %s (%s)\n", $cmd, $key, $val, $line));
+         $this->_debugprint(sprintf("%s %s (%s)\n", $cmd, $key, $line));
       }
       if ($line == "STORED")
          return true;
@@ -1086,4 +1092,3 @@ class memcached
 // vim: sts=3 sw=3 et
 
 // }}}
-