merge latest master into Wikidata branch
[lhc/web/wiklou.git] / includes / actions / RollbackAction.php
index 714bd07..81bad9d 100644 (file)
@@ -71,25 +71,18 @@ 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'];
@@ -102,7 +95,8 @@ class RollbackAction extends FormlessAction {
                $this->getOutput()->returnToMain( false, $this->getTitle() );
 
                if ( !$request->getBool( 'hidediff', false ) && !$this->getUser()->getBoolOption( 'norollbackdiff', false ) ) {
-                       $de = new DifferenceEngine( $this->getContext(), $current->getId(), $newId, false, true );
+                       $contentHandler = $current->getContentHandler();
+                       $de = $contentHandler->createDifferenceEngine( $this->getContext(), $current->getId(), $newId, false, true );
                        $de->showDiff( '', '' );
                }
        }