mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-12 16:05:33 +00:00
7a23ddf4b0
Change-Id: I7b19fab3b1100c4973600ec95ee24160e141c5ac
58 lines
1.1 KiB
PHP
58 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Cache class that maps revision id to Revision object
|
|
*/
|
|
class EchoRevisionLocalCache extends EchoLocalCache {
|
|
|
|
/**
|
|
* @var EchoRevisionLocalCache
|
|
*/
|
|
private static $instance;
|
|
|
|
/**
|
|
* Create a EchoRevisionLocalCache object
|
|
* @return EchoRevisionLocalCache
|
|
*/
|
|
public static function create() {
|
|
if ( !self::$instance ) {
|
|
self::$instance = new EchoRevisionLocalCache();
|
|
}
|
|
|
|
return self::$instance;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
protected function resolve() {
|
|
if ( $this->lookups ) {
|
|
// @Todo Add newFromIds() to Revision
|
|
$dbr = wfGetDB( DB_REPLICA );
|
|
$fields = array_merge(
|
|
Revision::selectFields(),
|
|
Revision::selectPageFields(),
|
|
Revision::selectUserFields()
|
|
);
|
|
$res = $dbr->select(
|
|
[ 'revision', 'page', 'user' ],
|
|
$fields,
|
|
[ 'rev_id' => $this->lookups ],
|
|
__METHOD__,
|
|
[],
|
|
[
|
|
'page' => Revision::pageJoinCond(),
|
|
'user' => Revision::userJoinCond()
|
|
]
|
|
);
|
|
if ( $res ) {
|
|
foreach ( $res as $row ) {
|
|
$this->targets->set( $row->rev_id, new Revision( $row ) );
|
|
}
|
|
$this->lookups = [];
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|