EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/164664

Change subject: Hygiene: Use this->context->msg instead of wfMessage
......................................................................

Hygiene: Use this->context->msg instead of wfMessage

Change-Id: If1b25a1f244288ff34e4661af74c6d0b2a13761c
---
M includes/Block/Header.php
M includes/Block/Topic.php
M includes/Block/TopicList.php
M includes/Block/TopicSummary.php
4 files changed, 47 insertions(+), 47 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/64/164664/1

diff --git a/includes/Block/Header.php b/includes/Block/Header.php
index 411ed6f..c797677 100644
--- a/includes/Block/Header.php
+++ b/includes/Block/Header.php
@@ -83,11 +83,11 @@
                // @todo this is superseeded by SubmissionHandler::onSubmit 
checking
                //      Title::userCan() ?
                if ( !$this->context->getUser()->isAllowed( 'edit' ) ) {
-                       $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                       $this->addError( 'permissions', $this->context->msg( 
'flow-error-not-allowed' ) );
                        return;
                }
                if ( !isset( $this->submitted['content'] ) ) {
-                       $this->addError( 'content', wfMessage( 
'flow-error-missing-header-content' ) );
+                       $this->addError( 'content', $this->context->msg( 
'flow-error-missing-header-content' ) );
                }
 
                if ( $this->header ) {
@@ -100,12 +100,12 @@
 
        protected function validateNextRevision() {
                if ( !$this->permissions->isAllowed( $this->header, 
'edit-header' ) ) {
-                       $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                       $this->addError( 'permissions', $this->context->msg( 
'flow-error-not-allowed' ) );
                        return;
                }
 
                if ( empty( $this->submitted['prev_revision'] ) ) {
-                       $this->addError( 'prev_revision', wfMessage( 
'flow-error-missing-prev-revision-identifier' ) );
+                       $this->addError( 'prev_revision', $this->context->msg( 
'flow-error-missing-prev-revision-identifier' ) );
                } elseif ( $this->header->getRevisionId()->getAlphadecimal() 
!== $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
@@ -114,7 +114,7 @@
                        // handing user back to specific dialog indicating race 
condition
                        $this->addError(
                                'prev_revision',
-                               wfMessage( 'flow-error-prev-revision-mismatch' 
)->params(
+                               $this->context->msg( 
'flow-error-prev-revision-mismatch' )->params(
                                        $this->submitted['prev_revision'],
                                        
$this->header->getRevisionId()->getAlphadecimal(),
                                        $this->context->getUser()->getName()
@@ -138,14 +138,14 @@
 
        protected function validateFirstRevision() {
                if ( !$this->permissions->isAllowed( null, 'create-header' ) ) {
-                       $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                       $this->addError( 'permissions', $this->context->msg( 
'flow-error-not-allowed' ) );
                        return;
                }
                if ( isset( $this->submitted['prev_revision'] ) && 
$this->submitted['prev_revision'] ) {
                        // 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
                        // is this even worth checking?
-                       $this->addError( 'prev_revision', wfMessage( 
'flow-error-prev-revision-does-not-exist' ) );
+                       $this->addError( 'prev_revision', $this->context->msg( 
'flow-error-prev-revision-does-not-exist' ) );
                        return;
                }
 
diff --git a/includes/Block/Topic.php b/includes/Block/Topic.php
index 37e01c6..536c06a 100644
--- a/includes/Block/Topic.php
+++ b/includes/Block/Topic.php
@@ -122,7 +122,7 @@
                                || !in_array( 
$this->submitted['moderationState'], array( 'unlock', /* BC for unlock: */ 
'reopen' ) )
                        )
                ) {
-                       $this->addError( 'moderate', wfMessage( 
'flow-error-topic-is-locked' ) );
+                       $this->addError( 'moderate', $this->context->msg( 
'flow-error-topic-is-locked' ) );
                }
 
                switch( $this->action ) {
@@ -159,25 +159,25 @@
 
        protected function validateEditTitle() {
                if ( $this->workflow->isNew() ) {
-                       $this->addError( 'content', wfMessage( 
'flow-error-no-existing-workflow' ) );
+                       $this->addError( 'content', $this->context->msg( 
'flow-error-no-existing-workflow' ) );
                        return;
                }
                if ( !isset( $this->submitted['content'] ) || !is_string( 
$this->submitted['content'] ) ) {
-                       $this->addError( 'content', wfMessage( 
'flow-error-missing-title' ) );
+                       $this->addError( 'content', $this->context->msg( 
'flow-error-missing-title' ) );
                        return;
                }
                $this->submitted['content'] = trim( $this->submitted['content'] 
);
                $len = mb_strlen( $this->submitted['content'] );
                if ( $len === 0 ) {
-                       $this->addError( 'content', wfMessage( 
'flow-error-missing-title' ) );
+                       $this->addError( 'content', $this->context->msg( 
'flow-error-missing-title' ) );
                        return;
                }
                if ( $len > PostRevision::MAX_TOPIC_LENGTH ) {
-                       $this->addError( 'content', wfMessage( 
'flow-error-title-too-long', PostRevision::MAX_TOPIC_LENGTH ) );
+                       $this->addError( 'content', $this->context->msg( 
'flow-error-title-too-long', PostRevision::MAX_TOPIC_LENGTH ) );
                        return;
                }
                if ( empty( $this->submitted['prev_revision'] ) ) {
-                       $this->addError( 'prev_revision', wfMessage( 
'flow-error-missing-prev-revision-identifier' ) );
+                       $this->addError( 'prev_revision', $this->context->msg( 
'flow-error-missing-prev-revision-identifier' ) );
                        return;
                }
                $topicTitle = $this->loadTopicTitle();
@@ -185,7 +185,7 @@
                        return;
                }
                if ( !$this->permissions->isAllowed( $topicTitle, 'edit-title' 
) ) {
-                       $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                       $this->addError( 'permissions', $this->context->msg( 
'flow-error-not-allowed' ) );
                        return;
                }
                if ( $topicTitle->getRevisionId()->getAlphadecimal() !== 
$this->submitted['prev_revision'] ) {
@@ -196,7 +196,7 @@
                        // handing user back to specific dialog indicating race 
condition
                        $this->addError(
                                'prev_revision',
-                               wfMessage( 'flow-error-prev-revision-mismatch' 
)->params(
+                               $this->context->msg( 
'flow-error-prev-revision-mismatch' )->params(
                                        $this->submitted['prev_revision'],
                                        
$topicTitle->getRevisionId()->getAlphadecimal(),
                                        $this->context->getUser()->getName()
@@ -218,11 +218,11 @@
 
        protected function validateReply() {
                if ( empty( $this->submitted['content'] ) ) {
-                       $this->addError( 'content', wfMessage( 
'flow-error-missing-content' ) );
+                       $this->addError( 'content', $this->context->msg( 
'flow-error-missing-content' ) );
                        return;
                }
                if ( !isset( $this->submitted['replyTo'] ) ) {
-                       $this->addError( 'replyTo', wfMessage( 
'flow-error-missing-replyto' ) );
+                       $this->addError( 'replyTo', $this->context->msg( 
'flow-error-missing-replyto' ) );
                        return;
                }
 
@@ -231,7 +231,7 @@
                        return; // loadRequestedPost adds its own errors
                }
                if ( !$this->permissions->isAllowed( $post, 'reply' ) ) {
-                       $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                       $this->addError( 'permissions', $this->context->msg( 
'flow-error-not-allowed' ) );
                        return;
                }
                $this->newRevision = $post->reply(
@@ -257,7 +257,7 @@
 
        protected function validateModeratePost() {
                if ( empty( $this->submitted['postId'] ) ) {
-                       $this->addError( 'post', wfMessage( 
'flow-error-missing-postId' ) );
+                       $this->addError( 'post', $this->context->msg( 
'flow-error-missing-postId' ) );
                        return;
                }
 
@@ -267,7 +267,7 @@
                        return;
                }
                if ( $post->isTopicTitle() ) {
-                       $this->addError( 'moderate', wfMessage( 
'flow-error-not-a-post' ) );
+                       $this->addError( 'moderate', $this->context->msg( 
'flow-error-not-a-post' ) );
                        return;
                }
                $this->doModerate( $post );
@@ -278,7 +278,7 @@
                        $this->submitted['moderationState'] === 
AbstractRevision::MODERATED_LOCKED
                        && $post->isModerated()
                ) {
-                       $this->addError( 'moderate', wfMessage( 
'flow-error-lock-moderated-post' ) );
+                       $this->addError( 'moderate', $this->context->msg( 
'flow-error-lock-moderated-post' ) );
                        return;
                }
 
@@ -291,7 +291,7 @@
                // are checked below with $post->isValidModerationState(), but 
this is checked first otherwise
                // a blank string would restore a post(due to 
AbstractRevision::MODERATED_NONE === '').
                if ( ! $moderationState ) {
-                       $this->addError( 'moderate', wfMessage( 
'flow-error-invalid-moderation-state' ) );
+                       $this->addError( 'moderate', $this->context->msg( 
'flow-error-invalid-moderation-state' ) );
                        return;
                }
 
@@ -323,16 +323,16 @@
                }
 
                if ( ! $post->isValidModerationState( $newState ) ) {
-                       $this->addError( 'moderate', wfMessage( 
'flow-error-invalid-moderation-state' ) );
+                       $this->addError( 'moderate', $this->context->msg( 
'flow-error-invalid-moderation-state' ) );
                        return;
                }
                if ( !$this->permissions->isAllowed( $post, $action ) ) {
-                       $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                       $this->addError( 'permissions', $this->context->msg( 
'flow-error-not-allowed' ) );
                        return;
                }
 
                if ( empty( $this->submitted['reason'] ) ) {
-                       $this->addError( 'moderate', wfMessage( 
'flow-error-invalid-moderation-reason' ) );
+                       $this->addError( 'moderate', $this->context->msg( 
'flow-error-invalid-moderation-reason' ) );
                        return;
                }
 
@@ -340,22 +340,22 @@
 
                $this->newRevision = $post->moderate( 
$this->context->getUser(), $newState, $action, $reason );
                if ( !$this->newRevision ) {
-                       $this->addError( 'moderate', wfMessage( 
'flow-error-not-allowed' ) );
+                       $this->addError( 'moderate', $this->context->msg( 
'flow-error-not-allowed' ) );
                        return;
                }
        }
 
        protected function validateEditPost() {
                if ( empty( $this->submitted['postId'] ) ) {
-                       $this->addError( 'post', wfMessage( 
'flow-error-missing-postId' ) );
+                       $this->addError( 'post', $this->context->msg( 
'flow-error-missing-postId' ) );
                        return;
                }
                if ( empty( $this->submitted['content'] ) ) {
-                       $this->addError( 'content', wfMessage( 
'flow-error-missing-content' ) );
+                       $this->addError( 'content', $this->context->msg( 
'flow-error-missing-content' ) );
                        return;
                }
                if ( empty( $this->submitted['prev_revision'] ) ) {
-                       $this->addError( 'prev_revision', wfMessage( 
'flow-error-missing-prev-revision-identifier' ) );
+                       $this->addError( 'prev_revision', $this->context->msg( 
'flow-error-missing-prev-revision-identifier' ) );
                        return;
                }
                $post = $this->loadRequestedPost( $this->submitted['postId'] );
@@ -363,7 +363,7 @@
                        return;
                }
                if ( !$this->permissions->isAllowed( $post, 'edit-post' ) ) {
-                       $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                       $this->addError( 'permissions', $this->context->msg( 
'flow-error-not-allowed' ) );
                        return;
                }
                if ( $post->getRevisionId()->getAlphadecimal() !== 
$this->submitted['prev_revision'] ) {
@@ -378,7 +378,7 @@
                        // user back to specific dialog indicating race 
condition
                        $this->addError(
                                'prev_revision',
-                               wfMessage( 'flow-error-prev-revision-mismatch' 
)->params(
+                               $this->context->msg( 
'flow-error-prev-revision-mismatch' )->params(
                                        $this->submitted['prev_revision'],
                                        
$post->getRevisionId()->getAlphadecimal(),
                                        $this->context->getUser()->getName()
@@ -699,7 +699,7 @@
                        return $this->topicTitle = $this->root = $rootPost;
                }
 
-               $this->addError( 'moderation', wfMessage( 
'flow-error-not-allowed' ) );
+               $this->addError( 'moderation', $this->context->msg( 
'flow-error-not-allowed' ) );
 
                return null;
        }
@@ -733,7 +733,7 @@
                }
 
                if ( !$this->permissions->isAllowed( $this->topicTitle, $action 
) ) {
-                       $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                       $this->addError( 'permissions', $this->context->msg( 
'flow-error-not-allowed' ) );
                        return null;
                }
 
@@ -764,14 +764,14 @@
                        $post = $root->getRecursiveResult( 
$root->registerDescendant( $postId ) );
                        if ( !$post ) {
                                // The requested postId is not a member of the 
current workflow
-                               $this->addError( 'post', wfMessage( 
'flow-error-invalid-postId', $postId->getAlphadecimal() ) );
+                               $this->addError( 'post', $this->context->msg( 
'flow-error-invalid-postId', $postId->getAlphadecimal() ) );
                                return null;
                        }
                } else {
                        // Load the post and its root
                        $found = $this->rootLoader->getWithRoot( $postId );
                        if ( !$found['post'] || !$found['root'] || 
!$found['root']->getPostId()->equals( $this->workflow->getId() ) ) {
-                               $this->addError( 'post', wfMessage( 
'flow-error-invalid-postId', $postId->getAlphadecimal() ) );
+                               $this->addError( 'post', $this->context->msg( 
'flow-error-invalid-postId', $postId->getAlphadecimal() ) );
                                return null;
                        }
                        $this->topicTitle = $topicTitle = $found['root'];
@@ -788,7 +788,7 @@
                        return $post;
                }
 
-               $this->addError( 'moderation', wfMessage( 
'flow-error-not-allowed' ) );
+               $this->addError( 'moderation', $this->context->msg( 
'flow-error-not-allowed' ) );
                return null;
        }
 
diff --git a/includes/Block/TopicList.php b/includes/Block/TopicList.php
index 2a0c483..bb6b61d 100644
--- a/includes/Block/TopicList.php
+++ b/includes/Block/TopicList.php
@@ -59,25 +59,25 @@
        protected function validate() {
                // for now, new topic is considered a new post; perhaps some 
day topic creation should get it's own permissions?
                if ( !$this->permissions->isAllowed( null, 'new-post' ) ) {
-                       $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                       $this->addError( 'permissions', $this->context->msg( 
'flow-error-not-allowed' ) );
                        return;
                }
                if ( !isset( $this->submitted['topic'] ) || !is_string( 
$this->submitted['topic'] ) ) {
-                       $this->addError( 'topic', wfMessage( 
'flow-error-missing-title' ) );
+                       $this->addError( 'topic', $this->context->msg( 
'flow-error-missing-title' ) );
                        return;
                }
                $this->submitted['topic'] = trim( $this->submitted['topic'] );
                if ( strlen( $this->submitted['topic'] ) === 0 ) {
-                       $this->addError( 'topic', wfMessage( 
'flow-error-missing-title' ) );
+                       $this->addError( 'topic', $this->context->msg( 
'flow-error-missing-title' ) );
                        return;
                }
                if ( mb_strlen( $this->submitted['topic'] ) > 
PostRevision::MAX_TOPIC_LENGTH ) {
-                       $this->addError( 'topic', wfMessage( 
'flow-error-title-too-long', PostRevision::MAX_TOPIC_LENGTH ) );
+                       $this->addError( 'topic', $this->context->msg( 
'flow-error-title-too-long', PostRevision::MAX_TOPIC_LENGTH ) );
                        return;
                }
 
                if ( trim( $this->submitted['content'] ) === '' ) {
-                       $this->addError( 'content', wfMessage( 
'flow-error-missing-content' ) );
+                       $this->addError( 'content', $this->context->msg( 
'flow-error-missing-content' ) );
                        return;
                }
 
diff --git a/includes/Block/TopicSummary.php b/includes/Block/TopicSummary.php
index b290163..1343d7f 100644
--- a/includes/Block/TopicSummary.php
+++ b/includes/Block/TopicSummary.php
@@ -103,7 +103,7 @@
         */
        protected function validateTopicSummary() {
                if ( !isset( $this->submitted['summary'] ) || !is_string( 
$this->submitted['summary'] ) ) {
-                       $this->addError( 'content', wfMessage( 
'flow-error-missing-summary' ) );
+                       $this->addError( 'content', $this->context->msg( 
'flow-error-missing-summary' ) );
                        return;
                }
 
@@ -114,12 +114,12 @@
                // Create topic summary
                if ( !$this->topicSummary ) {
                        if ( !$this->permissions->isAllowed( null, 
'create-topic-summary' ) ) {
-                               $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                               $this->addError( 'permissions', 
$this->context->msg( 'flow-error-not-allowed' ) );
                                return;
                        }
                        // new summary should not have a previous revision
                        if ( !empty( $this->submitted['prev_revision'] ) ) {
-                               $this->addError( 'prev_revision', wfMessage( 
'flow-error-prev-revision-does-not-exist' ) );
+                               $this->addError( 'prev_revision', 
$this->context->msg( 'flow-error-prev-revision-does-not-exist' ) );
                                return;
                        }
 
@@ -132,17 +132,17 @@
                // Edit topic summary
                } else {
                        if ( !$this->permissions->isAllowed( 
$this->topicSummary, 'edit-topic-summary' ) ) {
-                               $this->addError( 'permissions', wfMessage( 
'flow-error-not-allowed' ) );
+                               $this->addError( 'permissions', 
$this->context->msg( 'flow-error-not-allowed' ) );
                                return;
                        }
                        // Check the previous revision to catch possible edit 
conflict
                        if ( empty( $this->submitted['prev_revision'] ) ) {
-                               $this->addError( 'prev_revision', wfMessage( 
'flow-error-missing-prev-revision-identifier' ) );
+                               $this->addError( 'prev_revision', 
$this->context->msg( 'flow-error-missing-prev-revision-identifier' ) );
                                return;
                        } elseif ( 
$this->topicSummary->getRevisionId()->getAlphadecimal() !== 
$this->submitted['prev_revision'] ) {
                                $this->addError(
                                        'prev_revision',
-                                       wfMessage( 
'flow-error-prev-revision-mismatch' )->params(
+                                       $this->context->msg( 
'flow-error-prev-revision-mismatch' )->params(
                                                
$this->submitted['prev_revision'],
                                                
$this->topicSummary->getRevisionId()->getAlphadecimal(),
                                                
$this->context->getUser()->getName()

-- 
To view, visit https://gerrit.wikimedia.org/r/164664
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If1b25a1f244288ff34e4661af74c6d0b2a13761c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to