Merge "Inject service RevisionStore into RevisionLocalCache"

This commit is contained in:
jenkins-bot 2024-03-18 09:06:16 +00:00 committed by Gerrit Code Review
commit fda5f7daa6
2 changed files with 12 additions and 6 deletions

View file

@ -99,7 +99,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 );
}
}
}