merge latest master into Wikidata branch
[lhc/web/wiklou.git] / includes / actions / RollbackAction.php
index 5c85d53..81bad9d 100644 (file)
@@ -71,46 +71,32 @@ class RollbackAction extends FormlessAction {
                        return;
                }
 
-               # Display permissions errors before read-only message -- there's no
-               # point in misleading the user into thinking the inability to rollback
-               # is only temporary.
-               if ( !empty( $result ) && $result !== array( array( 'readonlytext' ) ) ) {
-                       # array_diff is completely broken for arrays of arrays, sigh.
-                       # Remove any 'readonlytext' error manually.
-                       $out = array();
-                       foreach ( $result as $error ) {
-                               if ( $error != array( 'readonlytext' ) ) {
-                                       $out [] = $error;
-                               }
-                       }
-                       throw new PermissionsError( 'rollback', $out );
-               }
+               #NOTE: Permission errors already handled by Action::checkExecute.
 
                if ( $result == array( array( 'readonlytext' ) ) ) {
                        throw new ReadOnlyError;
                }
 
+               #XXX: Would be nice if ErrorPageError could take multiple errors, and/or a status object.
+               #     Right now, we only show the first error
+               foreach ( $result as $error ) {
+                       throw new ErrorPageError( 'rollbackfailed', $error[0], array_slice( $error, 1 ) );
+               }
+
                $current = $details['current'];
                $target = $details['target'];
                $newId = $details['newid'];
                $this->getOutput()->setPageTitle( $this->msg( 'actioncomplete' ) );
                $this->getOutput()->setRobotPolicy( 'noindex,nofollow' );
 
-               if ( $current->getUserText() === '' ) {
-                       $old = $this->msg( 'rev-deleted-user' )->escaped();
-               } else {
-                       $old = Linker::userLink( $current->getUser(), $current->getUserText() )
-                               . Linker::userToolLinks( $current->getUser(), $current->getUserText() );
-               }
-
-               $new = Linker::userLink( $target->getUser(), $target->getUserText() )
-                       . Linker::userToolLinks( $target->getUser(), $target->getUserText() );
+               $old = Linker::revUserTools( $current );
+               $new = Linker::revUserTools( $target );
                $this->getOutput()->addHTML( $this->msg( 'rollback-success' )->rawParams( $old, $new )->parseAsBlock() );
                $this->getOutput()->returnToMain( false, $this->getTitle() );
 
                if ( !$request->getBool( 'hidediff', false ) && !$this->getUser()->getBoolOption( 'norollbackdiff', false ) ) {
-            $contentHandler = ContentHandler::getForTitle( $this->getTitle() );
-            $de = $contentHandler->createDifferenceEngine( $this->getContext(), $current->getId(), $newId, false, true );
+                       $contentHandler = $current->getContentHandler();
+                       $de = $contentHandler->createDifferenceEngine( $this->getContext(), $current->getId(), $newId, false, true );
                        $de->showDiff( '', '' );
                }
        }