mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-23 15:36:58 +00:00
Merge "Inject service RevisionStore into RevisionLocalCache"
This commit is contained in:
commit
fda5f7daa6
|
@ -99,7 +99,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