Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
25.00% |
3 / 12 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
TitleLocalCache | |
25.00% |
3 / 12 |
|
50.00% |
1 / 2 |
10.75 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
resolve | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\Notifications\Cache; |
4 | |
5 | use MediaWiki\Page\PageRecord; |
6 | use MediaWiki\Page\PageStore; |
7 | use MediaWiki\Title\TitleFactory; |
8 | |
9 | /** |
10 | * Cache class that maps article id to Title object. |
11 | * @fixme There should be no need for this class. Core's PageStore should be responsible for caching, if it's |
12 | * deemed necessary. See also T344124. |
13 | */ |
14 | class TitleLocalCache extends LocalCache { |
15 | private PageStore $pageStore; |
16 | private TitleFactory $titleFactory; |
17 | |
18 | /** |
19 | * @param PageStore $pageStore |
20 | * @param TitleFactory $titleFactory |
21 | */ |
22 | public function __construct( |
23 | PageStore $pageStore, |
24 | TitleFactory $titleFactory |
25 | ) { |
26 | parent::__construct(); |
27 | $this->pageStore = $pageStore; |
28 | $this->titleFactory = $titleFactory; |
29 | } |
30 | |
31 | /** |
32 | * @inheritDoc |
33 | */ |
34 | protected function resolve( array $lookups ) { |
35 | if ( $lookups ) { |
36 | $titles = $this->pageStore |
37 | ->newSelectQueryBuilder() |
38 | ->wherePageIds( $lookups ) |
39 | ->caller( __METHOD__ ) |
40 | ->fetchPageRecords(); |
41 | |
42 | /** @var PageRecord $title */ |
43 | foreach ( $titles as $title ) { |
44 | $title = $this->titleFactory->castFromPageIdentity( $title ); |
45 | yield $title->getArticleID() => $title; |
46 | } |
47 | } |
48 | } |
49 | |
50 | } |