Revert r114067, r114071, r114075, r114079, r114081, r114082, r114084, r114086, r11408...
authorRoan Kattouw <catrope@users.mediawiki.org>
Tue, 20 Mar 2012 23:03:59 +0000 (23:03 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Tue, 20 Mar 2012 23:03:59 +0000 (23:03 +0000)
This reverts the SpecialCachedPage and formatDuration sagas, with some collateral damage here and there. All of these revisions are tagged with 'gerritmigration' and will be resubmitted into Gerrit after the Gerrit switchover. See also http://lists.wikimedia.org/pipermail/wikitech-l/2012-March/059124.html

includes/AutoLoader.php
includes/CacheHelper.php [deleted file]
includes/actions/CachedAction.php [deleted file]
includes/objectcache/MemcachedClient.php
includes/specials/SpecialCachedPage.php [deleted file]
languages/Language.php
languages/classes/LanguageKaa.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc
tests/phpunit/languages/LanguageTest.php

index 41b7481..ca31248 100644 (file)
@@ -27,7 +27,6 @@ $wgAutoloadLocalClasses = array(
        'BadTitleError' => 'includes/Exception.php',
        'BaseTemplate' => 'includes/SkinTemplate.php',
        'Block' => 'includes/Block.php',
-       'CacheHelper' => 'includes/CacheHelper.php',
        'Category' => 'includes/Category.php',
        'Categoryfinder' => 'includes/Categoryfinder.php',
        'CategoryPage' => 'includes/CategoryPage.php',
@@ -121,7 +120,6 @@ $wgAutoloadLocalClasses = array(
        'Http' => 'includes/HttpFunctions.php',
        'HttpError' => 'includes/Exception.php',
        'HttpRequest' => 'includes/HttpFunctions.old.php',
-       'ICacheHelper' => 'includes/CacheHelper.php',
        'IcuCollation' => 'includes/Collation.php',
        'IdentityCollation' => 'includes/Collation.php',
        'ImageGallery' => 'includes/ImageGallery.php',
@@ -260,7 +258,6 @@ $wgAutoloadLocalClasses = array(
        'ZipDirectoryReader' => 'includes/ZipDirectoryReader.php',
 
        # includes/actions
-       'CachedAction' => 'includes/actions/CachedAction.php',
        'CreditsAction' => 'includes/actions/CreditsAction.php',
        'DeleteAction' => 'includes/actions/DeleteAction.php',
        'EditAction' => 'includes/actions/EditAction.php',
@@ -827,7 +824,6 @@ $wgAutoloadLocalClasses = array(
        'SpecialBlockList' => 'includes/specials/SpecialBlockList.php',
        'SpecialBlockme' => 'includes/specials/SpecialBlockme.php',
        'SpecialBookSources' => 'includes/specials/SpecialBooksources.php',
-       'SpecialCachedPage' => 'includes/specials/SpecialCachedPage.php',
        'SpecialCategories' => 'includes/specials/SpecialCategories.php',
        'SpecialChangeEmail' => 'includes/specials/SpecialChangeEmail.php',
        'SpecialChangePassword' => 'includes/specials/SpecialChangePassword.php',
diff --git a/includes/CacheHelper.php b/includes/CacheHelper.php
deleted file mode 100644 (file)
index 92f1d46..0000000
+++ /dev/null
@@ -1,339 +0,0 @@
-<?php
-
-/**
- * Interface for all classes implementing CacheHelper functionality.
- *
- * @since 1.20
- *
- * @licence GNU GPL v2 or later
- * @author Jeroen De Dauw < jeroendedauw@gmail.com >
- */
-interface ICacheHelper {
-
-       /**
-        * Sets if the cache should be enabled or not.
-        *
-        * @since 1.20
-        * @param boolean $cacheEnabled
-        */
-       function setCacheEnabled( $cacheEnabled );
-
-       /**
-        * Initializes the caching.
-        * Should be called before the first time anything is added via addCachedHTML.
-        *
-        * @since 1.20
-        *
-        * @param integer|null $cacheExpiry Sets the cache expirty, either ttl in seconds or unix timestamp.
-        * @param boolean|null $cacheEnabled Sets if the cache should be enabled or not.
-        */
-       function startCache( $cacheExpiry = null, $cacheEnabled = null );
-
-       /**
-        * Get a cached value if available or compute it if not and then cache it if possible.
-        * The provided $computeFunction is only called when the computation needs to happen
-        * and should return a result value. $args are arguments that will be passed to the
-        * compute function when called.
-        *
-        * @since 1.20
-        *
-        * @param {function} $computeFunction
-        * @param array|mixed $args
-        * @param string|null $key
-        *
-        * @return mixed
-        */
-       function getCachedValue( $computeFunction, $args = array(), $key = null );
-
-       /**
-        * Saves the HTML to the cache in case it got recomputed.
-        * Should be called after the last time anything is added via addCachedHTML.
-        *
-        * @since 1.20
-        */
-       function saveCache();
-
-       /**
-        * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry..
-        *
-        * @since 1.20
-        *
-        * @param integer $cacheExpiry
-        */
-       function setExpirey( $cacheExpiry );
-
-}
-
-/**
- * Helper class for caching various elements in a single cache entry.
- *
- * To get a cached value or compute it, use getCachedValue like this:
- * $this->getCachedValue( $callback );
- *
- * To add HTML that should be cached, use addCachedHTML like this:
- * $this->addCachedHTML( $callback );
- *
- * The callback function is only called when needed, so do all your expensive
- * computations here. This function should returns the HTML to be cached.
- * It should not add anything to the PageOutput object!
- *
- * Before the first addCachedHTML call, you should call $this->startCache();
- * After adding the last HTML that should be cached, call $this->saveCache();
- *
- * @since 1.20
- *
- * @file CacheHelper.php
- *
- * @licence GNU GPL v2 or later
- * @author Jeroen De Dauw < jeroendedauw@gmail.com >
- */
-class CacheHelper implements ICacheHelper {
-
-       /**
-        * The time to live for the cache, in seconds or a unix timestamp indicating the point of expiry.
-        *
-        * @since 1.20
-        * @var integer
-        */
-       protected $cacheExpiry = 3600;
-
-       /**
-        * List of HTML chunks to be cached (if !hasCached) or that where cashed (of hasCached).
-        * If no cached already, then the newly computed chunks are added here,
-        * if it as cached already, chunks are removed from this list as they are needed.
-        *
-        * @since 1.20
-        * @var array
-        */
-       protected $cachedChunks;
-
-       /**
-        * Indicates if the to be cached content was already cached.
-        * Null if this information is not available yet.
-        *
-        * @since 1.20
-        * @var boolean|null
-        */
-       protected $hasCached = null;
-
-       /**
-        * If the cache is enabled or not.
-        *
-        * @since 1.20
-        * @var boolean
-        */
-       protected $cacheEnabled = true;
-
-       /**
-        * Function that gets called when initialization is done.
-        *
-        * @since 1.20
-        * @var function
-        */
-       protected $onInitHandler = false;
-
-       /**
-        * Sets if the cache should be enabled or not.
-        *
-        * @since 1.20
-        * @param boolean $cacheEnabled
-        */
-       public function setCacheEnabled( $cacheEnabled ) {
-               $this->cacheEnabled = $cacheEnabled;
-       }
-
-       /**
-        * Initializes the caching.
-        * Should be called before the first time anything is added via addCachedHTML.
-        *
-        * @since 1.20
-        *
-        * @param integer|null $cacheExpiry Sets the cache expirty, either ttl in seconds or unix timestamp.
-        * @param boolean|null $cacheEnabled Sets if the cache should be enabled or not.
-        */
-       public function startCache( $cacheExpiry = null, $cacheEnabled = null ) {
-               if ( is_null( $this->hasCached ) ) {
-                       if ( !is_null( $cacheExpiry ) ) {
-                               $this->cacheExpiry = $cacheExpiry;
-                       }
-
-                       if ( !is_null( $cacheEnabled ) ) {
-                               $this->setCacheEnabled( $cacheEnabled );
-                       }
-
-                       $this->initCaching();
-               }
-       }
-
-       /**
-        * Returns a message that notifies the user he/she is looking at
-        * a cached version of the page, including a refresh link.
-        *
-        * @since 1.20
-        *
-        * @param IContextSource $context
-        *
-        * @return string
-        */
-       public function getCachedNotice( IContextSource $context ) {
-               $refreshArgs = $context->getRequest()->getQueryValues();
-               unset( $refreshArgs['title'] );
-               $refreshArgs['action'] = 'purge';
-
-               $subPage = $context->getTitle()->getFullText();
-               $subPage = explode( '/', $subPage, 2 );
-               $subPage = count( $subPage ) > 1 ? $subPage[1] : false;
-
-               $refreshLink = Linker::link(
-                       $context->getTitle( $subPage ),
-                       $context->msg( 'cachedspecial-refresh-now' )->escaped(),
-                       array(),
-                       $refreshArgs
-               );
-
-               if ( $this->cacheExpiry < 86400 * 3650 ) {
-                       $message = $context->msg(
-                               'cachedspecial-viewing-cached-ttl',
-                               $context->getLanguage()->formatDuration( $this->cacheExpiry )
-                       )->escaped();
-               }
-               else {
-                       $message = $context->msg(
-                               'cachedspecial-viewing-cached-ts'
-                       )->escaped();
-               }
-
-               return $message . ' ' . $refreshLink;
-       }
-
-       /**
-        * Initializes the caching if not already done so.
-        * Should be called before any of the caching functionality is used.
-        *
-        * @since 1.20
-        */
-       protected function initCaching() {
-               if ( $this->cacheEnabled && is_null( $this->hasCached ) ) {
-                       $cachedChunks = wfGetCache( CACHE_ANYTHING )->get( $this->getCacheKeyString() );
-
-                       $this->hasCached = is_array( $cachedChunks );
-                       $this->cachedChunks = $this->hasCached ? $cachedChunks : array();
-
-                       if ( $this->onInitHandler !== false ) {
-                               call_user_func( $this->onInitHandler, $this->hasCached );
-                       }
-               }
-       }
-
-       /**
-        * Get a cached value if available or compute it if not and then cache it if possible.
-        * The provided $computeFunction is only called when the computation needs to happen
-        * and should return a result value. $args are arguments that will be passed to the
-        * compute function when called.
-        *
-        * @since 1.20
-        *
-        * @param {function} $computeFunction
-        * @param array|mixed $args
-        * @param string|null $key
-        *
-        * @return mixed
-        */
-       public function getCachedValue( $computeFunction, $args = array(), $key = null ) {
-               $this->initCaching();
-
-               if ( $this->cacheEnabled && $this->hasCached ) {
-                       $value = null;
-
-                       if ( is_null( $key ) ) {
-                               $itemKey = array_keys( array_slice( $this->cachedChunks, 0, 1 ) );
-                               $itemKey = array_shift( $itemKey );
-
-                               if ( !is_integer( $itemKey ) ) {
-                                       wfWarn( "Attempted to get item with non-numeric key while the next item in the queue has a key ($itemKey) in " . __METHOD__ );
-                               }
-                               elseif ( is_null( $itemKey ) ) {
-                                       wfWarn( "Attempted to get an item while the queue is empty in " . __METHOD__ );
-                               }
-                               else {
-                                       $value = array_shift( $this->cachedChunks );
-                               }
-                       }
-                       else {
-                               if ( array_key_exists( $key, $this->cachedChunks ) ) {
-                                       $value = $this->cachedChunks[$key];
-                                       unset( $this->cachedChunks[$key] );
-                               }
-                               else {
-                                       wfWarn( "There is no item with key '$key' in this->cachedChunks in " . __METHOD__ );
-                               }
-                       }
-               }
-               else {
-                       if ( !is_array( $args ) ) {
-                               $args = array( $args );
-                       }
-
-                       $value = call_user_func_array( $computeFunction, $args );
-
-                       if ( $this->cacheEnabled ) {
-                               if ( is_null( $key ) ) {
-                                       $this->cachedChunks[] = $value;
-                               }
-                               else {
-                                       $this->cachedChunks[$key] = $value;
-                               }
-                       }
-               }
-
-               return $value;
-       }
-
-       /**
-        * Saves the HTML to the cache in case it got recomputed.
-        * Should be called after the last time anything is added via addCachedHTML.
-        *
-        * @since 1.20
-        */
-       public function saveCache() {
-               if ( $this->cacheEnabled && $this->hasCached === false && !empty( $this->cachedChunks ) ) {
-                       wfGetCache( CACHE_ANYTHING )->set( $this->getCacheKeyString(), $this->cachedChunks, $this->cacheExpiry );
-               }
-       }
-
-       /**
-        * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry..
-        *
-        * @since 1.20
-        *
-        * @param integer $cacheExpiry
-        */
-       public function setExpirey( $cacheExpiry ) {
-               $this->cacheExpiry = $cacheExpiry;
-       }
-
-       /**
-        * Returns the cache key to use to cache this page's HTML output.
-        * Is constructed from the special page name and language code.
-        *
-        * @since 1.20
-        *
-        * @return string
-        */
-       protected function getCacheKeyString() {
-               return call_user_func_array( 'wfMemcKey', $this->cacheKey );
-       }
-
-       public function setCacheKey( array $cacheKey ) {
-               $this->cacheKey = $cacheKey;
-       }
-
-       public function purge() {
-               $this->hasCached = false;
-       }
-
-       public function setOnInitializedHandler( $handlerFunction ) {
-               $this->onInitHandler = $handlerFunction;
-       }
-
-}
diff --git a/includes/actions/CachedAction.php b/includes/actions/CachedAction.php
deleted file mode 100644 (file)
index 300a93d..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-<?php
-
-/**
- * Abstract action class with scaffolding for caching HTML and other values
- * in a single blob.
- *
- * Before using any of the cahing functionality, call startCache.
- * After the last call to either getCachedValue or addCachedHTML, call saveCache.
- *
- * To get a cached value or compute it, use getCachedValue like this:
- * $this->getCachedValue( $callback );
- *
- * To add HTML that should be cached, use addCachedHTML like this:
- * $this->addCachedHTML( $callback );
- *
- * The callback function is only called when needed, so do all your expensive
- * computations here. This function should returns the HTML to be cached.
- * It should not add anything to the PageOutput object!
- *
- * @since 1.20
- *
- * @file CachedAction.php
- * @ingroup Action
- *
- * @licence GNU GPL v2 or later
- * @author Jeroen De Dauw < jeroendedauw@gmail.com >
- */
-abstract class CachedAction extends FormlessAction implements ICacheHelper {
-
-       /**
-        * CacheHelper object to which we foreward the non-SpecialPage specific caching work.
-        * Initialized in startCache.
-        *
-        * @since 1.20
-        * @var CacheHelper
-        */
-       protected $cacheHelper;
-
-       /**
-        * If the cache is enabled or not.
-        *
-        * @since 1.20
-        * @var boolean
-        */
-       protected $cacheEnabled = true;
-
-       /**
-        * Sets if the cache should be enabled or not.
-        *
-        * @since 1.20
-        * @param boolean $cacheEnabled
-        */
-       public function setCacheEnabled( $cacheEnabled ) {
-               $this->cacheHelper->setCacheEnabled( $cacheEnabled );
-       }
-
-       /**
-        * Initializes the caching.
-        * Should be called before the first time anything is added via addCachedHTML.
-        *
-        * @since 1.20
-        *
-        * @param integer|null $cacheExpiry Sets the cache expirty, either ttl in seconds or unix timestamp.
-        * @param boolean|null $cacheEnabled Sets if the cache should be enabled or not.
-        */
-       public function startCache( $cacheExpiry = null, $cacheEnabled = null ) {
-               $this->cacheHelper = new CacheHelper();
-
-               $this->cacheHelper->setCacheEnabled( $this->cacheEnabled );
-               $this->cacheHelper->setOnInitializedHandler( array( $this, 'onCacheInitialized' ) );
-
-               $keyArgs = $this->getCacheKey();
-
-               if ( array_key_exists( 'action', $keyArgs ) && $keyArgs['action'] === 'purge' ) {
-                       unset( $keyArgs['action'] );
-               }
-
-               $this->cacheHelper->setCacheKey( $keyArgs );
-
-               if ( $this->getRequest()->getText( 'action' ) === 'purge' ) {
-                       $this->cacheHelper->purge();
-               }
-
-               $this->cacheHelper->startCache( $cacheExpiry, $cacheEnabled );
-       }
-
-       /**
-        * Get a cached value if available or compute it if not and then cache it if possible.
-        * The provided $computeFunction is only called when the computation needs to happen
-        * and should return a result value. $args are arguments that will be passed to the
-        * compute function when called.
-        *
-        * @since 1.20
-        *
-        * @param {function} $computeFunction
-        * @param array|mixed $args
-        * @param string|null $key
-        *
-        * @return mixed
-        */
-       public function getCachedValue( $computeFunction, $args = array(), $key = null ) {
-               return $this->cacheHelper->getCachedValue( $computeFunction, $args, $key );
-       }
-
-       /**
-        * Add some HTML to be cached.
-        * This is done by providing a callback function that should
-        * return the HTML to be added. It will only be called if the
-        * item is not in the cache yet or when the cache has been invalidated.
-        *
-        * @since 1.20
-        *
-        * @param {function} $computeFunction
-        * @param array $args
-        * @param string|null $key
-        */
-       public function addCachedHTML( $computeFunction, $args = array(), $key = null ) {
-               $this->getOutput()->addHTML( $this->cacheHelper->getCachedValue( $computeFunction, $args, $key ) );
-       }
-
-       /**
-        * Saves the HTML to the cache in case it got recomputed.
-        * Should be called after the last time anything is added via addCachedHTML.
-        *
-        * @since 1.20
-        */
-       public function saveCache() {
-               $this->cacheHelper->saveCache();
-       }
-
-       /**
-        * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry..
-        *
-        * @since 1.20
-        *
-        * @param integer $cacheExpiry
-        */
-       public function setExpirey( $cacheExpiry ) {
-               $this->cacheHelper->setExpirey( $cacheExpiry );
-       }
-
-       /**
-        * Returns the variables used to constructed the cache key in an array.
-        *
-        * @since 1.20
-        *
-        * @return array
-        */
-       protected function getCacheKey() {
-               return array(
-                       get_class( $this->page ),
-                       $this->getName(),
-                       $this->getLanguage()->getCode()
-               );
-       }
-
-       /**
-        * Gets called after the cache got initialized.
-        *
-        * @since 1.20
-        *
-        * @param boolean $hasCached
-        */
-       public function onCacheInitialized( $hasCached ) {
-               if ( $hasCached ) {
-                       $this->getOutput()->setSubtitle( $this->cacheHelper->getCachedNotice( $this->getContext() ) );
-               }
-       }
-
-}
\ No newline at end of file
index 4f49f7d..f8208f6 100644 (file)
@@ -344,20 +344,11 @@ class MWMemcached {
                return false;
        }
 
-       /**
-        * @param $key
-        * @param $timeout int
-        * @return bool
-        */
        public function lock( $key, $timeout = 0 ) {
                /* stub */
                return true;
        }
 
-       /**
-        * @param $key
-        * @return bool
-        */
        public function unlock( $key ) {
                /* stub */
                return true;
@@ -480,7 +471,7 @@ class MWMemcached {
                        $this->stats['get_multi'] = 1;
                }
                $sock_keys = array();
-               $socks = array();
+
                foreach ( $keys as $key ) {
                        $sock = $this->get_sock( $key );
                        if ( !is_resource( $sock ) ) {
@@ -494,7 +485,6 @@ class MWMemcached {
                        $sock_keys[$sock][] = $key;
                }
 
-               $gather = array();
                // Send out the requests
                foreach ( $socks as $sock ) {
                        $cmd = 'get';
@@ -589,7 +579,6 @@ class MWMemcached {
                        return array();
                }
 
-               $ret = array();
                while ( true ) {
                        $res = fgets( $sock );
                        $ret[] = $res;
@@ -755,9 +744,6 @@ class MWMemcached {
                $this->_dead_host( $host );
        }
 
-       /**
-        * @param $host
-        */
        function _dead_host( $host ) {
                $parts = explode( ':', $host );
                $ip = $parts[0];
@@ -788,8 +774,8 @@ class MWMemcached {
                }
 
                $hv = is_array( $key ) ? intval( $key[0] ) : $this->_hashfunc( $key );
+
                if ( $this->_buckets === null ) {
-                       $bu = array();
                        foreach ( $this->_servers as $v ) {
                                if ( is_array( $v ) ) {
                                        for( $i = 0; $i < $v[1]; $i++ ) {
@@ -865,8 +851,7 @@ class MWMemcached {
                        $this->stats[$cmd] = 1;
                }
                if ( !$this->_safe_fwrite( $sock, "$cmd $key $amt\r\n" ) ) {
-                       $this->_dead_sock( $sock );
-                       return null;
+                       return $this->_dead_sock( $sock );
                }
 
                $line = fgets( $sock );
@@ -1013,8 +998,7 @@ class MWMemcached {
                        }
                }
                if ( !$this->_safe_fwrite( $sock, "$cmd $key $flags $exp $len\r\n$val\r\n" ) ) {
-                       $this->_dead_sock( $sock );
-                       return false;
+                       return $this->_dead_sock( $sock );
                }
 
                $line = trim( fgets( $sock ) );
@@ -1054,8 +1038,7 @@ class MWMemcached {
                }
 
                if ( !$this->_connect_sock( $sock, $host ) ) {
-                       $this->_dead_host( $host );
-                       return null;
+                       return $this->_dead_host( $host );
                }
 
                // Do not buffer writes
@@ -1066,9 +1049,6 @@ class MWMemcached {
                return $this->_cache_sock[$host];
        }
 
-       /**
-        * @param $str string
-        */
        function _debugprint( $str ) {
                print( $str );
        }
@@ -1100,9 +1080,6 @@ class MWMemcached {
 
        /**
         * Original behaviour
-        * @param $f
-        * @param $buf
-        * @param $len bool
         * @return int
         */
        function _safe_fwrite( $f, $buf, $len = false ) {
@@ -1116,7 +1093,6 @@ class MWMemcached {
 
        /**
         * Flush the read buffer of a stream
-        * @param $f Resource
         */
        function _flush_read_buffer( $f ) {
                if ( !is_resource( $f ) ) {
diff --git a/includes/specials/SpecialCachedPage.php b/includes/specials/SpecialCachedPage.php
deleted file mode 100644 (file)
index 6c48434..0000000
+++ /dev/null
@@ -1,169 +0,0 @@
-<?php
-
-/**
- * Abstract special page class with scaffolding for caching HTML and other values
- * in a single blob.
- *
- * Before using any of the cahing functionality, call startCache.
- * After the last call to either getCachedValue or addCachedHTML, call saveCache.
- *
- * To get a cached value or compute it, use getCachedValue like this:
- * $this->getCachedValue( $callback );
- *
- * To add HTML that should be cached, use addCachedHTML like this:
- * $this->addCachedHTML( $callback );
- *
- * The callback function is only called when needed, so do all your expensive
- * computations here. This function should returns the HTML to be cached.
- * It should not add anything to the PageOutput object!
- *
- * @since 1.20
- *
- * @file SpecialCachedPage.php
- * @ingroup SpecialPage
- *
- * @licence GNU GPL v2 or later
- * @author Jeroen De Dauw < jeroendedauw@gmail.com >
- */
-abstract class SpecialCachedPage extends SpecialPage implements ICacheHelper {
-
-       /**
-        * CacheHelper object to which we foreward the non-SpecialPage specific caching work.
-        * Initialized in startCache.
-        *
-        * @since 1.20
-        * @var CacheHelper
-        */
-       protected $cacheHelper;
-
-       /**
-        * If the cache is enabled or not.
-        *
-        * @since 1.20
-        * @var boolean
-        */
-       protected $cacheEnabled = true;
-
-       /**
-        * Sets if the cache should be enabled or not.
-        *
-        * @since 1.20
-        * @param boolean $cacheEnabled
-        */
-       public function setCacheEnabled( $cacheEnabled ) {
-               $this->cacheHelper->setCacheEnabled( $cacheEnabled );
-       }
-
-       /**
-        * Initializes the caching.
-        * Should be called before the first time anything is added via addCachedHTML.
-        *
-        * @since 1.20
-        *
-        * @param integer|null $cacheExpiry Sets the cache expirty, either ttl in seconds or unix timestamp.
-        * @param boolean|null $cacheEnabled Sets if the cache should be enabled or not.
-        */
-       public function startCache( $cacheExpiry = null, $cacheEnabled = null ) {
-               $this->cacheHelper = new CacheHelper();
-
-               $this->cacheHelper->setCacheEnabled( $this->cacheEnabled );
-               $this->cacheHelper->setOnInitializedHandler( array( $this, 'onCacheInitialized' ) );
-
-               $keyArgs = $this->getCacheKey();
-
-               if ( array_key_exists( 'action', $keyArgs ) && $keyArgs['action'] === 'purge' ) {
-                       unset( $keyArgs['action'] );
-               }
-
-               $this->cacheHelper->setCacheKey( $keyArgs );
-
-               if ( $this->getRequest()->getText( 'action' ) === 'purge' ) {
-                       $this->cacheHelper->purge();
-               }
-
-               $this->cacheHelper->startCache( $cacheExpiry, $cacheEnabled );
-       }
-
-       /**
-        * Get a cached value if available or compute it if not and then cache it if possible.
-        * The provided $computeFunction is only called when the computation needs to happen
-        * and should return a result value. $args are arguments that will be passed to the
-        * compute function when called.
-        *
-        * @since 1.20
-        *
-        * @param {function} $computeFunction
-        * @param array|mixed $args
-        * @param string|null $key
-        *
-        * @return mixed
-        */
-       public function getCachedValue( $computeFunction, $args = array(), $key = null ) {
-               return $this->cacheHelper->getCachedValue( $computeFunction, $args, $key );
-       }
-
-       /**
-        * Add some HTML to be cached.
-        * This is done by providing a callback function that should
-        * return the HTML to be added. It will only be called if the
-        * item is not in the cache yet or when the cache has been invalidated.
-        *
-        * @since 1.20
-        *
-        * @param {function} $computeFunction
-        * @param array $args
-        * @param string|null $key
-        */
-       public function addCachedHTML( $computeFunction, $args = array(), $key = null ) {
-               $this->getOutput()->addHTML( $this->cacheHelper->getCachedValue( $computeFunction, $args, $key ) );
-       }
-
-       /**
-        * Saves the HTML to the cache in case it got recomputed.
-        * Should be called after the last time anything is added via addCachedHTML.
-        *
-        * @since 1.20
-        */
-       public function saveCache() {
-               $this->cacheHelper->saveCache();
-       }
-
-       /**
-        * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry..
-        *
-        * @since 1.20
-        *
-        * @param integer $cacheExpiry
-        */
-       public function setExpirey( $cacheExpiry ) {
-               $this->cacheHelper->setExpirey( $cacheExpiry );
-       }
-
-       /**
-        * Returns the variables used to constructed the cache key in an array.
-        *
-        * @since 1.20
-        *
-        * @return array
-        */
-       protected function getCacheKey() {
-               return array(
-                       $this->mName,
-                       $this->getLanguage()->getCode()
-               );
-       }
-
-       /**
-        * Gets called after the cache got initialized.
-        *
-        * @since 1.20
-        *
-        * @param boolean $hasCached
-        */
-       public function onCacheInitialized( $hasCached ) {
-               if ( $hasCached ) {
-                       $this->getOutput()->setSubtitle( $this->cacheHelper->getCachedNotice( $this->getContext() ) );
-               }
-       }
-
-}
index 1bad3fe..854a9f1 100644 (file)
@@ -1909,52 +1909,6 @@ class Language {
                return $this->sprintfDate( $df, $ts );
        }
 
-       /**
-        * Takes a number of seconds and turns it into a text using values such as hours and minutes.
-        *
-        * @since 1.20
-        *
-        * @param integer $seconds The amount of seconds.
-        * @param array $chosenIntervals The intervals to enable.
-        *
-        * @return string
-        */
-       public function formatDuration( $seconds, array $chosenIntervals = array() ) {
-               $intervals = array(
-                       'millennia' => 1000 * 31557600,
-                       'centuries' => 100 * 31557600,
-                       'decades' => 10 * 31557600,
-                       'years' => 31557600, // 86400 * 365.25
-                       'weeks' => 604800,
-                       'days' => 86400,
-                       'hours' => 3600,
-                       'minutes' => 60,
-                       'seconds' => 1,
-               );
-
-               if ( empty( $chosenIntervals ) ) {
-                       $chosenIntervals = array( 'millennia', 'centuries', 'decades', 'years', 'days', 'hours', 'minutes', 'seconds' );
-               }
-
-               $intervals = array_intersect_key( $intervals, array_flip( $chosenIntervals ) );
-               $sortedNames = array_keys( $intervals );
-               $smallestInterval = array_pop( $sortedNames );
-
-               $segments = array();
-
-               foreach ( $intervals as $name => $length ) {
-                       $value = floor( $seconds / $length );
-
-                       if ( $value > 0 || ( $name == $smallestInterval && empty( $segments ) ) ) {
-                               $seconds -= $value * $length;
-                               $message = new Message( 'duration-' . $name, array( $value ) );
-                               $segments[] = $message->inLanguage( $this )->escaped();
-                       }
-               }
-
-               return $this->listToText( $segments );
-       }
-
        /**
         * Internal helper function for userDate(), userTime() and userTimeAndDate()
         *
@@ -3804,7 +3758,7 @@ class Language {
 
        /**
         * Decode an expiry (block, protection, etc) which has come from the DB
-        *
+        * 
         * @FIXME: why are we returnings DBMS-dependent strings???
         *
         * @param $expiry String: Database expiry String
index 22e8946..a40fb7a 100644 (file)
@@ -41,11 +41,11 @@ class LanguageKaa extends Language {
        }
 
        /**
-        * It fixes issue with lcfirst for transforming 'I' to 'ı'
+        * It fixes issue with  lcfirst for transforming 'I' to 'ı'
         *
         * @param $string string
         *
-        * @return mixed|string
+        * @return string
         */
        function lcfirst ( $string ) {
                if ( substr( $string, 0, 1 ) === 'I' ) {
index 2449e76..39dcb3f 100644 (file)
@@ -2661,11 +2661,6 @@ You can narrow down the view by selecting a log type, the username (case-sensiti
 It may contain one or more characters which cannot be used in titles.',
 'allpages-bad-ns'   => '{{SITENAME}} does not have namespace "$1".',
 
-# SpecialCachedPage
-'cachedspecial-viewing-cached-ttl' => 'You are viewing a cached version of this page, which can be up to $1 old.',
-'cachedspecial-viewing-cached-ts'  => 'You are viewing a cached version of this page, which might not be completely actual.',
-'cachedspecial-refresh-now'        => 'View latest.',
-
 # Special:Categories
 'categories'                    => 'Categories',
 'categories-summary'            => '', # do not translate or duplicate this message to other languages
@@ -4825,15 +4820,4 @@ Otherwise, you can use the easy form below. Your comment will be added to the pa
 'api-error-uploaddisabled'                => 'Uploading is disabled on this wiki.',
 'api-error-verification-error'            => 'This file might be corrupt, or have the wrong extension.',
 
-# Durations
-'duration-seconds'   => '$1 {{PLURAL:$1|second|seconds}}',
-'duration-minutes'   => '$1 {{PLURAL:$1|minute|minutes}}',
-'duration-hours'     => '$1 {{PLURAL:$1|hour|hours}}',
-'duration-days'      => '$1 {{PLURAL:$1|day|days}}',
-'duration-weeks'     => '$1 {{PLURAL:$1|week|weeks}}',
-'duration-years'     => '$1 {{PLURAL:$1|year|years}}',
-'duration-decades'   => '$1 {{PLURAL:$1|decade|decades}}',
-'duration-centuries' => '$1 {{PLURAL:$1|century|centuries}}',
-'duration-millennia' => '$1 {{PLURAL:$1|millennium|millennia}}',
-
 );
index 7f7c267..093305e 100644 (file)
@@ -1749,11 +1749,6 @@ $wgMessageStructure = array(
                'allpagesbadtitle',
                'allpages-bad-ns',
        ),
-       'cachedspecial' => array(
-               'cachedspecial-viewing-cached-ttl',
-               'cachedspecial-viewing-cached-ts',
-               'cachedspecial-refresh-now',
-       ),
        'categories' => array(
                'categories',
                'categories-summary',
@@ -3691,17 +3686,6 @@ $wgMessageStructure = array(
                'api-error-uploaddisabled',
                'api-error-verification-error',
        ),
-       'duration' => array(
-               'duration-seconds',
-               'duration-minutes',
-               'duration-hours',
-               'duration-days',
-               'duration-weeks',
-               'duration-years',
-               'duration-decades',
-               'duration-centuries',
-               'duration-millennia'
-       ),
 );
 
 /** Comments for each block */
@@ -3939,6 +3923,4 @@ Variants for Chinese language",
        'logging-irc'           => 'For IRC, see bug 34508. Do not change',
        'feedback'              => 'Feedback',
        'apierrors'             => 'API errors',
-       'duration'              => 'Durations',
-       'cachedspecial'         => 'SpecialCachedPage',
 );
index ff3d92e..c83e01e 100644 (file)
@@ -23,12 +23,12 @@ class LanguageTest extends MediaWikiTestCase {
                        'convertDoubleWidth() with the full alphabet and digits'
                );
        }
-
+       
        /** @dataProvider provideFormattableTimes */
        function testFormatTimePeriod( $seconds, $format, $expected, $desc ) {
                $this->assertEquals( $expected, $this->lang->formatTimePeriod( $seconds, $format ), $desc );
        }
-
+       
        function provideFormattableTimes() {
                return array(
                        array( 9.45, array(), '9.5s', 'formatTimePeriod() rounding (<10s)' ),
@@ -62,7 +62,7 @@ class LanguageTest extends MediaWikiTestCase {
                        array( 176460.55, array(), '2d 1h 1m 1s', 'formatTimePeriod() rounding, recursion, (>48h)' ),
                        array( 176460.55, array( 'noabbrevs' => true ), '2 days 1 hour 1 minute 1 second', 'formatTimePeriod() rounding, recursion, (>48h)' ),
                );
-
+               
        }
 
        function testTruncate() {
@@ -224,7 +224,7 @@ class LanguageTest extends MediaWikiTestCase {
                        "sprintfDate('$format', '$ts'): $msg"
                );
 
-               date_default_timezone_set( $oldTZ );
+               date_default_timezone_set( $oldTZ );            
        }
 
        function provideSprintfDateSamples() {
@@ -537,48 +537,48 @@ class LanguageTest extends MediaWikiTestCase {
                return array(
                        array(
                                0,
-                               '0 B',
-                               'Zero bytes'
+                               "0 B",
+                               "Zero bytes"
                        ),
                        array(
                                1024,
-                               '1 KB',
-                               '1 kilobyte'
+                               "1 KB",
+                               "1 kilobyte"
                        ),
                        array(
                                1024 * 1024,
-                               '1 MB',
-                               '1,024 megabytes'
+                               "1 MB",
+                               "1,024 megabytes"
                        ),
                        array(
                                1024 * 1024 * 1024,
-                               '1 GB',
-                               '1 gigabytes'
+                               "1 GB",
+                               "1 gigabytes"
                        ),
                        array(
                                pow( 1024, 4 ),
-                               '1 TB',
-                               '1 terabyte'
+                               "1 TB",
+                               "1 terabyte"
                        ),
                        array(
                                pow( 1024, 5 ),
-                               '1 PB',
-                               '1 petabyte'
+                               "1 PB",
+                               "1 petabyte"
                        ),
                        array(
                                pow( 1024, 6 ),
-                               '1 EB',
-                               '1,024 exabyte'
+                               "1 EB",
+                               "1,024 exabyte"
                        ),
                        array(
                                pow( 1024, 7 ),
-                               '1 ZB',
-                               '1 zetabyte'
+                               "1 ZB",
+                               "1 zetabyte"
                        ),
                        array(
                                pow( 1024, 8 ),
-                               '1 YB',
-                               '1 yottabyte'
+                               "1 YB",
+                               "1 yottabyte"
                        ),
                        // How big!? THIS BIG!
                );
@@ -599,193 +599,58 @@ class LanguageTest extends MediaWikiTestCase {
                return array(
                        array(
                                0,
-                               '0bps',
-                               '0 bits per second'
+                               "0bps",
+                               "0 bits per second"
                        ),
                        array(
                                999,
-                               '999bps',
-                               '999 bits per second'
+                               "999bps",
+                               "999 bits per second"
                        ),
                        array(
                                1000,
-                               '1kbps',
-                               '1 kilobit per second'
+                               "1kbps",
+                               "1 kilobit per second"
                        ),
                        array(
                                1000 * 1000,
-                               '1Mbps',
-                               '1 megabit per second'
+                               "1Mbps",
+                               "1 megabit per second"
                        ),
                        array(
                                pow( 10, 9 ),
-                               '1Gbps',
-                               '1 gigabit per second'
+                               "1Gbps",
+                               "1 gigabit per second"
                        ),
                        array(
                                pow( 10, 12 ),
-                               '1Tbps',
-                               '1 terabit per second'
+                               "1Tbps",
+                               "1 terabit per second"
                        ),
                        array(
                                pow( 10, 15 ),
-                               '1Pbps',
-                               '1 petabit per second'
+                               "1Pbps",
+                               "1 petabit per second"
                        ),
                        array(
                                pow( 10, 18 ),
-                               '1Ebps',
-                               '1 exabit per second'
+                               "1Ebps",
+                               "1 exabit per second"
                        ),
                        array(
                                pow( 10, 21 ),
-                               '1Zbps',
-                               '1 zetabit per second'
+                               "1Zbps",
+                               "1 zetabit per second"
                        ),
                        array(
                                pow( 10, 24 ),
-                               '1Ybps',
-                               '1 yottabit per second'
+                               "1Ybps",
+                               "1 yottabit per second"
                        ),
                        array(
                                pow( 10, 27 ),
-                               '1,000Ybps',
-                               '1,000 yottabits per second'
-                       ),
-               );
-       }
-
-       /**
-        * @dataProvider provideFormatDuration
-        */
-       function testFormatDuration( $duration, $expected, $intervals = array() ) {
-               $this->assertEquals(
-                       $expected,
-                       $this->lang->formatDuration( $duration, $intervals ),
-                       "formatDuration('$duration'): $expected"
-               );
-       }
-
-       function provideFormatDuration() {
-               return array(
-                       array(
-                               0,
-                               '0 seconds',
-                       ),
-                       array(
-                               1,
-                               '1 second',
-                       ),
-                       array(
-                               2,
-                               '2 seconds',
-                       ),
-                       array(
-                               60,
-                               '1 minute',
-                       ),
-                       array(
-                               2 * 60,
-                               '2 minutes',
-                       ),
-                       array(
-                               3600,
-                               '1 hour',
-                       ),
-                       array(
-                               2 * 3600,
-                               '2 hours',
-                       ),
-                       array(
-                               24 * 3600,
-                               '1 day',
-                       ),
-                       array(
-                               2 * 86400,
-                               '2 days',
-                       ),
-                       array(
-                               365.25 * 86400, // 365.25 * 86400 = 31557600
-                               '1 year',
-                       ),
-                       array(
-                               2 * 31557600,
-                               '2 years',
-                       ),
-                       array(
-                               10 * 31557600,
-                               '1 decade',
-                       ),
-                       array(
-                               20 * 31557600,
-                               '2 decades',
-                       ),
-                       array(
-                               100 * 31557600,
-                               '1 century',
-                       ),
-                       array(
-                               200 * 31557600,
-                               '2 centuries',
-                       ),
-                       array(
-                               1000 * 31557600,
-                               '1 millennium',
-                       ),
-                       array(
-                               2000 * 31557600,
-                               '2 millennia',
-                       ),
-                       array(
-                               9001,
-                               '2 hours, 30 minutes and 1 second'
-                       ),
-                       array(
-                               3601,
-                               '1 hour and 1 second'
-                       ),
-                       array(
-                               31557600 + 2 * 86400 + 9000,
-                               '1 year, 2 days, 2 hours and 30 minutes'
-                       ),
-                       array(
-                               42 * 1000 * 31557600 + 42,
-                               '42 millennia and 42 seconds'
-                       ),
-                       array(
-                               60,
-                               '60 seconds',
-                               array( 'seconds' ),
-                       ),
-                       array(
-                               61,
-                               '61 seconds',
-                               array( 'seconds' ),
-                       ),
-                       array(
-                               1,
-                               '1 second',
-                               array( 'seconds' ),
-                       ),
-                       array(
-                               31557600 + 2 * 86400 + 9000,
-                               '1 year, 2 days and 150 minutes',
-                               array( 'years', 'days', 'minutes' ),
-                       ),
-                       array(
-                               42,
-                               '0 days',
-                               array( 'years', 'days' ),
-                       ),
-                       array(
-                               31557600 + 2 * 86400 + 9000,
-                               '1 year, 2 days and 150 minutes',
-                               array( 'minutes', 'days', 'years' ),
-                       ),
-                       array(
-                               42,
-                               '0 days',
-                               array( 'days', 'years' ),
+                               "1,000Ybps",
+                               "1,000 yottabits per second"
                        ),
                );
        }