jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/318683 )

Change subject: Move count of revisions/files out of undelete log comment
......................................................................


Move count of revisions/files out of undelete log comment

The log comment on undelete contains a hint about the count of restored
files and/or revisions.
Move this text out of the comment to allow longer comments. Also makes
this information readable inside the api.

This is only for new log entries. Old entries will still show the hint
from the comment and no data in the api.

Change-Id: I9e30eb1271656bb81259a408210e9a282e949c57
---
M includes/logging/DeleteLogFormatter.php
M includes/page/PageArchive.php
M languages/i18n/en.json
M languages/i18n/qqq.json
M tests/phpunit/includes/logging/DeleteLogFormatterTest.php
5 files changed, 67 insertions(+), 24 deletions(-)

Approvals:
  GeoffreyT2000: Looks good to me, but someone else must approve
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/logging/DeleteLogFormatter.php 
b/includes/logging/DeleteLogFormatter.php
index 05973df..ceb0052 100644
--- a/includes/logging/DeleteLogFormatter.php
+++ b/includes/logging/DeleteLogFormatter.php
@@ -39,6 +39,12 @@
                                // logentry-suppress-event-legacy, 
logentry-suppress-revision-legacy
                                return "$key-legacy";
                        }
+               } elseif ( $this->entry->getSubtype() === 'restore' ) {
+                       $rawParams = $this->entry->getParameters();
+                       if ( !isset( $rawParams[':assoc:count'] ) ) {
+                               // Message: logentry-delete-restore-nocount
+                               return $key . '-nocount';
+                       }
                }
 
                return $key;
@@ -96,6 +102,19 @@
                        } else {
                                $this->parsedParametersDeleteLog = array_slice( 
$params, 0, 3 );
                                return $this->parsedParametersDeleteLog;
+                       }
+               } elseif ( $subtype === 'restore' ) {
+                       $rawParams = $this->entry->getParameters();
+                       if ( isset( $rawParams[':assoc:count'] ) ) {
+                               $countList = [];
+                               foreach ( $rawParams[':assoc:count'] as $type 
=> $count ) {
+                                       if ( $count ) {
+                                               // Messages: 
restore-count-revisions, restore-count-files
+                                               $countList[] = 
$this->context->msg( 'restore-count-' . $type )
+                                                       ->numParams( $count 
)->plain();
+                                       }
+                               }
+                               $params[3] = 
$this->context->getLanguage()->listToText( $countList );
                        }
                }
 
@@ -276,6 +295,11 @@
                                $params[':assoc:old'][$key] = (bool)( $old & 
$bit );
                                $params[':assoc:new'][$key] = (bool)( $new & 
$bit );
                        }
+               } elseif ( $subtype === 'restore' ) {
+                       $rawParams = $entry->getParameters();
+                       if ( isset( $rawParams[':assoc:count'] ) ) {
+                               $params[':assoc:count'] = 
$rawParams[':assoc:count'];
+                       }
                }
 
                return $params;
diff --git a/includes/page/PageArchive.php b/includes/page/PageArchive.php
index 188088f..11e1a30 100644
--- a/includes/page/PageArchive.php
+++ b/includes/page/PageArchive.php
@@ -453,23 +453,10 @@
 
                // Touch the log!
 
-               if ( $textRestored && $filesRestored ) {
-                       $reason = wfMessage( 'undeletedrevisions-files' )
-                               ->numParams( $textRestored, $filesRestored 
)->inContentLanguage()->text();
-               } elseif ( $textRestored ) {
-                       $reason = wfMessage( 'undeletedrevisions' )->numParams( 
$textRestored )
-                               ->inContentLanguage()->text();
-               } elseif ( $filesRestored ) {
-                       $reason = wfMessage( 'undeletedfiles' )->numParams( 
$filesRestored )
-                               ->inContentLanguage()->text();
-               } else {
+               if ( !$textRestored && !$filesRestored ) {
                        wfDebug( "Undelete: nothing undeleted...\n" );
 
                        return false;
-               }
-
-               if ( trim( $comment ) != '' ) {
-                       $reason .= wfMessage( 'colon-separator' 
)->inContentLanguage()->text() . $comment;
                }
 
                if ( $user === null ) {
@@ -480,15 +467,21 @@
                $logEntry = new ManualLogEntry( 'delete', 'restore' );
                $logEntry->setPerformer( $user );
                $logEntry->setTarget( $this->title );
-               $logEntry->setComment( $reason );
+               $logEntry->setComment( $comment );
                $logEntry->setTags( $tags );
+               $logEntry->setParameters( [
+                       ':assoc:count' => [
+                               'revisions' => $textRestored,
+                               'files' => $filesRestored,
+                       ],
+               ] );
 
                Hooks::run( 'ArticleUndeleteLogEntry', [ $this, &$logEntry, 
$user ] );
 
                $logid = $logEntry->insert();
                $logEntry->publish( $logid );
 
-               return [ $textRestored, $filesRestored, $reason ];
+               return [ $textRestored, $filesRestored, $comment ];
        }
 
        /**
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index d4196b0..e08a439 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -2351,9 +2351,6 @@
        "undeleteviewlink": "view",
        "undeleteinvert": "Invert selection",
        "undeletecomment": "Reason:",
-       "undeletedrevisions": "{{PLURAL:$1|1 revision|$1 revisions}} restored",
-       "undeletedrevisions-files": "{{PLURAL:$1|1 revision|$1 revisions}} and 
{{PLURAL:$2|1 file|$2 files}} restored",
-       "undeletedfiles": "{{PLURAL:$1|1 file|$1 files}} restored",
        "cannotundelete": "Some or all of the undeletion failed:\n$1",
        "undeletedpage": "<strong>$1 has been restored</strong>\n\nConsult the 
[[Special:Log/delete|deletion log]] for a record of recent deletions and 
restorations.",
        "undelete-header": "See [[Special:Log/delete|the deletion log]] for 
recently deleted pages.",
@@ -3911,7 +3908,10 @@
        "rawmessage": "$1",
        "logentry-delete-delete": "$1 {{GENDER:$2|deleted}} page $3",
        "logentry-delete-delete_redir": "$1 {{GENDER:$2|deleted}} redirect $3 
by overwriting",
-       "logentry-delete-restore": "$1 {{GENDER:$2|restored}} page $3",
+       "logentry-delete-restore": "$1 {{GENDER:$2|restored}} page $3 ($4)",
+       "logentry-delete-restore-nocount": "$1 {{GENDER:$2|restored}} page $3",
+       "restore-count-revisions": "{{PLURAL:$1|1 revision|$1 revisions}}",
+       "restore-count-files": "{{PLURAL:$1|1 file|$1 files}}",
        "logentry-delete-event": "$1 {{GENDER:$2|changed}} visibility of 
{{PLURAL:$5|a log event|$5 log events}} on $3: $4",
        "logentry-delete-revision": "$1 {{GENDER:$2|changed}} visibility of 
{{PLURAL:$5|a revision|$5 revisions}} on page $3: $4",
        "logentry-delete-event-legacy": "$1 {{GENDER:$2|changed}} visibility of 
log events on $3",
diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json
index c39437f..3136079 100644
--- a/languages/i18n/qqq.json
+++ b/languages/i18n/qqq.json
@@ -2538,9 +2538,6 @@
        "undeleteviewlink": "First part of {{msg-mw|undeletelink}}.\nDisplay 
name of link to view a deleted page used on 
[[Special:Log/delete]].\n{{Identical|View}}",
        "undeleteinvert": "{{Identical|Invert selection}}",
        "undeletecomment": "{{Identical|Reason}}",
-       "undeletedrevisions": "Used as reason in the log entry. Parameters:\n* 
$1 - number of revisions\nSee also:\n* {{msg-mw|Undeletedrevisions-files}}\n* 
{{msg-mw|Undeletedfiles}}",
-       "undeletedrevisions-files": "Used as reason in the log entry. 
Parameters:\n* $1 - number of revisions\n* $2 - number of files\nSee also:\n* 
{{msg-mw|Undeletedrevisions}}\n* {{msg-mw|Undeletedfiles}}",
-       "undeletedfiles": "Used as reason in the log entry. Parameters:\n* $1 - 
number of files\nSee also:\n* {{msg-mw|Undeletedrevisions-files}}\n* 
{{msg-mw|Undeletedrevisions}}",
        "cannotundelete": "Message shown when undeletion failed for some 
reason. Parameters:\n* $1 - the combined wikitext of messages for all errors 
that caused the failure",
        "undeletedpage": "Used as success message. Parameters:\n* $1 - page 
title, with link",
        "undelete-header": "Used in [[Special:Undelete]].",
@@ -4098,7 +4095,10 @@
        "rawmessage": "{{notranslate}} Used to pass arbitrary text as a message 
specifier array",
        "logentry-delete-delete": "{{Logentry|[[Special:Log/delete]]}}",
        "logentry-delete-delete_redir": "{{Logentry|[[Special:Log/delete]]}}",
-       "logentry-delete-restore": "{{Logentry|[[Special:Log/delete]]}}",
+       "logentry-delete-restore": "{{Logentry|[[Special:Log/delete]]}}\n* $4 - 
{{msg-mw|restore-count-revisions}} or/and {{msg-mw|restore-count-files}}",
+       "logentry-delete-restore-nocount": 
"{{Logentry|[[Special:Log/delete]]}}",
+       "restore-count-revisions": "Used as parameter in 
{{msg-mw|logentry-delete-restore}}",
+       "restore-count-files": "Used as parameter in 
{{msg-mw|logentry-delete-restore}}",
        "logentry-delete-event": 
"{{Logentry|[[Special:Log/delete]]}}\n{{Logentryparam}}\n* $5 - count of 
affected log events",
        "logentry-delete-revision": 
"{{Logentry|[[Special:Log/delete]]}}\n{{Logentryparam}}\n* $5 - the number of 
affected revisions of the page $3",
        "logentry-delete-event-legacy": "{{Logentry|[[Special:Log/delete]]}}",
diff --git a/tests/phpunit/includes/logging/DeleteLogFormatterTest.php 
b/tests/phpunit/includes/logging/DeleteLogFormatterTest.php
index 3fb4eab..2337899 100644
--- a/tests/phpunit/includes/logging/DeleteLogFormatterTest.php
+++ b/tests/phpunit/includes/logging/DeleteLogFormatterTest.php
@@ -66,6 +66,32 @@
                                        'comment' => 'delete comment',
                                        'namespace' => NS_MAIN,
                                        'title' => 'Page',
+                                       'params' => [
+                                               ':assoc:count' => [
+                                                       'revisions' => 2,
+                                                       'files' => 1,
+                                               ],
+                                       ],
+                               ],
+                               [
+                                       'text' => 'User restored page Page (2 
revisions and 1 file)',
+                                       'api' => [
+                                               'count' => [
+                                                       'revisions' => 2,
+                                                       'files' => 1,
+                                               ],
+                                       ],
+                               ],
+                       ],
+
+                       // Legacy format without counts
+                       [
+                               [
+                                       'type' => 'delete',
+                                       'action' => 'restore',
+                                       'comment' => 'delete comment',
+                                       'namespace' => NS_MAIN,
+                                       'title' => 'Page',
                                        'params' => [],
                                ],
                                [

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9e30eb1271656bb81259a408210e9a282e949c57
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: GeoffreyT2000 <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: Umherirrender <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to