jenkins-bot has submitted this change and it was merged.
Change subject: wbmergeitems can now ignore sitelink conflicts
......................................................................
wbmergeitems can now ignore sitelink conflicts
Change-Id: I65d63774aa916fe4935945258a2873ca423dfee2
---
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/api/MergeItemsTest.php
4 files changed, 42 insertions(+), 11 deletions(-)
Approvals:
Daniel Kinzler: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/includes/ChangeOp/ChangeOpsMerge.php
b/repo/includes/ChangeOp/ChangeOpsMerge.php
index 64b0925..3b8e2cf 100644
--- a/repo/includes/ChangeOp/ChangeOpsMerge.php
+++ b/repo/includes/ChangeOp/ChangeOpsMerge.php
@@ -25,7 +25,7 @@
* @param ItemContent $fromItemContent
* @param ItemContent $toItemContent
* @param array $ignoreConflicts list of elements to ignore conflicts
for
- * can only contain 'label' and or 'description'
+ * can only contain 'label' and or 'description' and or 'sitelink'
*/
public function __construct(
ItemContent $fromItemContent,
@@ -45,8 +45,8 @@
throw new InvalidArgumentException( '$ignoreConflicts
must be an array' );
}
foreach( $this->ignoreConflicts as $ignoreConflict ){
- if( $ignoreConflict !== 'label' && $ignoreConflict !==
'description' ){
- throw new InvalidArgumentException(
'$ignoreConflicts array can only contain "label" or "description"' );
+ if( $ignoreConflict !== 'label' && $ignoreConflict !==
'description' && $ignoreConflict !== 'sitelink' ){
+ throw new InvalidArgumentException(
'$ignoreConflicts array can only contain "label", "description" and or
"sitelink" values' );
}
}
}
@@ -109,7 +109,9 @@
$this->fromChangeOps->add( new
ChangeOpSiteLink( $siteId, null ) );
$this->toChangeOps->add( new ChangeOpSiteLink(
$siteId, $simpleSiteLink->getPageName() ) );
} else {
- throw new ChangeOpException( "Conflicting
sitelinks for {$siteId}" );
+ if( !in_array( 'sitelink',
$this->ignoreConflicts ) ){
+ throw new ChangeOpException(
"Conflicting sitelinks for {$siteId}" );
+ }
}
}
}
diff --git a/repo/includes/api/MergeItems.php b/repo/includes/api/MergeItems.php
index 6f7b09d..9a55f69 100644
--- a/repo/includes/api/MergeItems.php
+++ b/repo/includes/api/MergeItems.php
@@ -227,7 +227,7 @@
array(
'fromid' => array( 'The id to merge from' ),
'toid' => array( 'The id to merge to' ),
- 'ignoreconflicts' => array( 'Array of elements
of the item to ignore conflicts for, can only contain values of "label" and or
"description"' ),
+ 'ignoreconflicts' => array( 'Array of elements
of the item to ignore conflicts for, can only contain values of "label" and or
"description" and or "sitelink"' ),
'token' => 'An "edittoken" token previously
obtained through the token module (prop=info).',
'summary' => array( 'Summary for the edit.',
"Will be prepended by an automatically
generated comment. The length limit of the
diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php
b/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php
index b78832f..3b56ad8 100644
--- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php
+++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php
@@ -38,6 +38,7 @@
array( $from, $to, array( 'label' ) ),
array( $from, $to, array( 'description' ) ),
array( $from, $to, array( 'description', 'label' ) ),
+ array( $from, $to, array( 'description', 'label',
'sitelink' ) ),
);
}
@@ -169,6 +170,13 @@
array(),
array( 'links' => array( 'enwiki' => array( 'name' =>
'foo', 'badges' => array() ) ) ),
);
+ $testCases['ignoreConflictLinkMerge'] = array(
+ array( 'links' => array( 'enwiki' => array( 'name' =>
'foo', 'badges' => array() ) ) ),
+ array( 'links' => array( 'enwiki' => array( 'name' =>
'bar', 'badges' => array() ) ) ),
+ array( 'links' => array( 'enwiki' => array( 'name' =>
'foo', 'badges' => array() ) ) ),
+ array( 'links' => array( 'enwiki' => array( 'name' =>
'bar', 'badges' => array() ) ) ),
+ array( 'sitelink' ),
+ );
$testCases['claimMerge'] = array(
array( 'claims' => array(
array(
@@ -235,7 +243,10 @@
'label' => array( 'en' => 'foo', 'pt' =>
'ptfoo' ),
'description' => array( 'en' => 'foo', 'pl' =>
'pldesc' ),
'aliases' => array( 'en' => array( 'foo', 'bar'
), 'de' => array( 'defoo', 'debar' ) ),
- 'links' => array( 'dewiki' => array( 'name' =>
'foo', 'badges' => array() ) ),
+ 'links' => array(
+ 'dewiki' => array( 'name' => 'foo',
'badges' => array() ),
+ 'plwiki' => array( 'name' => 'bar',
'badges' => array() ),
+ ),
'claims' => array(
array(
'm' => array( 'novalue', 88 ),
@@ -245,24 +256,29 @@
),
array(
'label' => array( 'en' => 'toLabel' ),
- 'description' => array( 'pl' => 'toLabel' )
+ 'description' => array( 'pl' => 'toLabel' ),
+ 'links' => array( 'plwiki' => array( 'name' =>
'toLink', 'badges' => array() ) ),
),
array(
'label' => array( 'en' => 'foo' ),
- 'description' => array( 'pl' => 'pldesc' )
+ 'description' => array( 'pl' => 'pldesc' ),
+ 'links' => array( 'plwiki' => array( 'name' =>
'bar', 'badges' => array() ) ),
),
array(
'label' => array( 'en' => 'toLabel', 'pt' =>
'ptfoo' ),
'description' => array( 'en' => 'foo', 'pl' =>
'toLabel' ),
'aliases' => array( 'en' => array( 'foo', 'bar'
), 'de' => array( 'defoo', 'debar' ) ),
- 'links' => array( 'dewiki' => array( 'name' =>
'foo', 'badges' => array() ) ),
+ 'links' => array(
+ 'dewiki' => array( 'name' => 'foo',
'badges' => array() ),
+ 'plwiki' => array( 'name' => 'toLink',
'badges' => array() ),
+ ),
'claims' => array(
array(
'm' => array( 'novalue', 88 ),
'q' => array( array(
'novalue', 88 ) ) )
),
),
- array( 'label', 'description' )
+ array( 'label', 'description', 'sitelink' )
);
return $testCases;
}
diff --git a/repo/tests/phpunit/includes/api/MergeItemsTest.php
b/repo/tests/phpunit/includes/api/MergeItemsTest.php
index 130ab65..44bcccd 100644
--- a/repo/tests/phpunit/includes/api/MergeItemsTest.php
+++ b/repo/tests/phpunit/includes/api/MergeItemsTest.php
@@ -102,7 +102,7 @@
array(),
array( 'aliases' => array( array( "language" => "nl",
"value" => "Dickes B" ) ) ),
);
- $testCases[] = array(
+ $testCases['aliasesMerge2'] = array(
array( 'aliases' => array( array( "language" => "nl",
"value" => "Ali1" ) ) ),
array( 'aliases' => array( array( "language" => "nl",
"value" => "Ali2" ) ) ),
array(),
@@ -114,6 +114,19 @@
array(),
array( 'sitelinks' => array( 'dewiki' => array( 'site'
=> 'dewiki', 'title' => 'Foo' ) ) ),
);
+ $testCases['IgnoreConflictSitelinksMerge'] = array(
+ array( 'sitelinks' => array(
+ 'dewiki' => array( 'site' => 'dewiki', 'title'
=> 'RemainFrom' ),
+ 'enwiki' => array( 'site' => 'enwiki', 'title'
=> 'PlFrom' ),
+ ) ),
+ array( 'sitelinks' => array( 'dewiki' => array( 'site'
=> 'dewiki', 'title' => 'RemainTo' ) ) ),
+ array( 'sitelinks' => array( 'dewiki' => array( 'site'
=> 'dewiki', 'title' => 'RemainFrom' ) ) ),
+ array( 'sitelinks' => array(
+ 'dewiki' => array( 'site' => 'dewiki', 'title'
=> 'RemainTo' ),
+ 'enwiki' => array( 'site' => 'enwiki', 'title'
=> 'PlFrom' ),
+ ) ),
+ 'sitelink'
+ );
$testCases['claimMerge'] = array(
array( 'claims' => array( 'P56' => array( array(
'mainsnak' => array(
'snaktype' => 'value', 'property' => 'P56',
'datavalue' => array( 'value' => 'imastring', 'type' => 'string' ) ),
--
To view, visit https://gerrit.wikimedia.org/r/94335
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I65d63774aa916fe4935945258a2873ca423dfee2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits