objectcache: Reduce MediaWiki-specificness from Memcached classes
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 10 Nov 2015 03:20:08 +0000 (03:20 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 10 Nov 2015 03:32:58 +0000 (03:32 +0000)
Follows-up f36b73e96c, which moved these classes to libs/objectcache.

* Fix wrong @throws in MemcachedPeclBagOStuff.
* Fix wrong @returns in MemcachedBagOStuff::getClient().
* Rename MWMemcached to MemcachedClient.
* Remove mention of 'memcached.php', which doesn't exist anymore.

Change-Id: I34dbc859be4778cea489fd2344f233f30452605c

autoload.php
includes/compat/MemcachedClientCompat.php [new file with mode: 0644]
includes/libs/objectcache/MemcachedBagOStuff.php
includes/libs/objectcache/MemcachedClient.php
includes/libs/objectcache/MemcachedPhpBagOStuff.php
includes/objectcache/MemcachedPeclBagOStuff.php
maintenance/mcc.php

index b27ce46..15f1b10 100644 (file)
@@ -721,7 +721,7 @@ $wgAutoloadLocalClasses = array(
        'MWExceptionHandler' => __DIR__ . '/includes/exception/MWExceptionHandler.php',
        'MWHookException' => __DIR__ . '/includes/Hooks.php',
        'MWHttpRequest' => __DIR__ . '/includes/HttpFunctions.php',
-       'MWMemcached' => __DIR__ . '/includes/libs/objectcache/MemcachedClient.php',
+       'MWMemcached' => __DIR__ . '/includes/compat/MemcachedClientCompat.php',
        'MWMessagePack' => __DIR__ . '/includes/libs/MWMessagePack.php',
        'MWNamespace' => __DIR__ . '/includes/MWNamespace.php',
        'MWOldPassword' => __DIR__ . '/includes/password/MWOldPassword.php',
@@ -779,9 +779,10 @@ $wgAutoloadLocalClasses = array(
        'MediaWiki\\Widget\\NamespaceInputWidget' => __DIR__ . '/includes/widget/NamespaceInputWidget.php',
        'MediaWiki\\Widget\\TitleInputWidget' => __DIR__ . '/includes/widget/TitleInputWidget.php',
        'MediaWiki\\Widget\\UserInputWidget' => __DIR__ . '/includes/widget/UserInputWidget.php',
-       'MemCachedClientforWiki' => __DIR__ . '/includes/libs/objectcache/MemcachedClient.php',
+       'MemCachedClientforWiki' => __DIR__ . '/includes/compat/MemcachedClientCompat.php',
        'MemcLockManager' => __DIR__ . '/includes/filebackend/lockmanager/MemcLockManager.php',
        'MemcachedBagOStuff' => __DIR__ . '/includes/libs/objectcache/MemcachedBagOStuff.php',
+       'MemcachedClient' => __DIR__ . '/includes/libs/objectcache/MemcachedClient.php',
        'MemcachedPeclBagOStuff' => __DIR__ . '/includes/objectcache/MemcachedPeclBagOStuff.php',
        'MemcachedPhpBagOStuff' => __DIR__ . '/includes/libs/objectcache/MemcachedPhpBagOStuff.php',
        'MemoizedCallable' => __DIR__ . '/includes/libs/MemoizedCallable.php',
diff --git a/includes/compat/MemcachedClientCompat.php b/includes/compat/MemcachedClientCompat.php
new file mode 100644 (file)
index 0000000..2304733
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Backward-compatibility alias for MemcachedClient
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 1.27
+ * @file
+ */
+
+/**
+ * @deprecated since 1.27
+ */
+class MWMemcached extends MemcachedClient {
+}
+
+/**
+ * @deprecated since 1.27
+ */
+class MemCachedClientforWiki extends MWMemcached {
+}
index 162a531..7a36214 100644 (file)
@@ -27,7 +27,7 @@
  * @ingroup Cache
  */
 class MemcachedBagOStuff extends BagOStuff {
-       /** @var MWMemcached|Memcached */
+       /** @var MemcachedClient|Memcached */
        protected $client;
 
        /**
@@ -86,7 +86,7 @@ class MemcachedBagOStuff extends BagOStuff {
        /**
         * Get the underlying client object. This is provided for debugging
         * purposes.
-        * @return BagOStuff
+        * @return MemcachedClient|Memcached
         */
        public function getClient() {
                return $this->client;
index 5010b89..8007a53 100644 (file)
  */
 
 /**
- * This is the PHP client for memcached - a distributed memory cache daemon.
+ * This is a PHP client for memcached - a distributed memory cache daemon.
+ *
  * More information is available at http://www.danga.com/memcached/
  *
  * Usage example:
  *
- * require_once 'memcached.php';
- *
- * $mc = new MWMemcached(array(
- *              'servers' => array('127.0.0.1:10000',
- *                                 array('192.0.0.1:10010', 2),
- *                                 '127.0.0.1:10020'),
- *              'debug'   => false,
- *              'compress_threshold' => 10240,
- *              'persistent' => true));
+ *     $mc = new MemcachedClient(array(
+ *         'servers' => array(
+ *             '127.0.0.1:10000',
+ *             array( '192.0.0.1:10010', 2 ),
+ *             '127.0.0.1:10020'
+ *         ),
+ *         'debug'   => false,
+ *         'compress_threshold' => 10240,
+ *         'persistent' => true
+ *     ));
  *
- * $mc->add( 'key', array( 'some', 'array' ) );
- * $mc->replace( 'key', 'some random string' );
- * $val = $mc->get( 'key' );
+ *     $mc->add( 'key', array( 'some', 'array' ) );
+ *     $mc->replace( 'key', 'some random string' );
+ *     $val = $mc->get( 'key' );
  *
- * @author  Ryan T. Dean <rtdean@cytherianage.net>
+ * @author Ryan T. Dean <rtdean@cytherianage.net>
  * @version 0.1.2
  */
 
 use Psr\Log\LoggerInterface;
 use Psr\Log\NullLogger;
 
-// {{{ requirements
-// }}}
-
-// {{{ class MWMemcached
+// {{{ class MemcachedClient
 /**
  * memcached client class implemented using (p)fsockopen()
  *
  * @author  Ryan T. Dean <rtdean@cytherianage.net>
  * @ingroup Cache
  */
-class MWMemcached {
+class MemcachedClient {
        // {{{ properties
        // {{{ public
 
@@ -659,7 +658,7 @@ class MWMemcached {
        // {{{ set_compress_threshold()
 
        /**
-        * Sets the compression threshold
+        * Set the compression threshold
         *
         * @param int $thresh Threshold to compress if larger than
         */
@@ -671,11 +670,10 @@ class MWMemcached {
        // {{{ set_debug()
 
        /**
-        * Sets the debug flag
+        * Set the debug flag
         *
+        * @see __construct()
         * @param bool $dbg True for debugging, false otherwise
-        *
-        * @see MWMemcached::__construct
         */
        public function set_debug( $dbg ) {
                $this->_debug = $dbg;
@@ -685,11 +683,10 @@ class MWMemcached {
        // {{{ set_servers()
 
        /**
-        * Sets the server list to distribute key gets and puts between
+        * Set the server list to distribute key gets and puts between
         *
+        * @see __construct()
         * @param array $list Array of servers to connect to
-        *
-        * @see MWMemcached::__construct()
         */
        public function set_servers( $list ) {
                $this->_servers = $list;
@@ -1271,6 +1268,3 @@ class MWMemcached {
 }
 
 // }}}
-
-class MemCachedClientforWiki extends MWMemcached {
-}
index 1bb38fa..e2d9d93 100644 (file)
@@ -42,7 +42,7 @@ class MemcachedPhpBagOStuff extends MemcachedBagOStuff {
                parent::__construct( $params );
                $params = $this->applyDefaultParams( $params );
 
-               $this->client = new MWMemcached( $params );
+               $this->client = new MemcachedClient( $params );
                $this->client->set_servers( $params['servers'] );
                $this->client->set_debug( $params['debug'] );
        }
index b7d1eaf..aa21cbb 100644 (file)
@@ -43,7 +43,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
         *                          values, but serialization is much slower unless the php.ini option
         *                          igbinary.compact_strings is off.
         * @param array $params
-        * @throws MWException
+        * @throws InvalidArgumentException
         */
        function __construct( $params ) {
                parent::__construct( $params );
@@ -89,7 +89,7 @@ class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
                // is as good as any. There's no way to configure libmemcached to use
                // hashes identical to the ones currently in use by the PHP client, and
                // even implementing one of the libmemcached hashes in pure PHP for
-               // forwards compatibility would require MWMemcached::get_sock() to be
+               // forwards compatibility would require MemcachedClient::get_sock() to be
                // rewritten.
                $this->client->setOption( Memcached::OPT_LIBKETAMA_COMPATIBLE, true );
 
index 7b7b761..6b8487f 100644 (file)
@@ -35,7 +35,7 @@ if ( $help ) {
        mccShowUsage();
        exit( 0 );
 }
-$mcc = new MWMemcached( array(
+$mcc = new MemcachedClient( array(
        'persistent' => true,
        'debug' => $debug,
 ) );