Refactor deferrable updates into classes & interfaces, also add helper method for...
[lhc/web/wiklou.git] / includes / Wiki.php
index 1ba71a5..ca8584b 100644 (file)
@@ -99,7 +99,7 @@ class MediaWiki {
                }
 
                if ( $ret === null || ( $ret->getDBkey() == '' && $ret->getInterwiki() == '' ) ) {
-                       $ret = new BadTitle;
+                       $ret = SpecialPage::getTitleFor( 'Badtitle' );
                }
 
                return $ret;
@@ -147,7 +147,8 @@ class MediaWiki {
                        array( &$title, null, &$output, &$user, $request, $this ) );
 
                // Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
-               if ( $title instanceof BadTitle ) {
+               if ( is_null( $title ) || ( ( $title->getDBkey() == '' ) && ( $title->getInterwiki() == '' ) ) ) {
+                       $this->context->title = SpecialPage::getTitleFor( 'Badtitle' );
                        throw new ErrorPageError( 'badtitle', 'badtitletext' );
                // If the user is not logged in, the Namespace:title of the article must be in
                // the Read array in order for the user to see it. (We have to check here to
@@ -171,7 +172,7 @@ class MediaWiki {
                                // 301 so google et al report the target as the actual url.
                                $output->redirect( $url, 301 );
                        } else {
-                               $this->context->setTitle( new BadTitle );
+                               $this->context->setTitle( SpecialPage::getTitleFor( 'Badtitle' ) );
                                wfProfileOut( __METHOD__ );
                                throw new ErrorPageError( 'badtitle', 'badtitletext' );
                        }
@@ -187,7 +188,7 @@ class MediaWiki {
                                        $title = SpecialPage::getTitleFor( $name, $subpage );
                                }
                        }
-                       $targetUrl = $title->getFullURL();
+                       $targetUrl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
                        // Redirect to canonical url, make it a 301 to allow caching
                        if ( $targetUrl == $request->getFullRequestURL() ) {
                                $message = "Redirect loop detected!\n\n" .
@@ -376,7 +377,7 @@ class MediaWiki {
                // Output everything!
                $this->context->getOutput()->output();
                // Do any deferred jobs
-               wfDoUpdates( 'commit' );
+               DeferredUpdates::doUpdates( 'commit' );
                $this->doJobs();
                wfProfileOut( __METHOD__ );
        }