Merge "mw.Upload.BookletLayout: Use $.Deferred(), not $.Deferred"
[lhc/web/wiklou.git] / includes / Title.php
index 1fdeca8..5d8b072 100644 (file)
@@ -31,7 +31,7 @@
  *       and does not rely on global state or the database.
  */
 class Title {
-       /** @var MapCacheLRU */
+       /** @var HashBagOStuff */
        static private $titleCache = null;
 
        /**
@@ -299,21 +299,20 @@ class Title {
                        throw new MWException( '$text must be a string, given an object' );
                }
 
-               $cache = self::getTitleCache();
+               $titleCache = self::getTitleCache();
 
-               /**
-                * Wiki pages often contain multiple links to the same page.
-                * Title normalization and parsing can become expensive on
-                * pages with many links, so we can save a little time by
-                * caching them.
-                *
-                * In theory these are value objects and won't get changed...
-                */
-               if ( $defaultNamespace == NS_MAIN && $cache->has( $text ) ) {
-                       return $cache->get( $text );
+               // Wiki pages often contain multiple links to the same page.
+               // Title normalization and parsing can become expensive on pages with many
+               // links, so we can save a little time by caching them.
+               // In theory these are value objects and won't get changed...
+               if ( $defaultNamespace == NS_MAIN ) {
+                       $t = $titleCache->get( $text );
+                       if ( $t ) {
+                               return $t;
+                       }
                }
 
-               # Convert things like é ā or 〗 into normalized (bug 14952) text
+               // Convert things like é ā or 〗 into normalized (bug 14952) text
                $filteredText = Sanitizer::decodeCharReferencesAndNormalize( $text );
 
                $t = new Title();
@@ -322,7 +321,7 @@ class Title {
 
                $t->secureAndSplit();
                if ( $defaultNamespace == NS_MAIN ) {
-                       $cache->set( $text, $t );
+                       $titleCache->set( $text, $t );
                }
                return $t;
        }
@@ -363,11 +362,11 @@ class Title {
        }
 
        /**
-        * @return MapCacheLRU
+        * @return HashBagOStuff
         */
        private static function getTitleCache() {
                if ( self::$titleCache == null ) {
-                       self::$titleCache = new MapCacheLRU( self::CACHE_MAX );
+                       self::$titleCache = new HashBagOStuff( array( 'maxKeys' => self::CACHE_MAX ) );
                }
                return self::$titleCache;
        }
@@ -1825,7 +1824,7 @@ class Title {
 
        /**
         * Get the URL form for an internal link.
-        * - Used in various Squid-related code, in case we have a different
+        * - Used in various CDN-related code, in case we have a different
         * internal hostname for the server from the exposed one.
         *
         * This uses $wgInternalServer to qualify the path, or $wgServer
@@ -3558,12 +3557,12 @@ class Title {
        }
 
        /**
-        * Get a list of URLs to purge from the Squid cache when this
+        * Get a list of URLs to purge from the CDN cache when this
         * page changes
         *
         * @return string[] Array of String the URLs
         */
-       public function getSquidURLs() {
+       public function getCdnUrls() {
                $urls = array(
                        $this->getInternalURL(),
                        $this->getInternalURL( 'action=history' )
@@ -3589,15 +3588,20 @@ class Title {
        }
 
        /**
-        * Purge all applicable Squid URLs
+        * @deprecated since 1.27 use getCdnUrls()
+        */
+       public function getSquidURLs() {
+               return $this->getCdnUrls();
+       }
+
+       /**
+        * Purge all applicable CDN URLs
         */
        public function purgeSquid() {
-               global $wgUseSquid;
-               if ( $wgUseSquid ) {
-                       $urls = $this->getSquidURLs();
-                       $u = new SquidUpdate( $urls );
-                       $u->doUpdate();
-               }
+               DeferredUpdates::addUpdate(
+                       new CdnCacheUpdate( $this->getCdnUrls() ),
+                       DeferredUpdates::PRESEND
+               );
        }
 
        /**
@@ -4418,7 +4422,7 @@ class Title {
        }
 
        /**
-        * Update page_touched timestamps and send squid purge messages for
+        * Update page_touched timestamps and send CDN purge messages for
         * pages linking to this title. May be sent to the job queue depending
         * on the number of links. Typically called on create and delete.
         */