jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/390414 )
Change subject: Reduce duplicate code in AffectedPagesFinder ...................................................................... Reduce duplicate code in AffectedPagesFinder This is a direct follow up fixing the minor issues I had with Ib5d212a, and should be considered part of that. Bug: T176417 Change-Id: Id74f5839c03d0168396d7db39165d9cde023fa82 --- M client/includes/Changes/AffectedPagesFinder.php 1 file changed, 13 insertions(+), 36 deletions(-) Approvals: WMDE-leszek: Looks good to me, approved jenkins-bot: Verified Thiemo Mättig (WMDE): Looks good to me, but someone else must approve diff --git a/client/includes/Changes/AffectedPagesFinder.php b/client/includes/Changes/AffectedPagesFinder.php index fe66f77..91d2440 100644 --- a/client/includes/Changes/AffectedPagesFinder.php +++ b/client/includes/Changes/AffectedPagesFinder.php @@ -152,25 +152,23 @@ } } - if ( $diff instanceof EntityDiff && !$diff->getLabelsDiff()->isEmpty() ) { + if ( $diff instanceof EntityDiff ) { $labelsDiff = $diff->getLabelsDiff(); + $descriptionsDiff = $diff->getDescriptionsDiff(); - if ( !empty( $labelsDiff ) ) { - $labelAspects = $this->getChangedLabelAspects( $labelsDiff ); + if ( !$labelsDiff->isEmpty() ) { + $labelAspects = $this->getChangedTermAspects( EntityUsage::LABEL_USAGE, $labelsDiff ); $aspects = array_merge( $aspects, $labelAspects ); $remainingDiffOps -= count( $labelAspects ); } - } - if ( $diff instanceof EntityDiff && !$diff->getDescriptionsDiff()->isEmpty() ) { - $descriptionsDiff = $diff->getDescriptionsDiff(); - - if ( !empty( $descriptionsDiff ) ) { - $descriptionsAspects = $this->getChangedDescriptionAspects( $descriptionsDiff ); + if ( !$descriptionsDiff->isEmpty() ) { + $descriptionsAspects = $this->getChangedTermAspects( EntityUsage::DESCRIPTION_USAGE, $descriptionsDiff ); $aspects = array_merge( $aspects, $descriptionsAspects ); $remainingDiffOps -= count( $descriptionsAspects ); } } + // FIXME: EntityChange suppresses various kinds of diffs (see above). T113468. if ( $remainingDiffOps > 0 ) { @@ -181,44 +179,23 @@ } /** - * @param Diff $labelsDiff + * @param string $aspect + * @param Diff $diff * * @return string[] */ - private function getChangedLabelAspects( Diff $labelsDiff ) { + private function getChangedTermAspects( $aspect, Diff $diff ) { $aspects = []; - foreach ( $labelsDiff as $lang => $diffOp ) { - $aspects[] = EntityUsage::makeAspectKey( EntityUsage::LABEL_USAGE, $lang ); + foreach ( $diff as $lang => $diffOp ) { + $aspects[] = EntityUsage::makeAspectKey( $aspect, $lang ); } if ( $this->trackUsagesInAllLanguages ) { // On multi-lingual wikis where users can request pages in any language, we can not // optimize for one language fallback chain only. Since all possible language fallback // chains must cover all languages, we can simply track an "all languages" usage. - $aspects[] = EntityUsage::makeAspectKey( EntityUsage::LABEL_USAGE ); - } - - return $aspects; - } - - /** - * @param Diff $descriptionsDiff - * - * @return string[] - */ - private function getChangedDescriptionAspects( Diff $descriptionsDiff ) { - $aspects = []; - - foreach ( $descriptionsDiff as $lang => $diffOp ) { - $aspects[] = EntityUsage::makeAspectKey( EntityUsage::DESCRIPTION_USAGE, $lang ); - } - - if ( $this->trackUsagesInAllLanguages ) { - // On multi-lingual wikis where users can request pages in any language, we can not - // optimize for one language fallback chain only. Since all possible language fallback - // chains must cover all languages, we can simply track an "all languages" usage. - $aspects[] = EntityUsage::makeAspectKey( EntityUsage::DESCRIPTION_USAGE ); + $aspects[] = EntityUsage::makeAspectKey( $aspect ); } return $aspects; -- To view, visit https://gerrit.wikimedia.org/r/390414 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id74f5839c03d0168396d7db39165d9cde023fa82 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.kr...@wikimedia.de> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.kr...@wikimedia.de> Gerrit-Reviewer: WMDE-leszek <leszek.mani...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits