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
|
|
|
|
$dbr = wfGetDB( DB_SLAVE );
|
|
|
|
$fields = array_merge(
|
|
|
|
Revision::selectFields(),
|
|
|
|
Revision::selectPageFields(),
|
|
|
|
Revision::selectUserFields()
|
|
|
|
);
|
|
|
|
$res = $dbr->select(
|
2016-12-05 18:51:07 +00:00
|
|
|
[ 'revision', 'page', 'user' ],
|
2014-08-16 07:00:08 +00:00
|
|
|
$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
|
|
|
[],
|
|
|
|
[
|
2014-08-16 07:00:08 +00:00
|
|
|
'page' => Revision::pageJoinCond(),
|
|
|
|
'user' => Revision::userJoinCond()
|
2016-12-05 18:51:07 +00:00
|
|
|
]
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|