r43438 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43437‎ | r43438 | r43439 >
Date:08:15, 13 November 2008
Author:aaron
Status:old
Tags:
Comment:
Revert r43329, r43330 due to said performance issues
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/Skin.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialDisambiguations.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -574,20 +574,6 @@
575575 return $titleObj !== NULL;
576576 }
577577
578 - function isDisambig() {
579 - global $wgParser;
580 - $this->loadContent();
581 - $output = $wgParser->parse( $this->fetchContent(), $this->mTitle, new ParserOptions() );
582 - $templates = $output->getTemplates();
583 - $disambigs = wfGetDisambiguationTemplates();
584 - if( isset( $templates[NS_TEMPLATE] ) )
585 - foreach( $templates[NS_TEMPLATE] as $dbk => $id )
586 - foreach( $disambigs as $disambig )
587 - if( $disambig->getDBkey() == $dbk )
588 - return true;
589 - return false;
590 - }
591 -
592578 /**
593579 * Returns true if the currently-referenced revision is the current edit
594580 * to this page (and it exists).
Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2967,38 +2967,3 @@
29682968 $name = preg_replace ( "/[^".Title::legalChars()."]|:/", '-', $name );
29692969 return $name;
29702970 }
2971 -
2972 -/**
2973 - * Fetches all disambiguation templates from MediaWiki:Disambiguationspage
2974 - */
2975 -function wfGetDisambiguationTemplates() {
2976 - static $templates = null;
2977 - if( $templates )
2978 - return $templates;
2979 - $msgText = wfMsgForContent('disambiguationspage');
2980 - $templates = array();
2981 -
2982 - # If the text can be treated as a title, use it verbatim.
2983 - # Otherwise, pull the titles from the links table
2984 - $dp = Title::newFromText($msgText);
2985 - if( $dp ) {
2986 - if($dp->getNamespace() != NS_TEMPLATE) {
2987 - # FIXME we assume the disambiguation message is a template but
2988 - # the page can potentially be from another namespace :/
2989 - wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
2990 - }
2991 - $templates [] = $dp;
2992 - } else {
2993 - # Get all the templates linked from the Mediawiki:Disambiguationspage
2994 - # Originally used database, now uses parser
2995 - global $wgParser;
2996 - $output = $wgParser->parse( $msgText,
2997 - Title::makeTitle( NS_MEDIAWIKI, 'Disambiguationspage' ), new ParserOptions() );
2998 - $links = $output->getLinks();
2999 - if( isset( $links[NS_TEMPLATE] ) )
3000 - foreach( $links[NS_TEMPLATE] as $dbk => $id )
3001 - if( $id )
3002 - $templates[] = Title::makeTitle( NS_TEMPLATE, $dbk );
3003 - }
3004 - return $templates;
3005 -}
Index: trunk/phase3/includes/specials/SpecialDisambiguations.php
@@ -24,10 +24,37 @@
2525 function getSQL() {
2626 $dbr = wfGetDB( DB_SLAVE );
2727
 28+ $dMsgText = wfMsgForContent('disambiguationspage');
 29+
2830 $linkBatch = new LinkBatch;
29 - foreach( wfGetDisambiguationTemplates() as $tl )
30 - $linkBatch->addObj( $tl );
3131
 32+ # If the text can be treated as a title, use it verbatim.
 33+ # Otherwise, pull the titles from the links table
 34+ $dp = Title::newFromText($dMsgText);
 35+ if( $dp ) {
 36+ if($dp->getNamespace() != NS_TEMPLATE) {
 37+ # FIXME we assume the disambiguation message is a template but
 38+ # the page can potentially be from another namespace :/
 39+ wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
 40+ }
 41+ $linkBatch->addObj( $dp );
 42+ } else {
 43+ # Get all the templates linked from the Mediawiki:Disambiguationspage
 44+ $disPageObj = Title::makeTitleSafe( NS_MEDIAWIKI, 'disambiguationspage' );
 45+ $res = $dbr->select(
 46+ array('pagelinks', 'page'),
 47+ 'pl_title',
 48+ array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE,
 49+ 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()),
 50+ __METHOD__ );
 51+
 52+ while ( $row = $dbr->fetchObject( $res ) ) {
 53+ $linkBatch->addObj( Title::makeTitle( NS_TEMPLATE, $row->pl_title ));
 54+ }
 55+
 56+ $dbr->freeResult( $res );
 57+ }
 58+
3259 $set = $linkBatch->constructSet( 'lb.tl', $dbr );
3360 if( $set === false ) {
3461 # We must always return a valid sql query, but this way DB will always quicly return an empty result
Index: trunk/phase3/includes/Skin.php
@@ -660,7 +660,6 @@
661661 }
662662
663663 function getPageClasses( $title ) {
664 - global $wgArticle;
665664 $numeric = 'ns-'.$title->getNamespace();
666665 if( $title->getNamespace() == NS_SPECIAL ) {
667666 $type = "ns-special";
@@ -670,11 +669,7 @@
671670 $type = "ns-subject";
672671 }
673672 $name = Sanitizer::escapeClass( 'page-'.$title->getPrefixedText() );
674 - if( $wgArticle && $wgArticle->isDisambig() )
675 - $disambig = ' disambiguationpage';
676 - else
677 - $disambig = '';
678 - return "{$numeric} {$type} {$name}{$disambig}";
 673+ return "$numeric $type $name";
679674 }
680675
681676 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r43443Follow-up to r43438, forgot this fileaaron09:05, 13 November 2008

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r43329* Add class "disambiguationpage" to body tag...vasilievvv18:21, 9 November 2008
r43330Forgot to commit Skin.php partvasilievvv18:23, 9 November 2008

Status & tagging log