2014-08-16 07:00:08 +00:00
|
|
|
<?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();
|
|
|
|
}
|
2015-10-01 13:48:52 +00:00
|
|
|
|
2014-08-16 07:00:08 +00:00
|
|
|
return self::$instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-08-09 15:20:55 +00:00
|
|
|
* @inheritDoc
|
2014-08-16 07:00:08 +00:00
|
|
|
*/
|
|
|
|
protected function resolve() {
|
|
|
|
if ( $this->lookups ) {
|
|
|
|
// @Todo Add newFromIds() to Revision
|
2017-09-24 05:23:47 +00:00
|
|
|
$dbr = wfGetDB( DB_REPLICA );
|
2017-10-12 19:45:53 +00:00
|
|
|
$revQuery = Revision::getQueryInfo( [ 'page', 'user' ] );
|
2014-08-16 07:00:08 +00:00
|
|
|
$res = $dbr->select(
|
2017-10-12 19:45:53 +00:00
|
|
|
$revQuery['tables'],
|
|
|
|
$revQuery['fields'],
|
2016-12-05 18:51:07 +00:00
|
|
|
[ 'rev_id' => $this->lookups ],
|
2014-08-16 07:00:08 +00:00
|
|
|
__METHOD__,
|
2016-12-05 18:51:07 +00:00
|
|
|
[],
|
2017-10-12 19:45:53 +00:00
|
|
|
$revQuery['joins']
|
2014-08-16 07:00:08 +00:00
|
|
|
);
|
|
|
|
if ( $res ) {
|
|
|
|
foreach ( $res as $row ) {
|
|
|
|
$this->targets->set( $row->rev_id, new Revision( $row ) );
|
|
|
|
}
|
2016-12-05 18:51:07 +00:00
|
|
|
$this->lookups = [];
|
2014-08-16 07:00:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|