3 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface
;
4 use MediaWiki\Linker\LinkTarget
;
5 use Wikimedia\Assert\Assert
;
8 * Storage layer class for WatchedItems.
9 * Database interaction.
15 class WatchedItemStore
implements StatsdAwareInterface
{
17 const SORT_DESC
= 'DESC';
18 const SORT_ASC
= 'ASC';
23 private $loadBalancer;
31 * @var array[] Looks like $cacheIndex[Namespace ID][Target DB Key][User Id] => 'key'
32 * The index is needed so that on mass changes all relevant items can be un-cached.
33 * For example: Clearing a users watchlist of all items or updating notification timestamps
34 * for all users watching a single target.
36 private $cacheIndex = [];
41 private $deferredUpdatesAddCallableUpdateCallback;
46 private $revisionGetTimestampFromIdCallback;
49 * @var StatsdDataFactoryInterface
56 private static $instance;
59 * @param LoadBalancer $loadBalancer
60 * @param HashBagOStuff $cache
62 public function __construct(
63 LoadBalancer
$loadBalancer,
66 $this->loadBalancer
= $loadBalancer;
67 $this->cache
= $cache;
68 $this->stats
= new NullStatsdDataFactory();
69 $this->deferredUpdatesAddCallableUpdateCallback
= [ 'DeferredUpdates', 'addCallableUpdate' ];
70 $this->revisionGetTimestampFromIdCallback
= [ 'Revision', 'getTimestampFromId' ];
73 public function setStatsdDataFactory( StatsdDataFactoryInterface
$stats ) {
74 $this->stats
= $stats;
78 * Overrides the DeferredUpdates::addCallableUpdate callback
79 * This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
81 * @param callable $callback
83 * @see DeferredUpdates::addCallableUpdate for callback signiture
85 * @return ScopedCallback to reset the overridden value
88 public function overrideDeferredUpdatesAddCallableUpdateCallback( $callback ) {
89 if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
90 throw new MWException(
91 'Cannot override DeferredUpdates::addCallableUpdate callback in operation.'
94 Assert
::parameterType( 'callable', $callback, '$callback' );
96 $previousValue = $this->deferredUpdatesAddCallableUpdateCallback
;
97 $this->deferredUpdatesAddCallableUpdateCallback
= $callback;
98 return new ScopedCallback( function() use ( $previousValue ) {
99 $this->deferredUpdatesAddCallableUpdateCallback
= $previousValue;
104 * Overrides the Revision::getTimestampFromId callback
105 * This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
107 * @param callable $callback
108 * @see Revision::getTimestampFromId for callback signiture
110 * @return ScopedCallback to reset the overridden value
111 * @throws MWException
113 public function overrideRevisionGetTimestampFromIdCallback( $callback ) {
114 if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
115 throw new MWException(
116 'Cannot override Revision::getTimestampFromId callback in operation.'
119 Assert
::parameterType( 'callable', $callback, '$callback' );
121 $previousValue = $this->revisionGetTimestampFromIdCallback
;
122 $this->revisionGetTimestampFromIdCallback
= $callback;
123 return new ScopedCallback( function() use ( $previousValue ) {
124 $this->revisionGetTimestampFromIdCallback
= $previousValue;
129 * Overrides the default instance of this class
130 * This is intended for use while testing and will fail if MW_PHPUNIT_TEST is not defined.
132 * If this method is used it MUST also be called with null after a test to ensure a new
133 * default instance is created next time getDefaultInstance is called.
135 * @param WatchedItemStore|null $store
137 * @return ScopedCallback to reset the overridden value
138 * @throws MWException
140 public static function overrideDefaultInstance( WatchedItemStore
$store = null ) {
141 if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
142 throw new MWException(
143 'Cannot override ' . __CLASS__
. 'default instance in operation.'
147 $previousValue = self
::$instance;
148 self
::$instance = $store;
149 return new ScopedCallback( function() use ( $previousValue ) {
150 self
::$instance = $previousValue;
157 public static function getDefaultInstance() {
158 if ( !self
::$instance ) {
159 self
::$instance = new self(
161 new HashBagOStuff( [ 'maxKeys' => 100 ] )
163 self
::$instance->setStatsdDataFactory( RequestContext
::getMain()->getStats() );
165 return self
::$instance;
168 private function getCacheKey( User
$user, LinkTarget
$target ) {
169 return $this->cache
->makeKey(
170 (string)$target->getNamespace(),
172 (string)$user->getId()
176 private function cache( WatchedItem
$item ) {
177 $user = $item->getUser();
178 $target = $item->getLinkTarget();
179 $key = $this->getCacheKey( $user, $target );
180 $this->cache
->set( $key, $item );
181 $this->cacheIndex
[$target->getNamespace()][$target->getDBkey()][$user->getId()] = $key;
182 $this->stats
->increment( 'WatchedItemStore.cache' );
185 private function uncache( User
$user, LinkTarget
$target ) {
186 $this->cache
->delete( $this->getCacheKey( $user, $target ) );
187 unset( $this->cacheIndex
[$target->getNamespace()][$target->getDBkey()][$user->getId()] );
188 $this->stats
->increment( 'WatchedItemStore.uncache' );
191 private function uncacheLinkTarget( LinkTarget
$target ) {
192 if ( !isset( $this->cacheIndex
[$target->getNamespace()][$target->getDBkey()] ) ) {
195 $this->stats
->increment( 'WatchedItemStore.uncacheLinkTarget' );
196 foreach ( $this->cacheIndex
[$target->getNamespace()][$target->getDBkey()] as $key ) {
197 $this->stats
->increment( 'WatchedItemStore.uncacheLinkTarget.items' );
198 $this->cache
->delete( $key );
204 * @param LinkTarget $target
206 * @return WatchedItem|null
208 private function getCached( User
$user, LinkTarget
$target ) {
209 return $this->cache
->get( $this->getCacheKey( $user, $target ) );
213 * Return an array of conditions to select or update the appropriate database
217 * @param LinkTarget $target
221 private function dbCond( User
$user, LinkTarget
$target ) {
223 'wl_user' => $user->getId(),
224 'wl_namespace' => $target->getNamespace(),
225 'wl_title' => $target->getDBkey(),
230 * @param int $slaveOrMaster DB_MASTER or DB_SLAVE
232 * @return DatabaseBase
233 * @throws MWException
235 private function getConnection( $slaveOrMaster ) {
236 return $this->loadBalancer
->getConnection( $slaveOrMaster, [ 'watchlist' ] );
240 * @param DatabaseBase $connection
242 * @throws MWException
244 private function reuseConnection( $connection ) {
245 $this->loadBalancer
->reuseConnection( $connection );
249 * Count the number of individual items that are watched by the user.
250 * If a subject and corresponding talk page are watched this will return 2.
256 public function countWatchedItems( User
$user ) {
257 $dbr = $this->getConnection( DB_SLAVE
);
258 $return = (int)$dbr->selectField(
262 'wl_user' => $user->getId()
266 $this->reuseConnection( $dbr );
272 * @param LinkTarget $target
276 public function countWatchers( LinkTarget
$target ) {
277 $dbr = $this->getConnection( DB_SLAVE
);
278 $return = (int)$dbr->selectField(
282 'wl_namespace' => $target->getNamespace(),
283 'wl_title' => $target->getDBkey(),
287 $this->reuseConnection( $dbr );
293 * Number of page watchers who also visited a "recent" edit
295 * @param LinkTarget $target
296 * @param mixed $threshold timestamp accepted by wfTimestamp
299 * @throws DBUnexpectedError
300 * @throws MWException
302 public function countVisitingWatchers( LinkTarget
$target, $threshold ) {
303 $dbr = $this->getConnection( DB_SLAVE
);
304 $visitingWatchers = (int)$dbr->selectField(
308 'wl_namespace' => $target->getNamespace(),
309 'wl_title' => $target->getDBkey(),
310 'wl_notificationtimestamp >= ' .
311 $dbr->addQuotes( $dbr->timestamp( $threshold ) ) .
312 ' OR wl_notificationtimestamp IS NULL'
316 $this->reuseConnection( $dbr );
318 return $visitingWatchers;
322 * @param LinkTarget[] $targets
323 * @param array $options Allowed keys:
324 * 'minimumWatchers' => int
326 * @return array multi dimensional like $return[$namespaceId][$titleString] = int $watchers
327 * All targets will be present in the result. 0 either means no watchers or the number
328 * of watchers was below the minimumWatchers option if passed.
330 public function countWatchersMultiple( array $targets, array $options = [] ) {
331 $dbOptions = [ 'GROUP BY' => [ 'wl_namespace', 'wl_title' ] ];
333 $dbr = $this->getConnection( DB_SLAVE
);
335 if ( array_key_exists( 'minimumWatchers', $options ) ) {
336 $dbOptions['HAVING'] = 'COUNT(*) >= ' . (int)$options['minimumWatchers'];
339 $lb = new LinkBatch( $targets );
342 [ 'wl_title', 'wl_namespace', 'watchers' => 'COUNT(*)' ],
343 [ $lb->constructSet( 'wl', $dbr ) ],
348 $this->reuseConnection( $dbr );
351 foreach ( $targets as $linkTarget ) {
352 $watchCounts[$linkTarget->getNamespace()][$linkTarget->getDBkey()] = 0;
355 foreach ( $res as $row ) {
356 $watchCounts[$row->wl_namespace
][$row->wl_title
] = (int)$row->watchers
;
363 * Number of watchers of each page who have visited recent edits to that page
365 * @param array $targetsWithVisitThresholds array of pairs (LinkTarget $target, mixed $threshold),
367 * - a timestamp of the recent edit if $target exists (format accepted by wfTimestamp)
368 * - null if $target doesn't exist
369 * @param int|null $minimumWatchers
370 * @return array multi-dimensional like $return[$namespaceId][$titleString] = $watchers,
371 * where $watchers is an int:
372 * - if the page exists, number of users watching who have visited the page recently
373 * - if the page doesn't exist, number of users that have the page on their watchlist
374 * - 0 means there are no visiting watchers or their number is below the minimumWatchers
375 * option (if passed).
377 public function countVisitingWatchersMultiple(
378 array $targetsWithVisitThresholds,
379 $minimumWatchers = null
381 $dbr = $this->getConnection( DB_SLAVE
);
383 $conds = $this->getVisitingWatchersCondition( $dbr, $targetsWithVisitThresholds );
385 $dbOptions = [ 'GROUP BY' => [ 'wl_namespace', 'wl_title' ] ];
386 if ( $minimumWatchers !== null ) {
387 $dbOptions['HAVING'] = 'COUNT(*) >= ' . (int)$minimumWatchers;
391 [ 'wl_namespace', 'wl_title', 'watchers' => 'COUNT(*)' ],
397 $this->reuseConnection( $dbr );
400 foreach ( $targetsWithVisitThresholds as list( $target ) ) {
401 /* @var LinkTarget $target */
402 $watcherCounts[$target->getNamespace()][$target->getDBkey()] = 0;
405 foreach ( $res as $row ) {
406 $watcherCounts[$row->wl_namespace
][$row->wl_title
] = (int)$row->watchers
;
409 return $watcherCounts;
413 * Generates condition for the query used in a batch count visiting watchers.
415 * @param IDatabase $db
416 * @param array $targetsWithVisitThresholds array of pairs (LinkTarget, last visit threshold)
419 private function getVisitingWatchersCondition(
421 array $targetsWithVisitThresholds
423 $missingTargets = [];
424 $namespaceConds = [];
425 foreach ( $targetsWithVisitThresholds as list( $target, $threshold ) ) {
426 if ( $threshold === null ) {
427 $missingTargets[] = $target;
430 /* @var LinkTarget $target */
431 $namespaceConds[$target->getNamespace()][] = $db->makeList( [
432 'wl_title = ' . $db->addQuotes( $target->getDBkey() ),
434 'wl_notificationtimestamp >= ' . $db->addQuotes( $db->timestamp( $threshold ) ),
435 'wl_notificationtimestamp IS NULL'
441 foreach ( $namespaceConds as $namespace => $pageConds ) {
442 $conds[] = $db->makeList( [
443 'wl_namespace = ' . $namespace,
444 '(' . $db->makeList( $pageConds, LIST_OR
) . ')'
448 if ( $missingTargets ) {
449 $lb = new LinkBatch( $missingTargets );
450 $conds[] = $lb->constructSet( 'wl', $db );
453 return $db->makeList( $conds, LIST_OR
);
457 * Get an item (may be cached)
460 * @param LinkTarget $target
462 * @return WatchedItem|false
464 public function getWatchedItem( User
$user, LinkTarget
$target ) {
465 if ( $user->isAnon() ) {
469 $cached = $this->getCached( $user, $target );
471 $this->stats
->increment( 'WatchedItemStore.getWatchedItem.cached' );
474 $this->stats
->increment( 'WatchedItemStore.getWatchedItem.load' );
475 return $this->loadWatchedItem( $user, $target );
479 * Loads an item from the db
482 * @param LinkTarget $target
484 * @return WatchedItem|false
486 public function loadWatchedItem( User
$user, LinkTarget
$target ) {
487 // Only loggedin user can have a watchlist
488 if ( $user->isAnon() ) {
492 $dbr = $this->getConnection( DB_SLAVE
);
493 $row = $dbr->selectRow(
495 'wl_notificationtimestamp',
496 $this->dbCond( $user, $target ),
499 $this->reuseConnection( $dbr );
505 $item = new WatchedItem(
508 $row->wl_notificationtimestamp
510 $this->cache( $item );
517 * @param array $options Allowed keys:
518 * 'forWrite' => bool defaults to false
519 * 'sort' => string optional sorting by namespace ID and title
520 * one of the self::SORT_* constants
522 * @return WatchedItem[]
524 public function getWatchedItemsForUser( User
$user, array $options = [] ) {
525 $options +
= [ 'forWrite' => false ];
528 if ( array_key_exists( 'sort', $options ) ) {
530 ( in_array( $options['sort'], [ self
::SORT_ASC
, self
::SORT_DESC
] ) ),
531 '$options[\'sort\']',
532 'must be SORT_ASC or SORT_DESC'
534 $dbOptions['ORDER BY'] = [
535 "wl_namespace {$options['sort']}",
536 "wl_title {$options['sort']}"
539 $db = $this->getConnection( $options['forWrite'] ? DB_MASTER
: DB_SLAVE
);
543 [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
544 [ 'wl_user' => $user->getId() ],
548 $this->reuseConnection( $db );
551 foreach ( $res as $row ) {
552 // todo these could all be cached at some point?
553 $watchedItems[] = new WatchedItem(
555 new TitleValue( (int)$row->wl_namespace
, $row->wl_title
),
556 $row->wl_notificationtimestamp
560 return $watchedItems;
564 * Must be called separately for Subject & Talk namespaces
567 * @param LinkTarget $target
571 public function isWatched( User
$user, LinkTarget
$target ) {
572 return (bool)$this->getWatchedItem( $user, $target );
577 * @param LinkTarget[] $targets
579 * @return array multi-dimensional like $return[$namespaceId][$titleString] = $timestamp,
580 * where $timestamp is:
581 * - string|null value of wl_notificationtimestamp,
582 * - false if $target is not watched by $user.
584 public function getNotificationTimestampsBatch( User
$user, array $targets ) {
586 foreach ( $targets as $target ) {
587 $timestamps[$target->getNamespace()][$target->getDBkey()] = false;
590 if ( $user->isAnon() ) {
595 foreach ( $targets as $target ) {
596 $cachedItem = $this->getCached( $user, $target );
598 $timestamps[$target->getNamespace()][$target->getDBkey()] =
599 $cachedItem->getNotificationTimestamp();
601 $targetsToLoad[] = $target;
605 if ( !$targetsToLoad ) {
609 $dbr = $this->getConnection( DB_SLAVE
);
611 $lb = new LinkBatch( $targetsToLoad );
614 [ 'wl_namespace', 'wl_title', 'wl_notificationtimestamp' ],
616 $lb->constructSet( 'wl', $dbr ),
617 'wl_user' => $user->getId(),
621 $this->reuseConnection( $dbr );
623 foreach ( $res as $row ) {
624 $timestamps[(int)$row->wl_namespace
][$row->wl_title
] = $row->wl_notificationtimestamp
;
631 * Must be called separately for Subject & Talk namespaces
634 * @param LinkTarget $target
636 public function addWatch( User
$user, LinkTarget
$target ) {
637 $this->addWatchBatchForUser( $user, [ $target ] );
642 * @param LinkTarget[] $targets
644 * @return bool success
646 public function addWatchBatchForUser( User
$user, array $targets ) {
647 if ( $this->loadBalancer
->getReadOnlyReason() !== false ) {
650 // Only loggedin user can have a watchlist
651 if ( $user->isAnon() ) {
660 foreach ( $targets as $target ) {
662 'wl_user' => $user->getId(),
663 'wl_namespace' => $target->getNamespace(),
664 'wl_title' => $target->getDBkey(),
665 'wl_notificationtimestamp' => null,
667 $this->uncache( $user, $target );
670 $dbw = $this->getConnection( DB_MASTER
);
671 foreach ( array_chunk( $rows, 100 ) as $toInsert ) {
672 // Use INSERT IGNORE to avoid overwriting the notification timestamp
673 // if there's already an entry for this page
674 $dbw->insert( 'watchlist', $toInsert, __METHOD__
, 'IGNORE' );
676 $this->reuseConnection( $dbw );
682 * Removes the an entry for the User watching the LinkTarget
683 * Must be called separately for Subject & Talk namespaces
686 * @param LinkTarget $target
688 * @return bool success
689 * @throws DBUnexpectedError
690 * @throws MWException
692 public function removeWatch( User
$user, LinkTarget
$target ) {
693 // Only logged in user can have a watchlist
694 if ( $this->loadBalancer
->getReadOnlyReason() !== false ||
$user->isAnon() ) {
698 $this->uncache( $user, $target );
700 $dbw = $this->getConnection( DB_MASTER
);
701 $dbw->delete( 'watchlist',
703 'wl_user' => $user->getId(),
704 'wl_namespace' => $target->getNamespace(),
705 'wl_title' => $target->getDBkey(),
708 $success = (bool)$dbw->affectedRows();
709 $this->reuseConnection( $dbw );
715 * @param User $editor The editor that triggered the update. Their notification
716 * timestamp will not be updated(they have already seen it)
717 * @param LinkTarget $target The target to update timestamps for
718 * @param string $timestamp Set the update timestamp to this value
720 * @return int[] Array of user IDs the timestamp has been updated for
722 public function updateNotificationTimestamp( User
$editor, LinkTarget
$target, $timestamp ) {
723 $dbw = $this->getConnection( DB_MASTER
);
724 $res = $dbw->select( [ 'watchlist' ],
727 'wl_user != ' . intval( $editor->getId() ),
728 'wl_namespace' => $target->getNamespace(),
729 'wl_title' => $target->getDBkey(),
730 'wl_notificationtimestamp IS NULL',
735 foreach ( $res as $row ) {
736 $watchers[] = intval( $row->wl_user
);
740 // Update wl_notificationtimestamp for all watching users except the editor
742 $dbw->onTransactionIdle(
743 function () use ( $dbw, $timestamp, $watchers, $target, $fname ) {
744 $dbw->update( 'watchlist',
746 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp )
748 'wl_user' => $watchers,
749 'wl_namespace' => $target->getNamespace(),
750 'wl_title' => $target->getDBkey(),
753 $this->uncacheLinkTarget( $target );
758 $this->reuseConnection( $dbw );
764 * Reset the notification timestamp of this entry
767 * @param Title $title
768 * @param string $force Whether to force the write query to be executed even if the
769 * page is not watched or the notification timestamp is already NULL.
770 * 'force' in order to force
771 * @param int $oldid The revision id being viewed. If not given or 0, latest revision is assumed.
773 * @return bool success
775 public function resetNotificationTimestamp( User
$user, Title
$title, $force = '', $oldid = 0 ) {
776 // Only loggedin user can have a watchlist
777 if ( $this->loadBalancer
->getReadOnlyReason() !== false ||
$user->isAnon() ) {
782 if ( $force != 'force' ) {
783 $item = $this->loadWatchedItem( $user, $title );
784 if ( !$item ||
$item->getNotificationTimestamp() === null ) {
789 // If the page is watched by the user (or may be watched), update the timestamp
790 $job = new ActivityUpdateJob(
793 'type' => 'updateWatchlistNotification',
794 'userid' => $user->getId(),
795 'notifTime' => $this->getNotificationTimestamp( $user, $title, $item, $force, $oldid ),
800 // Try to run this post-send
801 // Calls DeferredUpdates::addCallableUpdate in normal operation
803 $this->deferredUpdatesAddCallableUpdateCallback
,
804 function() use ( $job ) {
809 $this->uncache( $user, $title );
814 private function getNotificationTimestamp( User
$user, Title
$title, $item, $force, $oldid ) {
816 // No oldid given, assuming latest revision; clear the timestamp.
820 if ( !$title->getNextRevisionID( $oldid ) ) {
821 // Oldid given and is the latest revision for this title; clear the timestamp.
825 if ( $item === null ) {
826 $item = $this->loadWatchedItem( $user, $title );
830 // This can only happen if $force is enabled.
834 // Oldid given and isn't the latest; update the timestamp.
835 // This will result in no further notification emails being sent!
836 // Calls Revision::getTimestampFromId in normal operation
837 $notificationTimestamp = call_user_func(
838 $this->revisionGetTimestampFromIdCallback
,
843 // We need to go one second to the future because of various strict comparisons
844 // throughout the codebase
845 $ts = new MWTimestamp( $notificationTimestamp );
846 $ts->timestamp
->add( new DateInterval( 'PT1S' ) );
847 $notificationTimestamp = $ts->getTimestamp( TS_MW
);
849 if ( $notificationTimestamp < $item->getNotificationTimestamp() ) {
850 if ( $force != 'force' ) {
853 // This is a little silly…
854 return $item->getNotificationTimestamp();
858 return $notificationTimestamp;
863 * @param int $unreadLimit
865 * @return int|bool The number of unread notifications
866 * true if greater than or equal to $unreadLimit
868 public function countUnreadNotifications( User
$user, $unreadLimit = null ) {
870 if ( $unreadLimit !== null ) {
871 $unreadLimit = (int)$unreadLimit;
872 $queryOptions['LIMIT'] = $unreadLimit;
875 $dbr = $this->getConnection( DB_SLAVE
);
876 $rowCount = $dbr->selectRowCount(
880 'wl_user' => $user->getId(),
881 'wl_notificationtimestamp IS NOT NULL',
886 $this->reuseConnection( $dbr );
888 if ( !isset( $unreadLimit ) ) {
892 if ( $rowCount >= $unreadLimit ) {
900 * Check if the given title already is watched by the user, and if so
901 * add a watch for the new title.
903 * To be used for page renames and such.
905 * @param LinkTarget $oldTarget
906 * @param LinkTarget $newTarget
908 public function duplicateAllAssociatedEntries( LinkTarget
$oldTarget, LinkTarget
$newTarget ) {
909 $oldTarget = Title
::newFromLinkTarget( $oldTarget );
910 $newTarget = Title
::newFromLinkTarget( $newTarget );
912 $this->duplicateEntry( $oldTarget->getSubjectPage(), $newTarget->getSubjectPage() );
913 $this->duplicateEntry( $oldTarget->getTalkPage(), $newTarget->getTalkPage() );
917 * Check if the given title already is watched by the user, and if so
918 * add a watch for the new title.
920 * To be used for page renames and such.
921 * This must be called separately for Subject and Talk pages
923 * @param LinkTarget $oldTarget
924 * @param LinkTarget $newTarget
926 public function duplicateEntry( LinkTarget
$oldTarget, LinkTarget
$newTarget ) {
927 $dbw = $this->getConnection( DB_MASTER
);
929 $result = $dbw->select(
931 [ 'wl_user', 'wl_notificationtimestamp' ],
933 'wl_namespace' => $oldTarget->getNamespace(),
934 'wl_title' => $oldTarget->getDBkey(),
940 $newNamespace = $newTarget->getNamespace();
941 $newDBkey = $newTarget->getDBkey();
943 # Construct array to replace into the watchlist
945 foreach ( $result as $row ) {
947 'wl_user' => $row->wl_user
,
948 'wl_namespace' => $newNamespace,
949 'wl_title' => $newDBkey,
950 'wl_notificationtimestamp' => $row->wl_notificationtimestamp
,
954 if ( !empty( $values ) ) {
956 # Note that multi-row replace is very efficient for MySQL but may be inefficient for
957 # some other DBMSes, mostly due to poor simulation by us
960 [ [ 'wl_user', 'wl_namespace', 'wl_title' ] ],
966 $this->reuseConnection( $dbw );