jenkins-bot has submitted this change and it was merged. Change subject: When merging items, reuse conflicting labels as aliases ......................................................................
When merging items, reuse conflicting labels as aliases Bug: T67990 Change-Id: I78be7ca03a4a6fd0d86a5b476dd89ea81bac9fd3 --- M repo/includes/ChangeOp/ChangeOpsMerge.php M repo/includes/api/MergeItems.php M repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php M repo/tests/phpunit/includes/Interactors/ItemMergeInteractorTest.php M repo/tests/phpunit/includes/api/MergeItemsTest.php M repo/tests/phpunit/includes/specials/SpecialMergeItemsTest.php 6 files changed, 23 insertions(+), 22 deletions(-) Approvals: Daniel Kinzler: Checked; Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/ChangeOp/ChangeOpsMerge.php b/repo/includes/ChangeOp/ChangeOpsMerge.php index dd83808..2db7a48 100644 --- a/repo/includes/ChangeOp/ChangeOpsMerge.php +++ b/repo/includes/ChangeOp/ChangeOpsMerge.php @@ -59,7 +59,7 @@ */ private $changeOpFactoryProvider; - static $conflictTypes = array( 'label', 'description', 'sitelink' ); + public static $conflictTypes = array( 'description', 'sitelink' ); /** * @param Item $fromItem @@ -102,7 +102,8 @@ throw new InvalidArgumentException( '$ignoreConflicts must be an array' ); } - if ( array_diff( $ignoreConflicts, self::$conflictTypes ) ) { + //TODO remove the adition of 'label' below. This was added to allow a soft deprecation 11-12-14 + if ( array_diff( $ignoreConflicts, array_merge( self::$conflictTypes, array( 'label' ) ) ) ) { throw new InvalidArgumentException( '$ignoreConflicts array can only contain "label", "description" and or "sitelink" values' ); @@ -168,9 +169,8 @@ $this->fromChangeOps->add( $this->getFingerprintChangeOpFactory()->newRemoveLabelOp( $langCode ) ); $this->toChangeOps->add( $this->getFingerprintChangeOpFactory()->newSetLabelOp( $langCode, $label ) ); } else { - if ( !in_array( 'label', $this->ignoreConflicts ) ) { - throw new ChangeOpException( "Conflicting labels for language {$langCode}" ); - } + $this->fromChangeOps->add( $this->getFingerprintChangeOpFactory()->newRemoveLabelOp( $langCode ) ); + $this->toChangeOps->add( $this->getFingerprintChangeOpFactory()->newAddAliasesOp( $langCode, array( $label ) ) ); } } } diff --git a/repo/includes/api/MergeItems.php b/repo/includes/api/MergeItems.php index 60b13b4..a94e6ab 100644 --- a/repo/includes/api/MergeItems.php +++ b/repo/includes/api/MergeItems.php @@ -214,9 +214,9 @@ 'apihelp-wbmergeitems-example-1', 'action=wbmergeitems&fromid=Q555&toid=Q3' => 'apihelp-wbmergeitems-example-2', - 'action=wbmergeitems&fromid=Q66&toid=Q99&ignoreconflicts=label' => + 'action=wbmergeitems&fromid=Q66&toid=Q99&ignoreconflicts=sitelinks' => 'apihelp-wbmergeitems-example-3', - 'action=wbmergeitems&fromid=Q66&toid=Q99&ignoreconflicts=label|description' => + 'action=wbmergeitems&fromid=Q66&toid=Q99&ignoreconflicts=sitelinks|description' => 'apihelp-wbmergeitems-example-4', ); } diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php b/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php index 5bde95e..6b22c6c 100644 --- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php +++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php @@ -191,8 +191,11 @@ $testCases['ignoreConflictLabelMerge'] = array( array( 'label' => array( 'en' => 'foo' ) ), array( 'label' => array( 'en' => 'bar' ) ), - array( 'label' => array( 'en' => 'foo' ) ), - array( 'label' => array( 'en' => 'bar' ) ), + array( 'label' => array( ) ), + array( + 'label' => array( 'en' => 'bar' ), + 'aliases' => array( 'en' => array( 'foo' ) ) + ), array( 'label' ) ); $testCases['descriptionMerge'] = array( @@ -346,7 +349,7 @@ 'links' => array( 'plwiki' => array( 'name' => 'toLink', 'badges' => array() ) ), ), array( - 'label' => array( 'en' => 'foo' ), + 'label' => array( ), 'description' => array( 'pl' => 'pldesc' ), 'links' => array( 'plwiki' => array( 'name' => 'bar', 'badges' => array() ) ), ), diff --git a/repo/tests/phpunit/includes/Interactors/ItemMergeInteractorTest.php b/repo/tests/phpunit/includes/Interactors/ItemMergeInteractorTest.php index 2e07bcb..3d9af00 100644 --- a/repo/tests/phpunit/includes/Interactors/ItemMergeInteractorTest.php +++ b/repo/tests/phpunit/includes/Interactors/ItemMergeInteractorTest.php @@ -152,11 +152,14 @@ 'de' => array( 'language' => 'de', 'value' => 'berlin' ) ) ), array( 'labels' => array( 'en' => array( 'language' => 'en', 'value' => 'bar' ) ) ), - array( 'labels' => array( 'en' => array( 'language' => 'en', 'value' => 'foo' ) ) ), - array( 'labels' => array( + array( ), + array( + 'labels' => array( 'en' => array( 'language' => 'en', 'value' => 'bar' ), 'de' => array( 'language' => 'de', 'value' => 'berlin' ) - ) ), + ), + 'aliases' => array( 'en' => array( array( 'language' => 'en', 'value' => 'foo' ) ) ) + ), 'label' ); $testCases['descriptionMerge'] = array( @@ -313,11 +316,6 @@ public static function mergeConflictsProvider() { return array( - array( - array( 'labels' => array( 'en' => array( 'language' => 'en', 'value' => 'foo' ) ) ), - array( 'labels' => array( 'en' => array( 'language' => 'en', 'value' => 'foo2' ) ) ), - array() - ), array( array( 'descriptions' => array( 'en' => array( 'language' => 'en', 'value' => 'foo' ) ) ), array( 'descriptions' => array( 'en' => array( 'language' => 'en', 'value' => 'foo2' ) ) ), diff --git a/repo/tests/phpunit/includes/api/MergeItemsTest.php b/repo/tests/phpunit/includes/api/MergeItemsTest.php index 7c00886..b0ee383 100644 --- a/repo/tests/phpunit/includes/api/MergeItemsTest.php +++ b/repo/tests/phpunit/includes/api/MergeItemsTest.php @@ -259,8 +259,8 @@ public static function provideExceptionConflictsData() { return array( array( - array( 'labels' => array( 'en' => array( 'language' => 'en', 'value' => 'foo' ) ) ), - array( 'labels' => array( 'en' => array( 'language' => 'en', 'value' => 'foo2' ) ) ), + array( 'descriptions' => array( 'en' => array( 'language' => 'en', 'value' => 'foo' ) ) ), + array( 'descriptions' => array( 'en' => array( 'language' => 'en', 'value' => 'foo2' ) ) ), ), array( array( 'sitelinks' => array( 'dewiki' => array( 'site' => 'dewiki', 'title' => 'Foo' ) ) ), diff --git a/repo/tests/phpunit/includes/specials/SpecialMergeItemsTest.php b/repo/tests/phpunit/includes/specials/SpecialMergeItemsTest.php index 7d9ca4e..655b6c1 100644 --- a/repo/tests/phpunit/includes/specials/SpecialMergeItemsTest.php +++ b/repo/tests/phpunit/includes/specials/SpecialMergeItemsTest.php @@ -330,8 +330,8 @@ public function provideExceptionConflictsData() { return array( array( - array( 'labels' => array( 'en' => array( 'language' => 'en', 'value' => 'foo' ) ) ), - array( 'labels' => array( 'en' => array( 'language' => 'en', 'value' => 'foo2' ) ) ), + array( 'descriptions' => array( 'en' => array( 'language' => 'en', 'value' => 'foo' ) ) ), + array( 'descriptions' => array( 'en' => array( 'language' => 'en', 'value' => 'foo2' ) ) ), ), array( array( 'sitelinks' => array( 'dewiki' => array( 'site' => 'dewiki', 'title' => 'Foo' ) ) ), -- To view, visit https://gerrit.wikimedia.org/r/178062 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I78be7ca03a4a6fd0d86a5b476dd89ea81bac9fd3 Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits