* Proper redirect deletion
[lhc/web/wiklou.git] / includes / Wiki.php
index 72a6a61..7945c7a 100644 (file)
@@ -57,18 +57,10 @@ class MediaWiki {
        }
 
        function checkMaxLag( $maxLag ) {
-               global $wgLoadBalancer, $wgShowHostnames;
+               global $wgLoadBalancer;
                list( $host, $lag ) = $wgLoadBalancer->getMaxLag();
                if ( $lag > $maxLag ) {
-                       header( 'HTTP/1.1 503 Service Unavailable' );
-                       header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) );
-                       header( 'X-Database-Lag: ' . intval( $lag ) );
-                       header( 'Content-Type: text/plain' );
-                       if( $wgShowHostnames ) {
-                               echo "Waiting for $host: $lag seconds lagged\n";
-                       } else {
-                               echo "Waiting for a database server: $lag seconds lagged\n";
-                       }
+                       wfMaxlagError( $host, $lag, $maxLag );
                        return false;
                } else {
                        return true;
@@ -227,12 +219,17 @@ class MediaWiki {
                }
 
                switch( $title->getNamespace() ) {
-               case NS_IMAGE:
-                       return new ImagePage( $title );
-               case NS_CATEGORY:
-                       return new CategoryPage( $title );
-               default:
-                       return new Article( $title );
+                       case NS_IMAGE:
+                               $file = RepoGroup::singleton()->findFile( $title->getText() );
+                               if( $file && $file->getRedirectedFrom() ) {
+                                       return new Article( $title );
+                               } else {
+                                       return new ImagePage( $title );
+                               }
+                       case NS_CATEGORY:
+                               return new CategoryPage( $title );
+                       default:
+                               return new Article( $title );
                }
        }
 
@@ -252,7 +249,7 @@ class MediaWiki {
                $article = $this->articleFromTitle( $title );
 
                // Namespace might change when using redirects
-               if( $action == 'view' && !$request->getVal( 'oldid' ) &&
+               if( ( $action == 'view' || $action == 'render' ) && !$request->getVal( 'oldid' ) &&
                                                $request->getVal( 'redirect' ) != 'no' ) {
 
                        $dbr = wfGetDB(DB_SLAVE);
@@ -371,6 +368,11 @@ class MediaWiki {
 
                wfProfileIn( 'MediaWiki::performAction' );
 
+               if ( !wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request)) ) {
+                       wfProfileOut( 'MediaWiki::performAction' );
+                       return;
+               }
+
                $action = $this->getVal('Action');
                if( in_array( $action, $this->getVal('DisabledActions',array()) ) ) {
                        /* No such action; this will switch to the default case */