Hoo man has uploaded a new change for review.
https://gerrit.wikimedia.org/r/243398
Change subject: Fail gracefully if SiteLink not found in ParserOutputDataUpdater
......................................................................
Fail gracefully if SiteLink not found in ParserOutputDataUpdater
Bug: T114576
Change-Id: I4f0578065cfa357dff56c98043fd8a0f9b93dfe1
---
M client/includes/ParserOutputDataUpdater.php
1 file changed, 21 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/98/243398/1
diff --git a/client/includes/ParserOutputDataUpdater.php
b/client/includes/ParserOutputDataUpdater.php
index da47ad0..774659f 100644
--- a/client/includes/ParserOutputDataUpdater.php
+++ b/client/includes/ParserOutputDataUpdater.php
@@ -118,13 +118,28 @@
}
if ( $itemId ) {
- /** @var Item $item */
- $item = $this->entityLookup->getEntity( $itemId );
- $siteLink = $item->getSiteLinkList()->getBySiteId(
$this->siteId );
+ $this->setBadgesProperty( $itemId, $out );
+ }
+ }
- foreach ( $siteLink->getBadges() as $badge ) {
- $out->setProperty( 'wikibase-badge-' .
$badge->getSerialization(), true );
- }
+ private function setBadgesProperty( ItemId $itemId, ParserOutput $out )
{
+ /** @var Item $item */
+ $item = $this->entityLookup->getEntity( $itemId );
+
+ if ( !$item->getSiteLinkList()->hasLinkWithSiteId(
$this->siteId ) ) {
+ // Probably some sort of race condition or data
inconsistency, better log a warning
+ wfLogWarning(
+ 'According to a SiteLinkLookup ' .
$itemId->getSerialization() .
+ ' is linked to ' . $this->siteId . ' while it
apparently is not.'
+ );
+
+ return;
+ }
+
+ $siteLink = $item->getSiteLinkList()->getBySiteId(
$this->siteId );
+
+ foreach ( $siteLink->getBadges() as $badge ) {
+ $out->setProperty( 'wikibase-badge-' .
$badge->getSerialization(), true );
}
}
--
To view, visit https://gerrit.wikimedia.org/r/243398
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f0578065cfa357dff56c98043fd8a0f9b93dfe1
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