Matthias Mullie has uploaded a new change for review. https://gerrit.wikimedia.org/r/98533
Change subject: Improve error messages ...................................................................... Improve error messages * Half of the error messages didn't actually exist * There were some inconsistencies * ... Only did minor work; errors should probably still be improved drastically :) Change-Id: I6473b27eb7a349becefc76155bfb2cc797215796 --- M Flow.i18n.php M includes/Block/Header.php M includes/Block/Topic.php M templates/edit-header.html.php M templates/edit-post.html.php M templates/edit-title.html.php 6 files changed, 35 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/33/98533/1 diff --git a/Flow.i18n.php b/Flow.i18n.php index 1695dd4..6f709f7 100644 --- a/Flow.i18n.php +++ b/Flow.i18n.php @@ -86,8 +86,8 @@ 'flow-error-edit-restricted' => 'You are not allowed to edit this post.', 'flow-error-external-multi' => 'Errors were encountered.<br />$1', - 'flow-error-missing-content' => 'Post has no content. Content is required to save a new post.', - 'flow-error-missing-title' => 'Topic has no title. Title is required to save a new topic.', + 'flow-error-missing-content' => 'Post has no content. Content is required to save a post.', + 'flow-error-missing-title' => 'Topic has no title. Title is required to save a topic.', 'flow-error-parsoid-failure' => 'Unable to parse content due to a Parsoid failure.', 'flow-error-missing-replyto' => 'No "replyTo" parameter was supplied. This parameter is required for the "reply" action.', 'flow-error-invalid-replyto' => '"replyTo" parameter was invalid. The specified post could not be found.', @@ -99,6 +99,12 @@ 'flow-error-invalid-moderation-state' => 'An invalid value was provided for moderationState', 'flow-error-invalid-moderation-reason' => 'Please provide a reason for the moderation', 'flow-error-not-allowed' => 'Insufficient permissions to execute this action', + 'flow-error-no-existing-workflow' => 'This workflow does not yet exist.', + 'flow-error-not-a-post' => 'Topic title can not be saved as a post.', + 'flow-error-missing-header-content' => 'Header has no content. Content is required to save a header.', + 'flow-error-missing-prev-revision-identifier' => 'Previous revision identifier is missing.', + 'flow-error-prev-revision-mismatch' => 'Previous revision identifier does not match latest revision.', + 'flow-error-prev-revision-does-not-exist' => 'Could not find any previous revision matching the submitted identifier.', 'flow-edit-header-submit' => 'Save header', @@ -438,7 +444,13 @@ Valid values for moderationState are: (none), hidden, deleted, suppressed', 'flow-error-invalid-moderation-reason' => 'Used as error message when no reason is given for the moderation of a post.', - 'flow-error-not-allowed' => 'Insufficient permissions to execute this action', + 'flow-error-not-allowed' => 'Error message when the user has insufficient permissions to execute this action', + 'flow-error-no-existing-workflow' => 'Error message when an edit to a non-existing topic is performed.', + 'flow-error-not-a-post' => "Error message when a topic title is attempted to be saved as post (most likely a code issue - shouldn't happen).", + 'flow-error-missing-header-content' => 'Error message when the header is submitted without content.', + 'flow-error-missing-prev-revision-identifier' => 'Error message when the identifier for the previous header revision is missing.', + 'flow-error-prev-revision-mismatch' => 'Error message when the provided previous revision identifier does not match the last stored revision.', + 'flow-error-prev-revision-does-not-exist' => 'Error message when the provided previous revision identifier could not be found.', 'flow-edit-header-submit' => 'Used as label for the Submit button.', 'flow-edit-title-submit' => 'Used as label for the Submit button.', 'flow-rev-message-edit-post' => 'Used as a revision comment when a post has been edited. diff --git a/includes/Block/Header.php b/includes/Block/Header.php index ee5b88c..798bdc2 100644 --- a/includes/Block/Header.php +++ b/includes/Block/Header.php @@ -39,19 +39,19 @@ protected function validate() { if ( empty( $this->submitted['content'] ) ) { - $this->errors['content'] = wfMessage( 'flow-missing-header-content' ); + $this->errors['content'] = wfMessage( 'flow-error-missing-header-content' ); } if ( $this->header ) { if ( empty( $this->submitted['prev_revision'] ) ) { - $this->errors['prev_revision'] = wfMessage( 'flow-missing-prev-revision-identifier' ); + $this->errors['prev_revision'] = wfMessage( 'flow-error-missing-prev-revision-identifier' ); } elseif ( $this->header->getRevisionId()->getHex() !== $this->submitted['prev_revision'] ) { // This is a reasonably effective way to ensure prev revision matches, but for guarantees against race // conditions there also exists a unique index on rev_prev_revision in mysql, meaning if someone else inserts against the // parent we and the submitter think is the latest, our insert will fail. // TODO: Catch whatever exception happens there, make sure the most recent revision is the one in the cache before // handing user back to specific dialog indicating race condition - $this->errors['prev_revision'] = wfMessage( 'flow-prev-revision-mismatch' )->params( $this->submitted['prev_revision'], $this->header->getRevisionId()->getHex() ); + $this->errors['prev_revision'] = wfMessage( 'flow-error-prev-revision-mismatch' )->params( $this->submitted['prev_revision'], $this->header->getRevisionId()->getHex() ); } // this isnt really part of validate, but we want the error-rendering template to see the users edited header $this->header = $this->header->newNextRevision( $this->user, $this->submitted['content'], 'edit-header' ); @@ -62,7 +62,7 @@ } else { // User submitted a previous revision, but we couldn't find one. This is likely // an internal error and not a user error, consider better handling - $this->errors['prev_revision'] = wfMessage( 'flow-prev-revision-does-not-exist' ); + $this->errors['prev_revision'] = wfMessage( 'flow-error-prev-revision-does-not-exist' ); } } } diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php index 6a7a9c0..0d5192b 100644 --- a/includes/Block/Topic.php +++ b/includes/Block/Topic.php @@ -110,9 +110,9 @@ protected function validateEditTitle() { if ( $this->workflow->isNew() ) { - $this->errors['content'] = wfMessage( 'flow-no-existing-workflow' ); + $this->errors['content'] = wfMessage( 'flow-error-no-existing-workflow' ); } elseif ( empty( $this->submitted['content'] ) ) { - $this->errors['content'] = wfMessage( 'flow-missing-title-content' ); + $this->errors['content'] = wfMessage( 'flow-error-missing-title' ); } else { $topicTitle = $this->loadTopicTitle(); if ( !$topicTitle ) { @@ -174,7 +174,7 @@ protected function validateModeratePost( $moderationState = null ) { if ( empty( $this->submitted['postId'] ) ) { - $this->errors['moderate'] = wfMessage( 'flow-error-missing-postId' ); + $this->errors['post'] = wfMessage( 'flow-error-missing-postId' ); return; } @@ -247,11 +247,11 @@ protected function validateEditPost() { if ( empty( $this->submitted['postId'] ) ) { - $this->errors['edit-post'] = wfMessage( 'flow-no-post-provided' ); + $this->errors['post'] = wfMessage( 'flow-error-missing-postId' ); return; } if ( empty( $this->submitted['content'] ) ) { - $this->errors['content'] = wfMessage( 'flow-missing-post-content' ); + $this->errors['content'] = wfMessage( 'flow-error-missing-content' ); return; } $post = $this->loadRequestedPost( $this->submitted['postId'] ); diff --git a/templates/edit-header.html.php b/templates/edit-header.html.php index 6f6f2fa..50d9275 100644 --- a/templates/edit-header.html.php +++ b/templates/edit-header.html.php @@ -9,19 +9,21 @@ 'action' => $this->generateUrl( $workflow, 'edit-header' ), 'class' => 'flow-header-form', ) ); -echo Html::element( 'input', array( 'type' => 'hidden', 'name' => 'wpEditToken', 'value' => $editToken) ); -if ( $block->hasErrors( 'prev_revision' ) ) { - echo '<p>' . $block->getError( 'prev_revision' )->escaped() . '</p>'; +if ( $block->hasErrors() ) { + echo '<ul>'; + foreach ( $block->getErrors() as $error ) { + echo '<li>', $error->escaped() . '</li>'; + } + echo '</ul>'; } + +echo Html::element( 'input', array( 'type' => 'hidden', 'name' => 'wpEditToken', 'value' => $editToken) ); if ( $header ) { echo Html::element( 'input', array( 'type' => 'hidden', 'name' => $block->getName()."[prev_revision]", 'value' => $header->getRevisionId()->getHex(), ) ); -} -if ( $block->hasErrors( 'content' ) ) { - echo '<p>' . $block->getError( 'content' )->escaped() . '</p>'; } echo Html::textarea( diff --git a/templates/edit-post.html.php b/templates/edit-post.html.php index 479141a..7c144f8 100644 --- a/templates/edit-post.html.php +++ b/templates/edit-post.html.php @@ -7,7 +7,7 @@ if ( $block->hasErrors() ) { echo '<ul>'; foreach ( $block->getErrors() as $error ) { - echo '<li>', $error->escaped() . '</li>'; // the pain ... + echo '<li>', $error->escaped() . '</li>'; } echo '</ul>'; } diff --git a/templates/edit-title.html.php b/templates/edit-title.html.php index 75171f9..6b294e1 100644 --- a/templates/edit-title.html.php +++ b/templates/edit-title.html.php @@ -1,9 +1,9 @@ <?php if ( $block->hasErrors() ) { - echo wfMessage( 'flow-action-errors' )->escaped(), '<ul>'; + echo '<ul>'; foreach ( $block->getErrors() as $error ) { - echo $error->escaped(); + echo '<li>', $error->escaped() . '</li>'; } echo '</ul>'; } -- To view, visit https://gerrit.wikimedia.org/r/98533 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6473b27eb7a349becefc76155bfb2cc797215796 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits