Hoo man has uploaded a new change for review.
https://gerrit.wikimedia.org/r/229385
Change subject: Fix bool return value of SiteLinkTable::insertLinksInternal
......................................................................
Fix bool return value of SiteLinkTable::insertLinksInternal
This method is supposed to return false in case anything goes
wrong, not just die.
We need this behavior for the rebuildItemsPerSite maintenance
script which (tries) to re-insert all links.
Change-Id: I4f47e7899a0df0142d134379edeb72ccf6f6094f
---
M lib/includes/store/sql/SiteLinkTable.php
M lib/tests/phpunit/store/Sql/SiteLinkTableTest.php
2 files changed, 20 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/85/229385/1
diff --git a/lib/includes/store/sql/SiteLinkTable.php
b/lib/includes/store/sql/SiteLinkTable.php
index 60848da..9aa9510 100644
--- a/lib/includes/store/sql/SiteLinkTable.php
+++ b/lib/includes/store/sql/SiteLinkTable.php
@@ -151,9 +151,12 @@
'ips_site_id' => $link->getSiteId(),
'ips_site_page' => $link->getPageName()
),
- __METHOD__
+ __METHOD__,
+ array( 'IGNORE' )
);
+ $success = $success && $dbw->affectedRows() === 1;
+
if ( !$success ) {
break;
}
diff --git a/lib/tests/phpunit/store/Sql/SiteLinkTableTest.php
b/lib/tests/phpunit/store/Sql/SiteLinkTableTest.php
index d19bbda..0af7e44 100644
--- a/lib/tests/phpunit/store/Sql/SiteLinkTableTest.php
+++ b/lib/tests/phpunit/store/Sql/SiteLinkTableTest.php
@@ -57,12 +57,25 @@
return array( $items );
}
+ public function saveLinksOfItemProvider() {
+ $itemProvider = $this->itemProvider();
+ $goodItem = $itemProvider[0][0];
+
+ $conflicItem = new Item( new ItemId( 'Q2' ) );
+ $conflicItem->getSiteLinkList()->addNewSiteLink( 'enwiki',
'Beer' );
+
+ return array(
+ array( true, $goodItem ),
+ array( false, $conflicItem )
+ );
+ }
+
/**
- * @dataProvider itemProvider
+ * @dataProvider saveLinksOfItemProvider
*/
- public function testSaveLinksOfItem( Item $item ) {
+ public function testSaveLinksOfItem( $expected, Item $item ) {
$res = $this->siteLinkTable->saveLinksOfItem( $item );
- $this->assertTrue( $res );
+ $this->assertSame( $expected, $res );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/229385
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f47e7899a0df0142d134379edeb72ccf6f6094f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits