mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-27 17:20:40 +00:00
Inject service RevisionStore into RevisionLocalCache
Change-Id: I4945d582138af4500f8c6929ca0c97d05f10377e
This commit is contained in:
parent
2dd93768c5
commit
98feb3f3fd
|
@ -96,7 +96,8 @@ return [
|
||||||
|
|
||||||
'EchoRevisionLocalCache' => static function ( MediaWikiServices $services ): RevisionLocalCache {
|
'EchoRevisionLocalCache' => static function ( MediaWikiServices $services ): RevisionLocalCache {
|
||||||
return new RevisionLocalCache(
|
return new RevisionLocalCache(
|
||||||
$services->getConnectionProvider()
|
$services->getConnectionProvider(),
|
||||||
|
$services->getRevisionStore()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace MediaWiki\Extension\Notifications\Cache;
|
namespace MediaWiki\Extension\Notifications\Cache;
|
||||||
|
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\Revision\RevisionStore;
|
||||||
use Wikimedia\Rdbms\IConnectionProvider;
|
use Wikimedia\Rdbms\IConnectionProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -11,22 +11,27 @@ use Wikimedia\Rdbms\IConnectionProvider;
|
||||||
*/
|
*/
|
||||||
class RevisionLocalCache extends LocalCache {
|
class RevisionLocalCache extends LocalCache {
|
||||||
private IConnectionProvider $dbProvider;
|
private IConnectionProvider $dbProvider;
|
||||||
|
private RevisionStore $revisionStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param IConnectionProvider $dbProvider
|
* @param IConnectionProvider $dbProvider
|
||||||
|
* @param RevisionStore $revisionStore
|
||||||
*/
|
*/
|
||||||
public function __construct( IConnectionProvider $dbProvider ) {
|
public function __construct(
|
||||||
|
IConnectionProvider $dbProvider,
|
||||||
|
RevisionStore $revisionStore
|
||||||
|
) {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->dbProvider = $dbProvider;
|
$this->dbProvider = $dbProvider;
|
||||||
|
$this->revisionStore = $revisionStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
protected function resolve( array $lookups ) {
|
protected function resolve( array $lookups ) {
|
||||||
$store = MediaWikiServices::getInstance()->getRevisionStore();
|
|
||||||
$dbr = $this->dbProvider->getReplicaDatabase();
|
$dbr = $this->dbProvider->getReplicaDatabase();
|
||||||
$revQuery = $store->getQueryInfo( [ 'page', 'user' ] );
|
$revQuery = $this->revisionStore->getQueryInfo( [ 'page', 'user' ] );
|
||||||
$res = $dbr->select(
|
$res = $dbr->select(
|
||||||
$revQuery['tables'],
|
$revQuery['tables'],
|
||||||
$revQuery['fields'],
|
$revQuery['fields'],
|
||||||
|
@ -36,7 +41,7 @@ class RevisionLocalCache extends LocalCache {
|
||||||
$revQuery['joins']
|
$revQuery['joins']
|
||||||
);
|
);
|
||||||
foreach ( $res as $row ) {
|
foreach ( $res as $row ) {
|
||||||
yield $row->rev_id => $store->newRevisionFromRow( $row );
|
yield $row->rev_id => $this->revisionStore->newRevisionFromRow( $row );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue