makePageReferenceValue( $linkId ) ); } /** * Given an iterator over link IDs, remove links which go to the same * title, leaving only one link per title. * * @param iterable $linkIds * @return iterable */ abstract protected function deduplicateLinkIds( $linkIds ); /** * Get link IDs for a given set type, filtering out duplicate links to the * same title. * * @param int $setType * @return iterable */ protected function getDeduplicatedLinkIds( $setType ) { $linkIds = $this->getLinkIDs( $setType ); // Only the CHANGED set type should have duplicates if ( $setType === self::CHANGED ) { $linkIds = $this->deduplicateLinkIds( $linkIds ); } return $linkIds; } /** * Get a link set as an array of Title objects. This is memory-inefficient. * * @deprecated since 1.38, hard-deprecated since 1.43 * @param int $setType * @return Title[] */ public function getTitleArray( $setType ) { wfDeprecated( __METHOD__, '1.43' ); $linkIds = $this->getDeduplicatedLinkIds( $setType ); $titles = []; foreach ( $linkIds as $linkId ) { $titles[] = $this->makeTitle( $linkId ); } return $titles; } /** * Get a link set as an iterator over PageReferenceValue objects. * * @param int $setType * @return iterable * @phan-return \Traversable */ public function getPageReferenceIterator( $setType ) { $linkIds = $this->getDeduplicatedLinkIds( $setType ); foreach ( $linkIds as $linkId ) { yield $this->makePageReferenceValue( $linkId ); } } }