Aude has uploaded a new change for review.

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

Change subject: New auto-summary message for SpecialSetLabelDescriptionAliases
......................................................................

New auto-summary message for SpecialSetLabelDescriptionAliases

Again, this is only one step, more patches are coming. There are a lot of
FIXMEs in here, but I would love to fix them in later patches. Please
review and merge so we can move forward. If you find actual issues
introduced by this patch I will fix them. If you find issues *not*
introduced here I will mark them as FIXME if not already done. Ok?

Bug: T93853
Change-Id: I66f06792386adddf48e342a7a623e38033bc28ae
---
M repo/i18n/en.json
M repo/i18n/qqq.json
M repo/includes/specials/SpecialSetLabelDescriptionAliases.php
3 files changed, 76 insertions(+), 42 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/07/199607/1

diff --git a/repo/i18n/en.json b/repo/i18n/en.json
index 416d3d3..2ef6536 100644
--- a/repo/i18n/en.json
+++ b/repo/i18n/en.json
@@ -341,6 +341,7 @@
        "wikibase-item-summary-wbsetaliases-add-remove": "Added and removed 
[$2] {{PLURAL:$1|alias|aliases}}",
        "wikibase-item-summary-wbsetaliases-add": "Added [$2] 
{{PLURAL:$1|alias|aliases}}",
        "wikibase-item-summary-wbsetaliases-remove": "Removed [$2] 
{{PLURAL:$1|alias|aliases}}",
+       "wikibase-item-summary-wbsetlabeldescriptionaliases": "Changed [$2] 
label, description and aliases",
        "wikibase-item-summary-wbsetsitelink-add": "Added link to [$2]",
        "wikibase-item-summary-wbsetsitelink-add-both": "Added link with badges 
to [$2]",
        "wikibase-item-summary-wbsetsitelink-set": "Changed link to [$2]",
@@ -393,6 +394,7 @@
        "wikibase-property-summary-wbsetaliases-add-remove": "Added and removed 
[$2] {{PLURAL:$1|alias|aliases}}",
        "wikibase-property-summary-wbsetaliases-add": "Added [$2] 
{{PLURAL:$1|alias|aliases}}",
        "wikibase-property-summary-wbsetaliases-remove": "Removed [$2] 
{{PLURAL:$1|alias|aliases}}",
+       "wikibase-property-summary-wbsetlabeldescriptionaliases": "Changed [$2] 
label, description and aliases",
        "wikibase-property-summary-wbsetclaim-update": "Changed 
{{PLURAL:$3|claim|claims}}",
        "wikibase-property-summary-wbsetclaim-create": "Created 
{{PLURAL:$3|claim|claims}}",
        "wikibase-property-summary-wbsetclaim-update-qualifiers": "Changed 
{{PLURAL:$4|one qualifier|$4 qualifiers}} of {{PLURAL:$3|claim|claims}}",
diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json
index 8f1178e..248f76d 100644
--- a/repo/i18n/qqq.json
+++ b/repo/i18n/qqq.json
@@ -363,6 +363,7 @@
        "wikibase-item-summary-wbsetaliases-add-remove": "{{wikibase summary 
messages|item|Automatic edit summary when adding and removing item aliases. A 
user can be in edit mode for aliases and can remove one or more aliases, while 
adding others in the same edit.}}",
        "wikibase-item-summary-wbsetaliases-add": "{{wikibase summary 
messages|item|Automatic edit summary when adding one or more aliases.}}",
        "wikibase-item-summary-wbsetaliases-remove": "{{wikibase summary 
messages|item|Automatic edit summary when a user removes one or more 
aliases.}}",
+       "wikibase-item-summary-wbsetlabeldescriptionaliases": "{{wikibase 
summary messages|item|Automatic edit summary generated when editing an item 
label, description and aliases. Example of a full edit summary is \"Changed 
[en] label, description and aliases: Label, Description, Alias 1, Alias 2\".}}",
        "wikibase-item-summary-wbsetsitelink-add": "{{wikibase summary 
messages|sitelinks|Automatic edit summary (autocomment) when adding a language 
link. Such a summary could appear in English as \"Added link to [itwiki]:  
Italia\".}}",
        "wikibase-item-summary-wbsetsitelink-add-both": "{{wikibase summary 
messages|sitelinks|Automatic edit summary (autocomment) when adding a language 
link with badges. Such a summary could appear in English as \"Added link to 
[itwiki]:  Italia, Q2, Q3\".}}",
        "wikibase-item-summary-wbsetsitelink-set": "{{doc-important|Translate 
this as \"Changed link which points to <nowiki>[$2]</nowiki>\".}}\n{{wikibase 
summary messages|sitelinks|Automatic edit summary (autocomment) when editing a 
language link. Such a summary could appear in English as \"Changed link to 
[itwiki]:  Italia\".}}",
@@ -415,6 +416,7 @@
        "wikibase-property-summary-wbsetaliases-add-remove": "Automatic edit 
summary when adding and removing property aliases. A user can be in edit mode 
for aliases and can remove one or more aliases, while adding others in the same 
edit.\n\nParameters:\n* $1 - the number of aliases added/removed\n* $2 - the 
language code of the item page",
        "wikibase-property-summary-wbsetaliases-add": "Automatic edit summary 
when adding an alias(es) for a property. Parameters:\n* $1 - the number of 
aliases that were added\n* $2 - the language code for the item page",
        "wikibase-property-summary-wbsetaliases-remove": "Automatic edit 
summary when a user removes one or more aliases from a property. Parameters:\n* 
$1 - the number of aliases that were removed\n* $2 - the language code for the 
item page",
+       "wikibase-property-summary-wbsetlabeldescriptionaliases": "{{wikibase 
summary messages|item|Automatic edit summary generated when editing an property 
label, description and aliases. Example of a full edit summary is \"Changed 
[en] label, description and aliases: Label, Description, Alias 1, Alias 2\".}}",
        "wikibase-property-summary-wbsetclaim-update": "Automatic edit summary 
generated when modifying a claim using setclaim. Parameters:\n* $3 - number of 
claims changed.\n{{related|Wikibase-property-summary-wbsetclaim}}",
        "wikibase-property-summary-wbsetclaim-create": "Automatic edit summary 
generated when creating a new claim using setclaim. Parameters:\n* $3 - number 
of claims changed.\n{{related|Wikibase-property-summary-wbsetclaim}}",
        "wikibase-property-summary-wbsetclaim-update-qualifiers": "Automatic 
edit summary generated when modifying the qualifiers of a claim using setclaim. 
Parameters:\n* $3 - number of claims changed\n* $4 - number of qualifiers 
changed.\n{{related|Wikibase-property-summary-wbsetclaim}}",
diff --git a/repo/includes/specials/SpecialSetLabelDescriptionAliases.php 
b/repo/includes/specials/SpecialSetLabelDescriptionAliases.php
index 95ecfe6..7936811 100644
--- a/repo/includes/specials/SpecialSetLabelDescriptionAliases.php
+++ b/repo/includes/specials/SpecialSetLabelDescriptionAliases.php
@@ -4,9 +4,11 @@
 
 use Html;
 use Language;
+use Wikibase\ChangeOp\ChangeOp;
 use Wikibase\ChangeOp\ChangeOpException;
 use Wikibase\ChangeOp\FingerprintChangeOpFactory;
 use Wikibase\DataModel\Entity\Entity;
+use Wikibase\DataModel\Term\Fingerprint;
 use Wikibase\DataModel\Term\FingerprintProvider;
 use Wikibase\Lib\ContentLanguages;
 use Wikibase\Repo\WikibaseRepo;
@@ -239,7 +241,7 @@
        }
 
        /**
-        * @param string $languageCode
+        * @param string|null $languageCode
         *
         * @return bool
         */
@@ -252,52 +254,19 @@
         *
         * @param Entity $entity
         *
-        * @return Summary[]|bool
+        * @return Summary|bool
         */
        protected function modifyEntity( Entity $entity ) {
-               $fingerprint = $entity->getFingerprint();
-               $changeOpFactory = $this->changeOpFactory;
-               $changeOps = array();
+               $changeOps = $this->getChangeOps( $entity->getFingerprint() );
 
-               if ( $this->label !== '' ) {
-                       $changeOps[] = $changeOpFactory->newSetLabelOp(
-                               $this->languageCode,
-                               $this->label
-                       );
-               } elseif ( $fingerprint->hasLabel( $this->languageCode ) ) {
-                       $changeOps[] = $changeOpFactory->newRemoveLabelOp(
-                               $this->languageCode
-                       );
-               }
-
-               if ( $this->description !== '' ) {
-                       $changeOps[] = $changeOpFactory->newSetDescriptionOp(
-                               $this->languageCode,
-                               $this->description
-                       );
-               } elseif ( $fingerprint->hasDescription( $this->languageCode ) 
) {
-                       $changeOps[] = $changeOpFactory->newRemoveDescriptionOp(
-                               $this->languageCode
-                       );
-               }
-
-               if ( !empty( $this->aliases ) ) {
-                       $changeOps[] = $changeOpFactory->newSetAliasesOp(
-                               $this->languageCode,
-                               $this->aliases
-                       );
-               } elseif ( $fingerprint->hasAliasGroup( $this->languageCode ) ) 
{
-                       $changeOps[] = $changeOpFactory->newRemoveAliasesOp(
-                               $this->languageCode,
-                               $fingerprint->getAliasGroup( 
$this->languageCode )->getAliases()
-                       );
-               }
-
+               $summary = false;
                $success = true;
 
-               foreach ( $changeOps as $changeOp ) {
+               foreach ( $changeOps as $module => $changeOp ) {
+                       $summary = new Summary( $module );
+
                        try {
-                               $this->applyChangeOp( $changeOp, $entity );
+                               $this->applyChangeOp( $changeOp, $entity, 
$summary );
                        } catch ( ChangeOpException $ex ) {
                                $this->showErrorHTML( $ex->getMessage() );
                                $success = false;
@@ -306,9 +275,70 @@
 
                if ( !$success ) {
                        return false;
+               } elseif ( count( $changeOps ) === 1 ) {
+                       return $summary;
                }
 
-               return new Summary( 'wbeditentity' );
+               return $this->getSummaryForLabelDescriptionAliases();
+       }
+
+       /**
+        * @param Fingerprint $fingerprint
+        *
+        * @return ChangeOp[]
+        */
+       private function getChangeOps( Fingerprint $fingerprint ) {
+               $changeOpFactory = $this->changeOpFactory;
+               $changeOps = array();
+
+               if ( $this->label !== '' ) {
+                       $changeOps['wbsetlabel'] = 
$changeOpFactory->newSetLabelOp(
+                               $this->languageCode,
+                               $this->label
+                       );
+               } elseif ( $fingerprint->hasLabel( $this->languageCode ) ) {
+                       $changeOps['wbsetlabel'] = 
$changeOpFactory->newRemoveLabelOp(
+                               $this->languageCode
+                       );
+               }
+
+               if ( $this->description !== '' ) {
+                       $changeOps['wbsetdescription'] = 
$changeOpFactory->newSetDescriptionOp(
+                               $this->languageCode,
+                               $this->description
+                       );
+               } elseif ( $fingerprint->hasDescription( $this->languageCode ) 
) {
+                       $changeOps['wbsetdescription'] = 
$changeOpFactory->newRemoveDescriptionOp(
+                               $this->languageCode
+                       );
+               }
+
+               if ( !empty( $this->aliases ) ) {
+                       $changeOps['wbsetaliases'] = 
$changeOpFactory->newSetAliasesOp(
+                               $this->languageCode,
+                               $this->aliases
+                       );
+               } elseif ( $fingerprint->hasAliasGroup( $this->languageCode ) ) 
{
+                       $changeOps['wbsetaliases'] = 
$changeOpFactory->newRemoveAliasesOp(
+                               $this->languageCode,
+                               $fingerprint->getAliasGroup( 
$this->languageCode )->getAliases()
+                       );
+               }
+
+               return $changeOps;
+       }
+
+       /**
+        * @return Summary
+        */
+       private function getSummaryForLabelDescriptionAliases() {
+               // FIXME: Use the existing messages if only 1 of the 3 fields 
changed.
+               // FIXME: Introduce more specific messages if only 2 of the 3 
fields changed.
+               $summary = new Summary( 'wbsetlabeldescriptionaliases' );
+               $summary->addAutoSummaryArgs( $this->label, $this->description, 
$this->aliases );
+
+               $summary->setLanguage( $this->languageCode );
+               return $summary;
        }
 
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I66f06792386adddf48e342a7a623e38033bc28ae
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: wmf/1.25wmf22
Gerrit-Owner: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to