X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmes_infos.php?a=blobdiff_plain;f=includes%2Fcache%2FLinkCache.php;h=c13f95e1ed42972f1877974c966bebb0a24a16de;hb=44eecdda93a4b4a719d3780e1007790f7fc6c58a;hp=9e182c796c21253375606b8f4bd1298fca1444b6;hpb=bc6457b28d70641d366a554d8a82385b53a46fc9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php index 9e182c796c..c13f95e1ed 100644 --- a/includes/cache/LinkCache.php +++ b/includes/cache/LinkCache.php @@ -141,6 +141,7 @@ class LinkCache { 'revision' => (int)$revision, 'model' => $model ? (string)$model : null, 'lang' => $lang ? (string)$lang : null, + 'restrictions' => null ] ); } @@ -158,8 +159,15 @@ class LinkCache { '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, + 'model' => !empty( $row->page_content_model ) + ? strval( $row->page_content_model ) + : null, + 'lang' => !empty( $row->page_lang ) + ? strval( $row->page_lang ) + : null, + 'restrictions' => !empty( $row->page_restrictions ) + ? strval( $row->page_restrictions ) + : null ] ); } @@ -189,21 +197,6 @@ class LinkCache { $this->goodLinks->clear( $dbkey ); } - /** - * Add a title to the link cache, return the page_id or zero if non-existent - * - * @deprecated since 1.27, unused - * @param string $title Prefixed DB key - * @return int Page ID or zero - */ - public function addLink( $title ) { - $nt = Title::newFromDBkey( $title ); - if ( !$nt ) { - return 0; - } - return $this->addLinkObj( $nt ); - } - /** * Fields that LinkCache needs to select * @@ -213,7 +206,13 @@ class LinkCache { public static function getSelectFields() { global $wgContentHandlerUseDB, $wgPageLanguageUseDB; - $fields = [ 'page_id', 'page_len', 'page_is_redirect', 'page_latest' ]; + $fields = [ + 'page_id', + 'page_len', + 'page_is_redirect', + 'page_latest', + 'page_restrictions' + ]; if ( $wgContentHandlerUseDB ) { $fields[] = 'page_content_model'; } @@ -296,7 +295,16 @@ class LinkCache { } private function isCacheable( LinkTarget $title ) { - return ( $title->inNamespace( NS_TEMPLATE ) || $title->inNamespace( NS_FILE ) ); + $ns = $title->getNamespace(); + if ( in_array( $ns, [ NS_TEMPLATE, NS_FILE, NS_CATEGORY ] ) ) { + return true; + } + // Focus on transcluded pages more than the main content + if ( MWNamespace::isContent( $ns ) ) { + return false; + } + // Non-talk extension namespaces (e.g. NS_MODULE) + return ( $ns >= 100 && MWNamespace::isSubject( $ns ) ); } private function fetchPageRow( IDatabase $db, LinkTarget $nt ) {