Inject service RevisionStore into RevisionLocalCache

Change-Id: I4945d582138af4500f8c6929ca0c97d05f10377e
This commit is contained in:
Fomafix 2024-03-17 20:10:34 +00:00
parent 2dd93768c5
commit 98feb3f3fd
2 changed files with 12 additions and 6 deletions

View file

@ -96,7 +96,8 @@ return [
'EchoRevisionLocalCache' => static function ( MediaWikiServices $services ): RevisionLocalCache {
return new RevisionLocalCache(
$services->getConnectionProvider()
$services->getConnectionProvider(),
$services->getRevisionStore()
);
}

View file

@ -2,7 +2,7 @@
namespace MediaWiki\Extension\Notifications\Cache;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionStore;
use Wikimedia\Rdbms\IConnectionProvider;
/**
@ -11,22 +11,27 @@ use Wikimedia\Rdbms\IConnectionProvider;
*/
class RevisionLocalCache extends LocalCache {
private IConnectionProvider $dbProvider;
private RevisionStore $revisionStore;
/**
* @param IConnectionProvider $dbProvider
* @param RevisionStore $revisionStore
*/
public function __construct( IConnectionProvider $dbProvider ) {
public function __construct(
IConnectionProvider $dbProvider,
RevisionStore $revisionStore
) {
parent::__construct();
$this->dbProvider = $dbProvider;
$this->revisionStore = $revisionStore;
}
/**
* @inheritDoc
*/
protected function resolve( array $lookups ) {
$store = MediaWikiServices::getInstance()->getRevisionStore();
$dbr = $this->dbProvider->getReplicaDatabase();
$revQuery = $store->getQueryInfo( [ 'page', 'user' ] );
$revQuery = $this->revisionStore->getQueryInfo( [ 'page', 'user' ] );
$res = $dbr->select(
$revQuery['tables'],
$revQuery['fields'],
@ -36,7 +41,7 @@ class RevisionLocalCache extends LocalCache {
$revQuery['joins']
);
foreach ( $res as $row ) {
yield $row->rev_id => $store->newRevisionFromRow( $row );
yield $row->rev_id => $this->revisionStore->newRevisionFromRow( $row );
}
}
}