Cenarium has uploaded a new change for review.

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

Change subject: Record move of stable settings in logs after page move
......................................................................

Record move of stable settings in logs after page move

When a page with non-default stable settings is moved, this adds an
entry to the stable log of the new page, as is done for protections.

Bug: T59912
Change-Id: I200eb146bb7bfd0edfe42a09a69fc44058bb1219
---
M backend/FlaggedRevs.hooks.php
M backend/FlaggedRevsLog.php
M frontend/FlaggedRevsLogFormatter.php
M i18n/flaggedrevs/en.json
M i18n/flaggedrevs/qqq.json
5 files changed, 65 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/FlaggedRevs 
refs/changes/79/253279/1

diff --git a/backend/FlaggedRevs.hooks.php b/backend/FlaggedRevs.hooks.php
index 2cd138f..21a8506 100755
--- a/backend/FlaggedRevs.hooks.php
+++ b/backend/FlaggedRevs.hooks.php
@@ -60,20 +60,29 @@
         * (b) Autoreview pages moved into reviewable namespaces (bug 19379)
         */
        public static function onTitleMoveComplete(
-               Title $otitle, Title $ntitle, $user, $pageId
+               Title $otitle, Title $ntitle, $user, $pageId, $redirid, $reason
        ) {
-               if ( !FlaggedRevs::inReviewNamespace( $otitle )
-                       && FlaggedRevs::inReviewNamespace( $ntitle )
-                       && FlaggedRevs::autoReviewNewPages()
-               ) {
-                       $fa = FlaggableWikiPage::getTitleInstance( $ntitle );
-                       $fa->loadPageData( 'fromdbmaster' );
-                       // Re-validate NS/config (new title may not be 
reviewable)
-                       if ( $fa->isReviewable() && $ntitle->userCan( 
'autoreview' ) ) {
-                               // Auto-review such edits like new pages...
-                               $rev = Revision::newFromTitle( $ntitle, false, 
Revision::READ_LATEST );
-                               if ( $rev ) { // sanity
-                                       FlaggedRevs::autoReviewEdit( $fa, 
$user, $rev );
+               if ( FlaggedRevs::inReviewNamespace( $ntitle ) ) {
+                       if ( !FlaggedRevs::inReviewNamespace( $otitle ) ) {
+                               if ( FlaggedRevs::autoReviewNewPages() ) {
+                                       $fa = 
FlaggableWikiPage::getTitleInstance( $ntitle );
+                                       $fa->loadPageData( 'fromdbmaster' );
+                                       // Re-validate NS/config (new title may 
not be reviewable)
+                                       if ( $fa->isReviewable() && 
$ntitle->userCan( 'autoreview' ) ) {
+                                               // Auto-review such edits like 
new pages...
+                                               $rev = Revision::newFromTitle( 
$ntitle, false, Revision::READ_LATEST );
+                                               if ( $rev ) { // sanity
+                                                       
FlaggedRevs::autoReviewEdit( $fa, $user, $rev );
+                                               }
+                                       }
+                               }
+                       } else {
+                               $fa = FlaggableWikiPage::getTitleInstance( 
$ntitle );
+                               $fa->loadPageData( 'fromdbmaster' );
+                               $config = $fa->getStabilitySettings();
+                               // Insert a stable log entry if page doesn't 
have default wiki settings
+                               if ( !FRPageConfig::configIsReset( $config ) ) {
+                                       
FlaggedRevsLog::updateStabilityLogOnMove( $ntitle, $otitle, $reason, $user );
                                }
                        }
                }
diff --git a/backend/FlaggedRevsLog.php b/backend/FlaggedRevsLog.php
index b560f99..211d79c 100644
--- a/backend/FlaggedRevsLog.php
+++ b/backend/FlaggedRevsLog.php
@@ -14,7 +14,7 @@
         * @return bool
         */
        public static function isStabilityAction( $action ) {
-               return preg_match( '/^(config|modify|reset)$/', $action );
+               return preg_match( '/^(config|modify|reset|move_stable)$/', 
$action );
        }
 
        /**
@@ -132,6 +132,36 @@
        }
 
        /**
+        * Record move of settings in stability log
+        * @param Title $title
+        * @param string $reason
+        * @param User $user performing the action
+        */
+       public static function updateStabilityLogOnMove( Title $newTitle, Title 
$oldTitle, $reason, $user ) {
+               $logEntry = new ManualLogEntry( 'stable', 'move_stable' );
+               $logEntry->setPerformer( $user );
+               $logEntry->setTarget( $newTitle );
+
+               // Build comment for log
+               $comment = wfMessage(
+                       'prot_1movedto2',
+                       $oldTitle->getPrefixedText(),
+                       $newTitle->getPrefixedText()
+               )->inContentLanguage()->text();
+               if ( $reason ) {
+                       $comment .= wfMessage( 'colon-separator' 
)->inContentLanguage()->text() . $reason;
+               }
+               $logEntry->setComment( $comment );
+
+               $logEntry->setParameters( array(
+                       '4::oldtitle' => $oldTitle->getPrefixedText(),
+               ) );
+
+               $lodId = $logEntry->insert();
+               $logEntry->publish( $lodId );
+       }
+
+       /**
         * Get log params (associate array) from a stability config
         * @param array $config
         * @return array (associative)
diff --git a/frontend/FlaggedRevsLogFormatter.php 
b/frontend/FlaggedRevsLogFormatter.php
index c0f181d..5b8c788 100644
--- a/frontend/FlaggedRevsLogFormatter.php
+++ b/frontend/FlaggedRevsLogFormatter.php
@@ -41,10 +41,16 @@
        protected function getMessageParameters() {
                $params = parent::getMessageParameters();
                if ( $this->isStabilityAction ) {
-                       # Add setting change description as a param
-                       $settings = $this->entry->getParameters();
-                       $settings = $this->entry->isLegacy() ? 
FlaggedRevsLog::expandParams( $settings ) : $settings;
-                       $params[3] = FlaggedRevsLogView::stabilitySettings( 
$settings , false );
+                       $action = $this->entry->getSubtype();
+                       if ( $action !== 'move_stable' ) {
+                               # Add setting change description as a param
+                               $settings = $this->entry->getParameters();
+                               $settings = $this->entry->isLegacy() ? 
FlaggedRevsLog::expandParams( $settings ) : $settings;
+                               $params[3] = 
FlaggedRevsLogView::stabilitySettings( $settings , false );
+                       } else {
+                               $oldname = $this->makePageLink( 
Title::newFromText( $params[3] ), array( 'redirect' => 'no' ) );
+                               $params[3] = Message::rawParam( $oldname );
+                       }
                }
                return $params;
        }
diff --git a/i18n/flaggedrevs/en.json b/i18n/flaggedrevs/en.json
index 320cc14..c60c412 100644
--- a/i18n/flaggedrevs/en.json
+++ b/i18n/flaggedrevs/en.json
@@ -52,6 +52,7 @@
        "logentry-stable-config": "$1 {{GENDER:$2|set}} stable version settings 
for $3 $4",
        "logentry-stable-modify": "$1 {{GENDER:$2|changed}} stable version 
settings for $3 $4",
        "logentry-stable-reset": "$1 {{GENDER:$2|reset}} stable version 
settings for $3 $4",
+       "logentry-stable-move_stable": "$1 {{GENDER:$2|moved}} stable version 
settings from $4 to $3",
        "revreview-hist-draft": "unchecked revision",
        "revreview-hist-pending": "pending revision",
        "revreview-hist-quality": "quality revision",
diff --git a/i18n/flaggedrevs/qqq.json b/i18n/flaggedrevs/qqq.json
index 2304905..fb44989 100644
--- a/i18n/flaggedrevs/qqq.json
+++ b/i18n/flaggedrevs/qqq.json
@@ -81,6 +81,7 @@
        "logentry-stable-config": "{{Flagged Revs}}\nlog entry for enabling 
stabilisation config\nParams (4): link to target, user gender, link to user, 
and summary of configuration changes",
        "logentry-stable-modify": "{{Flagged Revs}}\nlog entry for modifying a 
stabilisation config\nParams (4): link to target, user gender, link to user, 
and summary of configuration changes",
        "logentry-stable-reset": "{{Flagged Revs}}\nlog entry for removing a 
stabilisation config\nParams (4): linked title, gender, linked user, and 
summary of configuration changes",
+       "logentry-stable-move_stable": "{{Flagged Revs}}\nlog entry for 
removing a stabilisation config\nParams (4): link to user, gender, new page 
title link, and old page title link",
        "revreview-hist-draft": "{{Flagged Revs}}\nShown on history and diff 
pages to refer to revision that has not been specifically marked as 
\"accepted\".",
        "revreview-hist-pending": "{{Flagged Revs}}\nShown on history and diff 
pages to refer to revision that is after the latest revision that was 
specifically marked \"accepted\".",
        "revreview-hist-quality": "{{Flagged Revs-small}}\nThe accuracy 
\"quality\", as displayed on the page history after a revision with this 
setting. This implies that the revision was accepted.",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I200eb146bb7bfd0edfe42a09a69fc44058bb1219
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FlaggedRevs
Gerrit-Branch: master
Gerrit-Owner: Cenarium <[email protected]>

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

Reply via email to