r95521 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95520‎ | r95521 | r95522 >
Date:21:03, 25 August 2011
Author:happy-melon
Status:ok (Comments)
Tags:
Comment:
Undo r85392 ('revert' is a strong word since a lot has changed in the intervening ten thousand revisions, but the effect is the same).
Modified paths:
  • /trunk/extensions/CreateBox/CreateBox.php (modified) (history)
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/AutoLoader.php
@@ -24,7 +24,6 @@
2525 'AuthPluginUser' => 'includes/AuthPlugin.php',
2626 'Autopromote' => 'includes/Autopromote.php',
2727 'BacklinkCache' => 'includes/BacklinkCache.php',
28 - 'BadTitle' => 'includes/Title.php',
2928 'BaseTemplate' => 'includes/SkinTemplate.php',
3029 'Block' => 'includes/Block.php',
3130 'Category' => 'includes/Category.php',
Index: trunk/phase3/includes/Wiki.php
@@ -99,7 +99,7 @@
100100 }
101101
102102 if ( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ) {
103 - $ret = new BadTitle;
 103+ $ret = SpecialPage::getTitleFor( 'Badtitle' );
104104 }
105105
106106 return $ret;
@@ -147,7 +147,9 @@
148148 array( &$title, null, &$output, &$user, $request, $this ) );
149149
150150 // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
151 - if ( $title instanceof BadTitle ) {
 151+ if ( is_null( $title ) || ( ( $title->getDBkey() == '' ) && ( $title->getInterwiki() == '' ) ) ) {
 152+ $this->context->title = SpecialPage::getTitleFor( 'Badtitle' );
 153+ // Die now before we mess up $wgArticle and the skin stops working
152154 throw new ErrorPageError( 'badtitle', 'badtitletext' );
153155 // If the user is not logged in, the Namespace:title of the article must be in
154156 // the Read array in order for the user to see it. (We have to check here to
@@ -171,7 +173,7 @@
172174 // 301 so google et al report the target as the actual url.
173175 $output->redirect( $url, 301 );
174176 } else {
175 - $this->context->setTitle( new BadTitle );
 177+ $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
176178 wfProfileOut( __METHOD__ );
177179 throw new ErrorPageError( 'badtitle', 'badtitletext' );
178180 }
Index: trunk/phase3/includes/Title.php
@@ -4369,38 +4369,4 @@
43704370 wfRunHooks( 'PageContentLanguage', array( $this, &$pageLang, $wgLang ) );
43714371 return wfGetLangObj( $pageLang );
43724372 }
4373 -}
4374 -
4375 -/**
4376 - * A BadTitle is generated in MediaWiki::parseTitle() if the title is invalid; the
4377 - * software uses this to display an error page. Internally it's basically a Title
4378 - * for an empty special page
4379 - */
4380 -class BadTitle extends Title {
4381 - public function __construct(){
4382 - $this->mTextform = '';
4383 - $this->mUrlform = '';
4384 - $this->mDbkeyform = '';
4385 - $this->mNamespace = NS_SPECIAL; // Stops talk page link, etc, being shown
4386 - }
4387 -
4388 - public function exists(){
4389 - return false;
4390 - }
4391 -
4392 - public function getPrefixedText(){
4393 - return '';
4394 - }
4395 -
4396 - public function getText(){
4397 - return '';
4398 - }
4399 -
4400 - public function getPrefixedURL(){
4401 - return '';
4402 - }
4403 -
4404 - public function getPrefixedDBKey(){
4405 - return '';
4406 - }
4407 -}
 4373+}
\ No newline at end of file
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -365,6 +365,7 @@
366366 'Allmessages' => array( 'AllMessages' ),
367367 'Allpages' => array( 'AllPages' ),
368368 'Ancientpages' => array( 'AncientPages' ),
 369+ 'Badtitle' => array( 'Badtitle' ),
369370 'Blankpage' => array( 'BlankPage' ),
370371 'Block' => array( 'Block', 'BlockIP', 'BlockUser' ),
371372 'Blockme' => array( 'BlockMe' ),
Index: trunk/extensions/CreateBox/CreateBox.php
@@ -63,7 +63,7 @@
6464 $title = Title::newFromText( $prefix . $text );
6565 if( is_null( $title ) ) {
6666 global $wgTitle;
67 - $wgTitle = new BadTitle;
 67+ $wgTitle = SpecialPage::getTitleFor( 'Badtitle' );
6868 throw new ErrorPageError( 'badtitle', 'badtitletext' );
6969 } elseif( $title->getArticleID() == 0 ) {
7070 acRedirect( $title, 'edit' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r96096Minor tweak to r95521: remove outdated comment about $wgArticledemon13:32, 2 September 2011
r964981.18: MFT r95171, r95409, r95436, r95458, r95467, r95470, r95475, r95493, r95...catrope21:04, 7 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85392Fix for catchable fatals thrown on invalid titles, follow-up to miscellaneous...happy-melon23:09, 4 April 2011

Comments

#Comment by Nikerabbit (talk | contribs)   09:24, 26 August 2011

Heh, the comment might be a bit outdated now

+// Die now before we mess up $wgArticle and the skin stops working

Status & tagging log