| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Deferred\LinksUpdate; |
| 4 |
|
| 5 |
use MediaWiki\Page\PageReferenceValue; |
| 6 |
use MediaWiki\Title\Title; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
abstract class TitleLinksTable extends LinksTable { |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
abstract protected function makePageReferenceValue( $linkId ): PageReferenceValue; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
protected function makeTitle( $linkId ): Title { |
| 31 |
return Title::newFromPageReference( $this->makePageReferenceValue( $linkId ) ); |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
abstract protected function deduplicateLinkIds( $linkIds ); |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
protected function getDeduplicatedLinkIds( $setType ) { |
| 51 |
$linkIds = $this->getLinkIDs( $setType ); |
| 52 |
|
| 53 |
if ( $setType === self::CHANGED ) { |
| 54 |
$linkIds = $this->deduplicateLinkIds( $linkIds ); |
| 55 |
} |
| 56 |
return $linkIds; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
public function getTitleArray( $setType ) { |
| 67 |
wfDeprecated( __METHOD__, '1.43' ); |
| 68 |
$linkIds = $this->getDeduplicatedLinkIds( $setType ); |
| 69 |
$titles = []; |
| 70 |
foreach ( $linkIds as $linkId ) { |
| 71 |
$titles[] = $this->makeTitle( $linkId ); |
| 72 |
} |
| 73 |
return $titles; |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
public function getPageReferenceIterator( $setType ) { |
| 84 |
$linkIds = $this->getDeduplicatedLinkIds( $setType ); |
| 85 |
foreach ( $linkIds as $linkId ) { |
| 86 |
yield $this->makePageReferenceValue( $linkId ); |
| 87 |
} |
| 88 |
} |
| 89 |
} |