From 41842bc71b2eedc7cf665d34c227801b74637d71 Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 27 Aug 2012 21:40:03 +0200 Subject: [PATCH] Fix error display on failing rollback Rollback will now show the actual errors that caused it to fail, instead of a misleading message about permissions. Also, errores returned by WikiPage::doEditContent are now propagated and shown. Change-Id: I5a3f8cb7a0b881d07d52f63504dd3757192205a9 --- includes/WikiPage.php | 5 +++++ includes/actions/RollbackAction.php | 21 +++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/includes/WikiPage.php b/includes/WikiPage.php index a4afda7ef4..96ff8b7aac 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -2746,6 +2746,11 @@ class WikiPage extends Page implements IDBAccessObject { # Actually store the edit $status = $this->doEditContent( $target->getContent(), $summary, $flags, $target->getId(), $guser ); + + if ( !$status->isOK() ) { + return $status->getErrorsArray(); + } + if ( !empty( $status->value['revision'] ) ) { $revId = $status->value['revision']->getId(); } else { diff --git a/includes/actions/RollbackAction.php b/includes/actions/RollbackAction.php index 5ee6786ed6..abe44fa40f 100644 --- a/includes/actions/RollbackAction.php +++ b/includes/actions/RollbackAction.php @@ -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']; -- 2.20.1