Merge "Limit the Title backlink cache to two instances."
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 11 Sep 2012 06:22:44 +0000 (06:22 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 11 Sep 2012 06:22:44 +0000 (06:22 +0000)
1  2 
includes/Title.php

diff --combined includes/Title.php
@@@ -84,7 -84,6 +84,6 @@@ class Title 
        var $mLength = -1;                // /< The page length, 0 for special pages
        var $mRedirect = null;            // /< Is the article at this title a redirect?
        var $mNotificationTimestamp = array(); // /< Associative array of user ID -> timestamp/false
-       var $mBacklinkCache = null;       // /< Cache of links to this title
        var $mHasSubpage;                 // /< Whether a page has any subpages
        // @}
  
                        'rd_title' => $this->getDBkey(),
                        'rd_from = page_id'
                );
 +              if ( $this->isExternal() ) {
 +                      $where['rd_interwiki'] = $this->getInterwiki();
 +              } else {
 +                      $where[] = 'rd_interwiki = ' . $dbr->addQuotes( '' ) . ' OR rd_interwiki IS NULL';
 +              }
                if ( !is_null( $ns ) ) {
                        $where['page_namespace'] = $ns;
                }
         *
         * @return BacklinkCache
         */
-       function getBacklinkCache() {
-               if ( is_null( $this->mBacklinkCache ) ) {
-                       $this->mBacklinkCache = new BacklinkCache( $this );
-               }
-               return $this->mBacklinkCache;
+       public function getBacklinkCache() {
+               return BacklinkCache::get( $this );
        }
  
        /**
        }
  
        /**
 -       * Get the language in which the content of this page is written.
 -       * Defaults to $wgContLang, but in certain cases it can be e.g.
 -       * $wgLang (such as special pages, which are in the user language).
 +       * Get the language in which the content of this page is written in
 +       * wikitext. Defaults to $wgContLang, but in certain cases it can be
 +       * e.g. $wgLang (such as special pages, which are in the user language).
         *
         * @since 1.18
         * @return Language
                wfRunHooks( 'PageContentLanguage', array( $this, &$pageLang, $wgLang ) );
                return wfGetLangObj( $pageLang );
        }
 +
 +      /**
 +       * Get the language in which the content of this page is written when
 +       * viewed by user. Defaults to $wgContLang, but in certain cases it can be
 +       * e.g. $wgLang (such as special pages, which are in the user language).
 +       *
 +       * @since 1.20
 +       * @return Language
 +       */
 +      public function getPageViewLanguage() {
 +              $pageLang = $this->getPageLanguage();
 +              // If this is nothing special (so the content is converted when viewed)
 +              if ( !$this->isSpecialPage()
 +                      && !$this->isCssOrJsPage() && !$this->isCssJsSubpage()
 +                      && $this->getNamespace() !== NS_MEDIAWIKI
 +              ) {
 +                      // If the user chooses a variant, the content is actually
 +                      // in a language whose code is the variant code.
 +                      $variant = $pageLang->getPreferredVariant();
 +                      if ( $pageLang->getCode() !== $variant ) {
 +                              $pageLang = Language::factory( $variant );
 +                      }
 +              }
 +              return $pageLang;
 +      }
  }