Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
RevisionLocalCache | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
resolve | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\Notifications\Cache; |
4 | |
5 | use MediaWiki\Revision\RevisionStore; |
6 | use Wikimedia\Rdbms\IConnectionProvider; |
7 | |
8 | /** |
9 | * Cache class that maps revision id to RevisionStore object |
10 | * @xxx Like TitleLocalCache, this class shouldn't need to exist. |
11 | */ |
12 | class RevisionLocalCache extends LocalCache { |
13 | private IConnectionProvider $dbProvider; |
14 | private RevisionStore $revisionStore; |
15 | |
16 | /** |
17 | * @param IConnectionProvider $dbProvider |
18 | * @param RevisionStore $revisionStore |
19 | */ |
20 | public function __construct( |
21 | IConnectionProvider $dbProvider, |
22 | RevisionStore $revisionStore |
23 | ) { |
24 | parent::__construct(); |
25 | $this->dbProvider = $dbProvider; |
26 | $this->revisionStore = $revisionStore; |
27 | } |
28 | |
29 | /** |
30 | * @inheritDoc |
31 | */ |
32 | protected function resolve( array $lookups ) { |
33 | $dbr = $this->dbProvider->getReplicaDatabase(); |
34 | $revQuery = $this->revisionStore->getQueryInfo( [ 'page', 'user' ] ); |
35 | $res = $dbr->newSelectQueryBuilder() |
36 | ->queryInfo( $revQuery ) |
37 | ->where( [ 'rev_id' => $lookups ] ) |
38 | ->caller( __METHOD__ ) |
39 | ->fetchResultSet(); |
40 | foreach ( $res as $row ) { |
41 | yield $row->rev_id => $this->revisionStore->newRevisionFromRow( $row ); |
42 | } |
43 | } |
44 | } |