Revert r43329, r43330 due to said performance issues
authorAaron Schulz <aaron@users.mediawiki.org>
Thu, 13 Nov 2008 08:15:23 +0000 (08:15 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Thu, 13 Nov 2008 08:15:23 +0000 (08:15 +0000)
includes/Article.php
includes/GlobalFunctions.php
includes/Skin.php
includes/specials/SpecialDisambiguations.php

index c629c42..f64e9f4 100644 (file)
@@ -574,20 +574,6 @@ class Article {
                return $titleObj !== NULL;
        }
 
-       function isDisambig() {
-               global $wgParser;
-               $this->loadContent();
-               $output = $wgParser->parse( $this->fetchContent(), $this->mTitle, new ParserOptions() );
-               $templates = $output->getTemplates();
-               $disambigs = wfGetDisambiguationTemplates();
-               if( isset( $templates[NS_TEMPLATE] ) )
-                       foreach( $templates[NS_TEMPLATE] as $dbk => $id )
-                               foreach( $disambigs as $disambig )
-                                       if( $disambig->getDBkey() == $dbk )
-                                               return true;
-               return false;
-       }
-
        /**
         * Returns true if the currently-referenced revision is the current edit
         * to this page (and it exists).
index d8b8fd0..a03017e 100644 (file)
@@ -2967,38 +2967,3 @@ function wfStripIllegalFilenameChars( $name ) {
        $name = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $name );
        return $name;
 }
-
-/**
- * Fetches all disambiguation templates from MediaWiki:Disambiguationspage
- */
-function wfGetDisambiguationTemplates() {
-       static $templates = null;
-       if( $templates )
-               return $templates;
-       $msgText = wfMsgForContent('disambiguationspage');
-       $templates = array();
-
-       # If the text can be treated as a title, use it verbatim.
-       # Otherwise, pull the titles from the links table
-       $dp = Title::newFromText($msgText);
-       if( $dp ) {
-               if($dp->getNamespace() != NS_TEMPLATE) {
-                       # FIXME we assume the disambiguation message is a template but
-                       # the page can potentially be from another namespace :/
-                       wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
-               }
-               $templates [] = $dp;
-       } else {
-                       # Get all the templates linked from the Mediawiki:Disambiguationspage
-                       # Originally used database, now uses parser
-                       global $wgParser;
-                       $output = $wgParser->parse( $msgText,
-                               Title::makeTitle( NS_MEDIAWIKI, 'Disambiguationspage' ), new ParserOptions() );
-                       $links = $output->getLinks();
-                       if( isset( $links[NS_TEMPLATE] ) )
-                               foreach( $links[NS_TEMPLATE] as $dbk => $id )
-                                       if( $id )
-                                               $templates[] = Title::makeTitle( NS_TEMPLATE, $dbk );
-       }
-       return $templates;
-}
index a646c47..1da33ec 100644 (file)
@@ -660,7 +660,6 @@ END;
        }
        
        function getPageClasses( $title ) {
-               global $wgArticle;
                $numeric = 'ns-'.$title->getNamespace();
                if( $title->getNamespace() == NS_SPECIAL ) {
                        $type = "ns-special";
@@ -670,11 +669,7 @@ END;
                        $type = "ns-subject";
                }
                $name = Sanitizer::escapeClass( 'page-'.$title->getPrefixedText() );
-               if( $wgArticle && $wgArticle->isDisambig() )
-                       $disambig = ' disambiguationpage';
-               else
-                       $disambig = '';
-                       return "{$numeric} {$type} {$name}{$disambig}";
+               return "$numeric $type $name";
        }
 
        /**
index dbf27d0..0a728b6 100644 (file)
@@ -24,9 +24,36 @@ class DisambiguationsPage extends PageQueryPage {
        function getSQL() {
                $dbr = wfGetDB( DB_SLAVE );
 
+               $dMsgText = wfMsgForContent('disambiguationspage');
+
                $linkBatch = new LinkBatch;
-               foreach( wfGetDisambiguationTemplates() as $tl )
-                       $linkBatch->addObj( $tl );
+
+               # If the text can be treated as a title, use it verbatim.
+               # Otherwise, pull the titles from the links table
+               $dp = Title::newFromText($dMsgText);
+               if( $dp ) {
+                       if($dp->getNamespace() != NS_TEMPLATE) {
+                               # FIXME we assume the disambiguation message is a template but
+                               # the page can potentially be from another namespace :/
+                               wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
+                       }
+                       $linkBatch->addObj( $dp );
+               } else {
+                               # Get all the templates linked from the Mediawiki:Disambiguationspage
+                               $disPageObj = Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage' );
+                               $res = $dbr->select(
+                                       array('pagelinks', 'page'),
+                                       'pl_title',
+                                       array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE,
+                                               'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
+                                       __METHOD__ );
+
+                               while ( $row = $dbr->fetchObject( $res ) ) {
+                                       $linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title ));
+                               }
+
+                               $dbr->freeResult( $res );
+               }
 
                $set = $linkBatch->constructSet( 'lb.tl', $dbr );
                if( $set === false ) {