mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 00:13:36 +00:00
Switch from typehinting ILBFactory to IConnectionProvider
Narrower interface Change-Id: Id94d098089f1db645ea6b4b4eb516a512c66fdb2
This commit is contained in:
parent
8070feda05
commit
40c3c65ccf
|
@ -11,7 +11,7 @@ use ReadOnlyMode;
|
|||
use stdClass;
|
||||
use TitleValue;
|
||||
use Wikimedia\Rdbms\FakeResultWrapper;
|
||||
use Wikimedia\Rdbms\ILBFactory;
|
||||
use Wikimedia\Rdbms\IConnectionProvider;
|
||||
use Wikimedia\Rdbms\IReadableDatabase;
|
||||
use Wikimedia\Rdbms\IResultWrapper;
|
||||
|
||||
|
@ -25,18 +25,18 @@ class SubscriptionStore {
|
|||
public const STATE_AUTOSUBSCRIBED = 2;
|
||||
|
||||
private Config $config;
|
||||
private ILBFactory $lbFactory;
|
||||
private IConnectionProvider $dbProvider;
|
||||
private ReadOnlyMode $readOnlyMode;
|
||||
private UserFactory $userFactory;
|
||||
|
||||
public function __construct(
|
||||
ConfigFactory $configFactory,
|
||||
ILBFactory $lbFactory,
|
||||
IConnectionProvider $dbProvider,
|
||||
ReadOnlyMode $readOnlyMode,
|
||||
UserFactory $userFactory
|
||||
) {
|
||||
$this->config = $configFactory->makeConfig( 'discussiontools' );
|
||||
$this->lbFactory = $lbFactory;
|
||||
$this->dbProvider = $dbProvider;
|
||||
$this->readOnlyMode = $readOnlyMode;
|
||||
$this->userFactory = $userFactory;
|
||||
}
|
||||
|
@ -104,9 +104,9 @@ class SubscriptionStore {
|
|||
|
||||
$options += [ 'forWrite' => false ];
|
||||
if ( $options['forWrite'] ) {
|
||||
$db = $this->lbFactory->getPrimaryDatabase();
|
||||
$db = $this->dbProvider->getPrimaryDatabase();
|
||||
} else {
|
||||
$db = $this->lbFactory->getReplicaDatabase();
|
||||
$db = $this->dbProvider->getReplicaDatabase();
|
||||
}
|
||||
|
||||
$rows = $this->fetchSubscriptions(
|
||||
|
@ -142,9 +142,9 @@ class SubscriptionStore {
|
|||
): array {
|
||||
$options += [ 'forWrite' => false ];
|
||||
if ( $options['forWrite'] ) {
|
||||
$db = $this->lbFactory->getPrimaryDatabase();
|
||||
$db = $this->dbProvider->getPrimaryDatabase();
|
||||
} else {
|
||||
$db = $this->lbFactory->getReplicaDatabase();
|
||||
$db = $this->dbProvider->getReplicaDatabase();
|
||||
}
|
||||
|
||||
$rows = $this->fetchSubscriptions(
|
||||
|
@ -210,7 +210,7 @@ class SubscriptionStore {
|
|||
if ( !$user->isRegistered() ) {
|
||||
return false;
|
||||
}
|
||||
$dbw = $this->lbFactory->getPrimaryDatabase();
|
||||
$dbw = $this->dbProvider->getPrimaryDatabase();
|
||||
$dbw->upsert(
|
||||
'discussiontools_subscription',
|
||||
[
|
||||
|
@ -247,7 +247,7 @@ class SubscriptionStore {
|
|||
if ( !$user->isRegistered() ) {
|
||||
return false;
|
||||
}
|
||||
$dbw = $this->lbFactory->getPrimaryDatabase();
|
||||
$dbw = $this->dbProvider->getPrimaryDatabase();
|
||||
$dbw->update(
|
||||
'discussiontools_subscription',
|
||||
[ 'sub_state' => static::STATE_UNSUBSCRIBED ],
|
||||
|
@ -304,7 +304,7 @@ class SubscriptionStore {
|
|||
if ( $this->readOnlyMode->isReadOnly() ) {
|
||||
return false;
|
||||
}
|
||||
$dbw = $this->lbFactory->getPrimaryDatabase();
|
||||
$dbw = $this->dbProvider->getPrimaryDatabase();
|
||||
|
||||
$conditions = [
|
||||
'sub_item' => $itemName,
|
||||
|
|
|
@ -19,7 +19,7 @@ use ReadOnlyMode;
|
|||
use stdClass;
|
||||
use TitleFormatter;
|
||||
use Wikimedia\Rdbms\DBError;
|
||||
use Wikimedia\Rdbms\ILBFactory;
|
||||
use Wikimedia\Rdbms\IConnectionProvider;
|
||||
use Wikimedia\Rdbms\IResultWrapper;
|
||||
use Wikimedia\Rdbms\SelectQueryBuilder;
|
||||
use Wikimedia\Timestamp\TimestampException;
|
||||
|
@ -30,7 +30,7 @@ use Wikimedia\Timestamp\TimestampException;
|
|||
class ThreadItemStore {
|
||||
|
||||
private Config $config;
|
||||
private ILBFactory $dbConProvider;
|
||||
private IConnectionProvider $dbProvider;
|
||||
private ReadOnlyMode $readOnlyMode;
|
||||
private PageStore $pageStore;
|
||||
private RevisionStore $revStore;
|
||||
|
@ -39,7 +39,7 @@ class ThreadItemStore {
|
|||
|
||||
public function __construct(
|
||||
ConfigFactory $configFactory,
|
||||
ILBFactory $dbConProvider,
|
||||
IConnectionProvider $dbProvider,
|
||||
ReadOnlyMode $readOnlyMode,
|
||||
PageStore $pageStore,
|
||||
RevisionStore $revStore,
|
||||
|
@ -47,7 +47,7 @@ class ThreadItemStore {
|
|||
ActorStore $actorStore
|
||||
) {
|
||||
$this->config = $configFactory->makeConfig( 'discussiontools' );
|
||||
$this->dbConProvider = $dbConProvider;
|
||||
$this->dbProvider = $dbProvider;
|
||||
$this->readOnlyMode = $readOnlyMode;
|
||||
$this->pageStore = $pageStore;
|
||||
$this->revStore = $revStore;
|
||||
|
@ -204,10 +204,10 @@ class ThreadItemStore {
|
|||
foreach ( $result as $row ) {
|
||||
$revs[ $row->itr_revision_id ] = null;
|
||||
}
|
||||
$revQueryBuilder = $this->dbConProvider->getReplicaDatabase()->newSelectQueryBuilder()
|
||||
->queryInfo( $this->revStore->getQueryInfo( [ 'page' ] ) )
|
||||
->fields( $this->pageStore->getSelectFields() )
|
||||
->where( $revs ? [ 'rev_id' => array_keys( $revs ) ] : '0=1' );
|
||||
$revQueryBuilder = $this->dbProvider->getReplicaDatabase()->newSelectQueryBuilder()
|
||||
->queryInfo( $this->revStore->getQueryInfo( [ 'page' ] ) )
|
||||
->fields( $this->pageStore->getSelectFields() )
|
||||
->where( $revs ? [ 'rev_id' => array_keys( $revs ) ] : '0=1' );
|
||||
$revResult = $revQueryBuilder->fetchResultSet();
|
||||
foreach ( $revResult as $row ) {
|
||||
$revs[ $row->rev_id ] = $row;
|
||||
|
@ -323,7 +323,7 @@ class ThreadItemStore {
|
|||
* @return SelectQueryBuilder
|
||||
*/
|
||||
private function getIdsNamesBuilder(): SelectQueryBuilder {
|
||||
$dbr = $this->dbConProvider->getReplicaDatabase();
|
||||
$dbr = $this->dbProvider->getReplicaDatabase();
|
||||
|
||||
$queryBuilder = $dbr->newSelectQueryBuilder()
|
||||
->from( 'discussiontools_items' )
|
||||
|
@ -353,7 +353,7 @@ class ThreadItemStore {
|
|||
return false;
|
||||
}
|
||||
|
||||
$dbw = $this->dbConProvider->getPrimaryDatabase();
|
||||
$dbw = $this->dbProvider->getPrimaryDatabase();
|
||||
$didInsert = false;
|
||||
$method = __METHOD__;
|
||||
|
||||
|
|
Loading…
Reference in a new issue