jenkins-bot has submitted this change and it was merged. Change subject: Pull out isModeratedChange to check if something is a moderation action ......................................................................
Pull out isModeratedChange to check if something is a moderation action Change-Id: I92a4639e17ac5d5eb83b076a0ef156ce29eb50de --- M includes/Data/Listener/ModerationLoggingListener.php M includes/Model/AbstractRevision.php 2 files changed, 29 insertions(+), 21 deletions(-) Approvals: Sbisson: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Data/Listener/ModerationLoggingListener.php b/includes/Data/Listener/ModerationLoggingListener.php index 3748ca9..6e52f0c 100644 --- a/includes/Data/Listener/ModerationLoggingListener.php +++ b/includes/Data/Listener/ModerationLoggingListener.php @@ -30,8 +30,7 @@ } protected function log( PostRevision $post, Workflow $workflow ) { - $moderationChangeTypes = self::getModerationChangeTypes(); - if ( ! in_array( $post->getChangeType(), $moderationChangeTypes ) ) { + if ( !$post->isModerationChange() ) { // Do nothing for non-moderation actions return; } @@ -46,24 +45,5 @@ $workflowId ); } - } - - public static function getModerationChangeTypes() { - static $changeTypes = false; - - if ( ! $changeTypes ) { - $changeTypes = array(); - foreach( AbstractRevision::$perms as $perm ) { - if ( $perm != '' ) { - $changeTypes[] = "{$perm}-topic"; - $changeTypes[] = "{$perm}-post"; - } - } - - $changeTypes[] = 'restore-topic'; - $changeTypes[] = 'restore-post'; - } - - return $changeTypes; } } diff --git a/includes/Model/AbstractRevision.php b/includes/Model/AbstractRevision.php index 6c34df1..717b8ec 100644 --- a/includes/Model/AbstractRevision.php +++ b/includes/Model/AbstractRevision.php @@ -35,6 +35,13 @@ ); /** + * List of moderation change types + * + * @var array|null + */ + static protected $moderationChangeTypes = null; + + /** * @var UUID */ protected $revId; @@ -710,6 +717,27 @@ return $this->moderatedBy ? $this->moderatedBy->wiki : null; } + protected static function getModerationChangeTypes() { + if ( self::$moderationChangeTypes === null ) { + self::$moderationChangeTypes = array(); + foreach( self::$perms as $perm ) { + if ( $perm != '' ) { + self::$moderationChangeTypes[] = "{$perm}-topic"; + self::$moderationChangeTypes[] = "{$perm}-post"; + } + } + + self::$moderationChangeTypes[] = 'restore-topic'; + self::$moderationChangeTypes[] = 'restore-post'; + } + + return self::$moderationChangeTypes; + } + + public function isModerationChange() { + return in_array( $this->getChangeType(), self::getModerationChangeTypes() ); + } + /** * @return integer */ -- To view, visit https://gerrit.wikimedia.org/r/248473 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I92a4639e17ac5d5eb83b076a0ef156ce29eb50de Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Sbisson <sbis...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits