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 stdClass;
|
||||||
use TitleValue;
|
use TitleValue;
|
||||||
use Wikimedia\Rdbms\FakeResultWrapper;
|
use Wikimedia\Rdbms\FakeResultWrapper;
|
||||||
use Wikimedia\Rdbms\ILBFactory;
|
use Wikimedia\Rdbms\IConnectionProvider;
|
||||||
use Wikimedia\Rdbms\IReadableDatabase;
|
use Wikimedia\Rdbms\IReadableDatabase;
|
||||||
use Wikimedia\Rdbms\IResultWrapper;
|
use Wikimedia\Rdbms\IResultWrapper;
|
||||||
|
|
||||||
|
@ -25,18 +25,18 @@ class SubscriptionStore {
|
||||||
public const STATE_AUTOSUBSCRIBED = 2;
|
public const STATE_AUTOSUBSCRIBED = 2;
|
||||||
|
|
||||||
private Config $config;
|
private Config $config;
|
||||||
private ILBFactory $lbFactory;
|
private IConnectionProvider $dbProvider;
|
||||||
private ReadOnlyMode $readOnlyMode;
|
private ReadOnlyMode $readOnlyMode;
|
||||||
private UserFactory $userFactory;
|
private UserFactory $userFactory;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ConfigFactory $configFactory,
|
ConfigFactory $configFactory,
|
||||||
ILBFactory $lbFactory,
|
IConnectionProvider $dbProvider,
|
||||||
ReadOnlyMode $readOnlyMode,
|
ReadOnlyMode $readOnlyMode,
|
||||||
UserFactory $userFactory
|
UserFactory $userFactory
|
||||||
) {
|
) {
|
||||||
$this->config = $configFactory->makeConfig( 'discussiontools' );
|
$this->config = $configFactory->makeConfig( 'discussiontools' );
|
||||||
$this->lbFactory = $lbFactory;
|
$this->dbProvider = $dbProvider;
|
||||||
$this->readOnlyMode = $readOnlyMode;
|
$this->readOnlyMode = $readOnlyMode;
|
||||||
$this->userFactory = $userFactory;
|
$this->userFactory = $userFactory;
|
||||||
}
|
}
|
||||||
|
@ -104,9 +104,9 @@ class SubscriptionStore {
|
||||||
|
|
||||||
$options += [ 'forWrite' => false ];
|
$options += [ 'forWrite' => false ];
|
||||||
if ( $options['forWrite'] ) {
|
if ( $options['forWrite'] ) {
|
||||||
$db = $this->lbFactory->getPrimaryDatabase();
|
$db = $this->dbProvider->getPrimaryDatabase();
|
||||||
} else {
|
} else {
|
||||||
$db = $this->lbFactory->getReplicaDatabase();
|
$db = $this->dbProvider->getReplicaDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = $this->fetchSubscriptions(
|
$rows = $this->fetchSubscriptions(
|
||||||
|
@ -142,9 +142,9 @@ class SubscriptionStore {
|
||||||
): array {
|
): array {
|
||||||
$options += [ 'forWrite' => false ];
|
$options += [ 'forWrite' => false ];
|
||||||
if ( $options['forWrite'] ) {
|
if ( $options['forWrite'] ) {
|
||||||
$db = $this->lbFactory->getPrimaryDatabase();
|
$db = $this->dbProvider->getPrimaryDatabase();
|
||||||
} else {
|
} else {
|
||||||
$db = $this->lbFactory->getReplicaDatabase();
|
$db = $this->dbProvider->getReplicaDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = $this->fetchSubscriptions(
|
$rows = $this->fetchSubscriptions(
|
||||||
|
@ -210,7 +210,7 @@ class SubscriptionStore {
|
||||||
if ( !$user->isRegistered() ) {
|
if ( !$user->isRegistered() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$dbw = $this->lbFactory->getPrimaryDatabase();
|
$dbw = $this->dbProvider->getPrimaryDatabase();
|
||||||
$dbw->upsert(
|
$dbw->upsert(
|
||||||
'discussiontools_subscription',
|
'discussiontools_subscription',
|
||||||
[
|
[
|
||||||
|
@ -247,7 +247,7 @@ class SubscriptionStore {
|
||||||
if ( !$user->isRegistered() ) {
|
if ( !$user->isRegistered() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$dbw = $this->lbFactory->getPrimaryDatabase();
|
$dbw = $this->dbProvider->getPrimaryDatabase();
|
||||||
$dbw->update(
|
$dbw->update(
|
||||||
'discussiontools_subscription',
|
'discussiontools_subscription',
|
||||||
[ 'sub_state' => static::STATE_UNSUBSCRIBED ],
|
[ 'sub_state' => static::STATE_UNSUBSCRIBED ],
|
||||||
|
@ -304,7 +304,7 @@ class SubscriptionStore {
|
||||||
if ( $this->readOnlyMode->isReadOnly() ) {
|
if ( $this->readOnlyMode->isReadOnly() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$dbw = $this->lbFactory->getPrimaryDatabase();
|
$dbw = $this->dbProvider->getPrimaryDatabase();
|
||||||
|
|
||||||
$conditions = [
|
$conditions = [
|
||||||
'sub_item' => $itemName,
|
'sub_item' => $itemName,
|
||||||
|
|
|
@ -19,7 +19,7 @@ use ReadOnlyMode;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
use TitleFormatter;
|
use TitleFormatter;
|
||||||
use Wikimedia\Rdbms\DBError;
|
use Wikimedia\Rdbms\DBError;
|
||||||
use Wikimedia\Rdbms\ILBFactory;
|
use Wikimedia\Rdbms\IConnectionProvider;
|
||||||
use Wikimedia\Rdbms\IResultWrapper;
|
use Wikimedia\Rdbms\IResultWrapper;
|
||||||
use Wikimedia\Rdbms\SelectQueryBuilder;
|
use Wikimedia\Rdbms\SelectQueryBuilder;
|
||||||
use Wikimedia\Timestamp\TimestampException;
|
use Wikimedia\Timestamp\TimestampException;
|
||||||
|
@ -30,7 +30,7 @@ use Wikimedia\Timestamp\TimestampException;
|
||||||
class ThreadItemStore {
|
class ThreadItemStore {
|
||||||
|
|
||||||
private Config $config;
|
private Config $config;
|
||||||
private ILBFactory $dbConProvider;
|
private IConnectionProvider $dbProvider;
|
||||||
private ReadOnlyMode $readOnlyMode;
|
private ReadOnlyMode $readOnlyMode;
|
||||||
private PageStore $pageStore;
|
private PageStore $pageStore;
|
||||||
private RevisionStore $revStore;
|
private RevisionStore $revStore;
|
||||||
|
@ -39,7 +39,7 @@ class ThreadItemStore {
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ConfigFactory $configFactory,
|
ConfigFactory $configFactory,
|
||||||
ILBFactory $dbConProvider,
|
IConnectionProvider $dbProvider,
|
||||||
ReadOnlyMode $readOnlyMode,
|
ReadOnlyMode $readOnlyMode,
|
||||||
PageStore $pageStore,
|
PageStore $pageStore,
|
||||||
RevisionStore $revStore,
|
RevisionStore $revStore,
|
||||||
|
@ -47,7 +47,7 @@ class ThreadItemStore {
|
||||||
ActorStore $actorStore
|
ActorStore $actorStore
|
||||||
) {
|
) {
|
||||||
$this->config = $configFactory->makeConfig( 'discussiontools' );
|
$this->config = $configFactory->makeConfig( 'discussiontools' );
|
||||||
$this->dbConProvider = $dbConProvider;
|
$this->dbProvider = $dbProvider;
|
||||||
$this->readOnlyMode = $readOnlyMode;
|
$this->readOnlyMode = $readOnlyMode;
|
||||||
$this->pageStore = $pageStore;
|
$this->pageStore = $pageStore;
|
||||||
$this->revStore = $revStore;
|
$this->revStore = $revStore;
|
||||||
|
@ -204,10 +204,10 @@ class ThreadItemStore {
|
||||||
foreach ( $result as $row ) {
|
foreach ( $result as $row ) {
|
||||||
$revs[ $row->itr_revision_id ] = null;
|
$revs[ $row->itr_revision_id ] = null;
|
||||||
}
|
}
|
||||||
$revQueryBuilder = $this->dbConProvider->getReplicaDatabase()->newSelectQueryBuilder()
|
$revQueryBuilder = $this->dbProvider->getReplicaDatabase()->newSelectQueryBuilder()
|
||||||
->queryInfo( $this->revStore->getQueryInfo( [ 'page' ] ) )
|
->queryInfo( $this->revStore->getQueryInfo( [ 'page' ] ) )
|
||||||
->fields( $this->pageStore->getSelectFields() )
|
->fields( $this->pageStore->getSelectFields() )
|
||||||
->where( $revs ? [ 'rev_id' => array_keys( $revs ) ] : '0=1' );
|
->where( $revs ? [ 'rev_id' => array_keys( $revs ) ] : '0=1' );
|
||||||
$revResult = $revQueryBuilder->fetchResultSet();
|
$revResult = $revQueryBuilder->fetchResultSet();
|
||||||
foreach ( $revResult as $row ) {
|
foreach ( $revResult as $row ) {
|
||||||
$revs[ $row->rev_id ] = $row;
|
$revs[ $row->rev_id ] = $row;
|
||||||
|
@ -323,7 +323,7 @@ class ThreadItemStore {
|
||||||
* @return SelectQueryBuilder
|
* @return SelectQueryBuilder
|
||||||
*/
|
*/
|
||||||
private function getIdsNamesBuilder(): SelectQueryBuilder {
|
private function getIdsNamesBuilder(): SelectQueryBuilder {
|
||||||
$dbr = $this->dbConProvider->getReplicaDatabase();
|
$dbr = $this->dbProvider->getReplicaDatabase();
|
||||||
|
|
||||||
$queryBuilder = $dbr->newSelectQueryBuilder()
|
$queryBuilder = $dbr->newSelectQueryBuilder()
|
||||||
->from( 'discussiontools_items' )
|
->from( 'discussiontools_items' )
|
||||||
|
@ -353,7 +353,7 @@ class ThreadItemStore {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbw = $this->dbConProvider->getPrimaryDatabase();
|
$dbw = $this->dbProvider->getPrimaryDatabase();
|
||||||
$didInsert = false;
|
$didInsert = false;
|
||||||
$method = __METHOD__;
|
$method = __METHOD__;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue