Make LinkCache::isCacheable include namespaces like NS_CATEGORY/NS_MODULE
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 14 Mar 2019 06:44:38 +0000 (23:44 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 16 Mar 2019 04:48:15 +0000 (04:48 +0000)
Category and module pages are some of the most frequently referenced

Change-Id: I6d29e883883cbea596b287494e75663d09130749

includes/cache/LinkCache.php

index b3dc004..348369e 100644 (file)
@@ -281,7 +281,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 ) {