Merge "Http::getProxy() method to get proxy configuration"
[lhc/web/wiklou.git] / includes / cache / LinkCache.php
index 5ea926b..8a79bd8 100644 (file)
@@ -49,8 +49,8 @@ class LinkCache {
        protected static $instance;
 
        public function __construct() {
-               $this->mGoodLinks = new HashBagOStuff( array( 'maxKeys' => self::MAX_SIZE ) );
-               $this->mBadLinks = new HashBagOStuff( array( 'maxKeys' => self::MAX_SIZE ) );
+               $this->mGoodLinks = new HashBagOStuff( [ 'maxKeys' => self::MAX_SIZE ] );
+               $this->mBadLinks = new HashBagOStuff( [ 'maxKeys' => self::MAX_SIZE ] );
        }
 
        /**
@@ -150,18 +150,20 @@ class LinkCache {
         * @param int $redir Whether the page is a redirect
         * @param int $revision Latest revision's ID
         * @param string|null $model Latest revision's content model ID
+        * @param string|null $lang Language code of the page, if not the content language
         */
        public function addGoodLinkObj( $id, Title $title, $len = -1, $redir = null,
-               $revision = 0, $model = null
+               $revision = 0, $model = null, $lang = null
        ) {
                $dbkey = $title->getPrefixedDBkey();
-               $this->mGoodLinks->set( $dbkey, array(
+               $this->mGoodLinks->set( $dbkey, [
                        'id' => (int)$id,
                        'length' => (int)$len,
                        'redirect' => (int)$redir,
                        'revision' => (int)$revision,
                        'model' => $model ? (string)$model : null,
-               ) );
+                       'lang' => $lang ? (string)$lang : null,
+               ] );
        }
 
        /**
@@ -173,13 +175,14 @@ class LinkCache {
         */
        public function addGoodLinkObjFromRow( Title $title, $row ) {
                $dbkey = $title->getPrefixedDBkey();
-               $this->mGoodLinks->set( $dbkey, array(
+               $this->mGoodLinks->set( $dbkey, [
                        'id' => intval( $row->page_id ),
                        'length' => intval( $row->page_len ),
                        'redirect' => intval( $row->page_is_redirect ),
                        'revision' => intval( $row->page_latest ),
                        'model' => !empty( $row->page_content_model ) ? strval( $row->page_content_model ) : null,
-               ) );
+                       'lang' => !empty( $row->page_lang ) ? strval( $row->page_lang ) : null,
+               ] );
        }
 
        /**
@@ -193,7 +196,7 @@ class LinkCache {
        }
 
        public function clearBadLink( $title ) {
-               $this->mBadLinks->clear( array( $title ) );
+               $this->mBadLinks->clear( [ $title ] );
        }
 
        /**
@@ -226,7 +229,7 @@ class LinkCache {
         * @return int Page ID or zero
         */
        public function addLinkObj( Title $nt ) {
-               global $wgContentHandlerUseDB;
+               global $wgContentHandlerUseDB, $wgPageLanguageUseDB;
 
                $key = $nt->getPrefixedDBkey();
                if ( $this->isBadLink( $key ) || $nt->isExternal() ) {
@@ -244,13 +247,16 @@ class LinkCache {
                // Some fields heavily used for linking...
                $db = $this->mForUpdate ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
 
-               $fields = array( 'page_id', 'page_len', 'page_is_redirect', 'page_latest' );
+               $fields = [ 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ];
                if ( $wgContentHandlerUseDB ) {
                        $fields[] = 'page_content_model';
                }
+               if ( $wgPageLanguageUseDB ) {
+                       $fields[] = 'page_lang';
+               }
 
                $row = $db->selectRow( 'page', $fields,
-                       array( 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ),
+                       [ 'page_namespace' => $nt->getNamespace(), 'page_title' => $nt->getDBkey() ],
                        __METHOD__
                );