Change-Id: I3dfe959d057d59a7d01c74a8f701cda0110dad2f
* @throws MWException
*/
private function getConnection() {
* @throws MWException
*/
private function getConnection() {
- return $this->loadBalancer->getConnection( DB_REPLICA, [ 'watchlist' ] );
- }
-
- /**
- * @param Database $connection
- * @throws MWException
- */
- private function reuseConnection( Database $connection ) {
- $this->loadBalancer->reuseConnection( $connection );
+ return $this->loadBalancer->getConnectionRef( DB_REPLICA, [ 'watchlist' ] );
- $this->reuseConnection( $db );
-
$items = [];
foreach ( $res as $row ) {
$items[] = [
$items = [];
foreach ( $res as $row ) {
$items[] = [
- $this->reuseConnection( $db );
-
$watchedItems = [];
foreach ( $res as $row ) {
// todo these could all be cached at some point?
$watchedItems = [];
foreach ( $res as $row ) {
// todo these could all be cached at some point?
}
private function getWatchedItemsWithRCInfoQueryConds(
}
private function getWatchedItemsWithRCInfoQueryConds(
User $user,
array $options
) {
User $user,
array $options
) {
- private function getStartEndConds( Database $db, array $options ) {
+ private function getStartEndConds( IDatabase $db, array $options ) {
if ( !isset( $options['start'] ) && ! isset( $options['end'] ) ) {
return [];
}
if ( !isset( $options['start'] ) && ! isset( $options['end'] ) ) {
return [];
}
- private function getUserRelatedConds( Database $db, User $user, array $options ) {
+ private function getUserRelatedConds( IDatabase $db, User $user, array $options ) {
if ( !array_key_exists( 'onlyByUser', $options ) && !array_key_exists( 'notByUser', $options ) ) {
return [];
}
if ( !array_key_exists( 'onlyByUser', $options ) && !array_key_exists( 'notByUser', $options ) ) {
return [];
}
- private function getExtraDeletedPageLogEntryRelatedCond( Database $db, User $user ) {
+ private function getExtraDeletedPageLogEntryRelatedCond( IDatabase $db, User $user ) {
// LogPage::DELETED_ACTION hides the affected page, too. So hide those
// entirely from the watchlist, or someone could guess the title.
$bitmask = 0;
// LogPage::DELETED_ACTION hides the affected page, too. So hide those
// entirely from the watchlist, or someone could guess the title.
$bitmask = 0;
- private function getStartFromConds( Database $db, array $options ) {
+ private function getStartFromConds( IDatabase $db, array $options ) {
$op = $options['dir'] === self::DIR_OLDER ? '<' : '>';
list( $rcTimestamp, $rcId ) = $options['startFrom'];
$rcTimestamp = $db->addQuotes( $db->timestamp( $rcTimestamp ) );
$op = $options['dir'] === self::DIR_OLDER ? '<' : '>';
list( $rcTimestamp, $rcId ) = $options['startFrom'];
$rcTimestamp = $db->addQuotes( $db->timestamp( $rcTimestamp ) );
- private function getWatchedItemsForUserQueryConds( Database $db, User $user, array $options ) {
+ private function getWatchedItemsForUserQueryConds( IDatabase $db, User $user, array $options ) {
$conds = [ 'wl_user' => $user->getId() ];
if ( $options['namespaceIds'] ) {
$conds['wl_namespace'] = array_map( 'intval', $options['namespaceIds'] );
$conds = [ 'wl_user' => $user->getId() ];
if ( $options['namespaceIds'] ) {
$conds['wl_namespace'] = array_map( 'intval', $options['namespaceIds'] );
* Creates a query condition part for getting only items before or after the given link target
* (while ordering using $sort mode)
*
* Creates a query condition part for getting only items before or after the given link target
* (while ordering using $sort mode)
*
* @param LinkTarget $target
* @param string $op comparison operator to use in the conditions
* @return string
*/
* @param LinkTarget $target
* @param string $op comparison operator to use in the conditions
* @return string
*/
- private function getFromUntilTargetConds( Database $db, LinkTarget $target, $op ) {
+ private function getFromUntilTargetConds( IDatabase $db, LinkTarget $target, $op ) {
return $db->makeList(
[
"wl_namespace $op " . $target->getNamespace(),
return $db->makeList(
[
"wl_namespace $op " . $target->getNamespace(),
->disableOriginalConstructor()
->getMock();
$mock->expects( $this->any() )
->disableOriginalConstructor()
->getMock();
$mock->expects( $this->any() )
- ->method( 'getConnection' )
+ ->method( 'getConnectionRef' )
->with( DB_SLAVE )
->will( $this->returnValue( $mockDb ) );
return $mock;
->with( DB_SLAVE )
->will( $this->returnValue( $mockDb ) );
return $mock;