Jeroen De Dauw has submitted this change and it was merged. Change subject: Fix reference snaks handling in ClaimHtmlGenerator ......................................................................
Fix reference snaks handling in ClaimHtmlGenerator If we pass $reference->getSnaks() as a constructor param for ByPropertyIdArray, then in some situations the snaks in the reference itself are getting cast to array and then HashArray->setElement() has an array instead of SnakList which causes an uncaught exception. Instead storing $snaks as a local variable and converting that to an array, when instantiating the ByPropertyIdArray, then this issue is avoided and the code will be more robust. Bug: 71479 Change-Id: Ia5e9e7d7f7010fd3a3faa73067d3075225cb91e5 --- M repo/includes/ClaimHtmlGenerator.php 1 file changed, 4 insertions(+), 2 deletions(-) Approvals: Jeroen De Dauw: Looks good to me, approved diff --git a/repo/includes/ClaimHtmlGenerator.php b/repo/includes/ClaimHtmlGenerator.php index 165f8e0..1ce9220 100644 --- a/repo/includes/ClaimHtmlGenerator.php +++ b/repo/includes/ClaimHtmlGenerator.php @@ -121,7 +121,7 @@ * @return string */ protected function getHtmlForQualifiers( Snaks $qualifiers, array $entityInfo ) { - $qualifiersByProperty = new ByPropertyIdArray( $qualifiers ); + $qualifiersByProperty = new ByPropertyIdArray( iterator_to_array( $qualifiers ) ); $qualifiersByProperty->buildIndex(); $snaklistviewsHtml = ''; @@ -171,7 +171,9 @@ * @return string */ protected function getHtmlForReference( $reference, array $entityInfo ) { - $referenceSnaksByProperty = new ByPropertyIdArray( $reference->getSnaks() ); + $snaks = $reference->getSnaks(); + + $referenceSnaksByProperty = new ByPropertyIdArray( iterator_to_array( $snaks ) ); $referenceSnaksByProperty->buildIndex(); $snaklistviewsHtml = ''; -- To view, visit https://gerrit.wikimedia.org/r/164767 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia5e9e7d7f7010fd3a3faa73067d3075225cb91e5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits