Merge "Fix error display on failing rollback" into Wikidata

This commit is contained in:
daniel 2012-08-29 10:02:26 +00:00 committed by Gerrit Code Review
commit 425ae715aa
2 changed files with 12 additions and 14 deletions

View file

@ -2736,6 +2736,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 {

View 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'];