Index: trunk/phase3/includes/Title.php |
— | — | @@ -4215,3 +4215,37 @@ |
4216 | 4216 | return $unprefixed; |
4217 | 4217 | } |
4218 | 4218 | } |
| 4219 | + |
| 4220 | +/** |
| 4221 | + * A BadTitle is generated in MediaWiki::parseTitle() if the title is invalid; the |
| 4222 | + * software uses this to display an error page. Internally it's basically a Title |
| 4223 | + * for an empty special page |
| 4224 | + */ |
| 4225 | +class BadTitle extends Title { |
| 4226 | + public function __construct(){ |
| 4227 | + $this->mTextform = ''; |
| 4228 | + $this->mUrlform = ''; |
| 4229 | + $this->mDbkeyform = ''; |
| 4230 | + $this->mNamespace = NS_SPECIAL; // Stops talk page link, etc, being shown |
| 4231 | + } |
| 4232 | + |
| 4233 | + public function exists(){ |
| 4234 | + return false; |
| 4235 | + } |
| 4236 | + |
| 4237 | + public function getPrefixedText(){ |
| 4238 | + return ''; |
| 4239 | + } |
| 4240 | + |
| 4241 | + public function getText(){ |
| 4242 | + return ''; |
| 4243 | + } |
| 4244 | + |
| 4245 | + public function getPrefixedURL(){ |
| 4246 | + return ''; |
| 4247 | + } |
| 4248 | + |
| 4249 | + public function getPrefixedDBKey(){ |
| 4250 | + return ''; |
| 4251 | + } |
| 4252 | +} |
\ No newline at end of file |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -137,8 +137,9 @@ |
138 | 138 | $ret = Title::newFromURL( $title ); |
139 | 139 | // check variant links so that interwiki links don't have to worry |
140 | 140 | // about the possible different language variants |
141 | | - if ( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 ) |
| 141 | + if ( count( $wgContLang->getVariants() ) > 1 && !is_null( $ret ) && $ret->getArticleID() == 0 ){ |
142 | 142 | $wgContLang->findVariantLink( $title, $ret ); |
| 143 | + } |
143 | 144 | } |
144 | 145 | // For non-special titles, check for implicit titles |
145 | 146 | if ( is_null( $ret ) || $ret->getNamespace() != NS_SPECIAL ) { |
— | — | @@ -151,6 +152,10 @@ |
152 | 153 | $ret = $rev ? $rev->getTitle() : $ret; |
153 | 154 | } |
154 | 155 | } |
| 156 | + |
| 157 | + if( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ){ |
| 158 | + $ret = new BadTitle; |
| 159 | + } |
155 | 160 | return $ret; |
156 | 161 | } |
157 | 162 | |
— | — | @@ -178,8 +183,7 @@ |
179 | 184 | wfProfileIn( __METHOD__ ); |
180 | 185 | |
181 | 186 | // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty. |
182 | | - if ( is_null( $this->context->title ) || ( ( $this->context->title->getDBkey() == '' ) && ( $this->context->title->getInterwiki() == '' ) ) ) { |
183 | | - $this->context->title = SpecialPage::getTitleFor( 'Badtitle' ); |
| 187 | + if ( $this->context->title instanceof BadTitle ) { |
184 | 188 | // Die now before we mess up $wgArticle and the skin stops working |
185 | 189 | throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
186 | 190 | |
— | — | @@ -193,12 +197,12 @@ |
194 | 198 | unset( $query['title'] ); |
195 | 199 | $url = $this->context->title->getFullURL( $query ); |
196 | 200 | } |
197 | | - /* Check for a redirect loop */ |
| 201 | + // Check for a redirect loop |
198 | 202 | if ( !preg_match( '/^' . preg_quote( $this->getVal( 'Server' ), '/' ) . '/', $url ) && $this->context->title->isLocal() ) { |
199 | 203 | // 301 so google et al report the target as the actual url. |
200 | 204 | $this->context->output->redirect( $url, 301 ); |
201 | 205 | } else { |
202 | | - $this->context->title = SpecialPage::getTitleFor( 'Badtitle' ); |
| 206 | + $this->context->title = new BadTitle; |
203 | 207 | wfProfileOut( __METHOD__ ); |
204 | 208 | throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
205 | 209 | } |
— | — | @@ -244,14 +248,14 @@ |
245 | 249 | } |
246 | 250 | // Special pages |
247 | 251 | } else if ( NS_SPECIAL == $this->context->title->getNamespace() ) { |
248 | | - /* actions that need to be made when we have a special pages */ |
| 252 | + // actions that need to be made when we have a special pages |
249 | 253 | SpecialPage::executePath( $this->context->title, $this->context ); |
250 | 254 | } else { |
251 | | - /* No match to special cases */ |
| 255 | + // No match to special cases |
252 | 256 | wfProfileOut( __METHOD__ ); |
253 | 257 | return false; |
254 | 258 | } |
255 | | - /* Did match a special case */ |
| 259 | + // Did match a special case |
256 | 260 | wfProfileOut( __METHOD__ ); |
257 | 261 | return true; |
258 | 262 | } |
— | — | @@ -514,10 +518,10 @@ |
515 | 519 | break; |
516 | 520 | case 'submit': |
517 | 521 | if ( session_id() == '' ) { |
518 | | - /* Send a cookie so anons get talk message notifications */ |
| 522 | + // Send a cookie so anons get talk message notifications |
519 | 523 | wfSetupSession(); |
520 | 524 | } |
521 | | - /* Continue... */ |
| 525 | + // Continue... |
522 | 526 | case 'edit': |
523 | 527 | if ( wfRunHooks( 'CustomEditor', array( $article, $this->context->user ) ) ) { |
524 | 528 | $internal = $this->context->request->getVal( 'internaledit' ); |
Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -22,6 +22,7 @@ |
23 | 23 | 'AuthPlugin' => 'includes/AuthPlugin.php', |
24 | 24 | 'AuthPluginUser' => 'includes/AuthPlugin.php', |
25 | 25 | 'Autopromote' => 'includes/Autopromote.php', |
| 26 | + 'BadTitle' => 'includes/Title.php', |
26 | 27 | 'BacklinkCache' => 'includes/BacklinkCache.php', |
27 | 28 | 'Block' => 'includes/Block.php', |
28 | 29 | 'CacheDependency' => 'includes/CacheDependency.php', |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -382,7 +382,6 @@ |
383 | 383 | 'Allmessages' => array( 'AllMessages' ), |
384 | 384 | 'Allpages' => array( 'AllPages' ), |
385 | 385 | 'Ancientpages' => array( 'AncientPages' ), |
386 | | - 'Badtitle' => array( 'Badtitle' ), |
387 | 386 | 'Blankpage' => array( 'BlankPage' ), |
388 | 387 | 'Block' => array( 'Block', 'BlockIP', 'BlockUser' ), |
389 | 388 | 'Blockme' => array( 'BlockMe' ), |
Index: trunk/extensions/CreateBox/CreateBox.php |
— | — | @@ -63,7 +63,7 @@ |
64 | 64 | $title = Title::newFromText( $prefix . $text ); |
65 | 65 | if( is_null( $title ) ) { |
66 | 66 | global $wgTitle; |
67 | | - $wgTitle = SpecialPage::getTitleFor( 'Badtitle' ); |
| 67 | + $wgTitle = new BadTitle; |
68 | 68 | throw new ErrorPageError( 'badtitle', 'badtitletext' ); |
69 | 69 | } elseif( $title->getArticleID() == 0 ) { |
70 | 70 | acRedirect( $title, 'edit' ); |