mediawiki-extensions-Echo/includes/cache/RevisionLocalCache.php
James D. Forrester 8c810dff48 build: Update mediawiki/mediawiki-codesniffer to 0.7.1
Also added "composer fix" command.

Change-Id: I25cb61b3b92798f1259d1575a336e2b056d5764f
2016-12-05 15:54:30 -08:00

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_SLAVE );
$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 = [];
}
}
}
}