aboutsummaryrefslogtreecommitdiffstats
path: root/includes/WatchedItemStore.php
diff options
context:
space:
mode:
authoraddshore <addshorewiki@gmail.com>2016-03-22 18:07:49 +0000
committerAddshore <addshorewiki@gmail.com>2016-03-24 18:28:08 +0000
commit12e2e9edbc5f97b49d85194af5fff316d5bf4a90 (patch)
tree67fd69e71eec4cb1e7c9a22c16ca64a23180fb98 /includes/WatchedItemStore.php
parent5a0da02e6a42da80035d7b3591e257c0c995e5e3 (diff)
downloadmediawikicore-12e2e9edbc5f97b49d85194af5fff316d5bf4a90.tar.gz
mediawikicore-12e2e9edbc5f97b49d85194af5fff316d5bf4a90.zip
Switch Signature of WatchedItemStore::addWatchBatch
Adding batches of watched items per users makes much more sense. Only the deprecated static WatchedItem method needed the old silly way of passing in objects. Change-Id: I90f9583b66bd3b5afcf07faefedb38a8a0149f6e
Diffstat (limited to 'includes/WatchedItemStore.php')
-rw-r--r--includes/WatchedItemStore.php30
1 files changed, 13 insertions, 17 deletions
diff --git a/includes/WatchedItemStore.php b/includes/WatchedItemStore.php
index 4eea54deecaf..c4340ad5e1f6 100644
--- a/includes/WatchedItemStore.php
+++ b/includes/WatchedItemStore.php
@@ -615,30 +615,30 @@ class WatchedItemStore {
* @param LinkTarget $target
*/
public function addWatch( User $user, LinkTarget $target ) {
- $this->addWatchBatch( [ [ $user, $target ] ] );
+ $this->addWatchBatchForUser( $user, [ $target ] );
}
/**
- * @param array[] $userTargetCombinations array of arrays containing [0] => User [1] => LinkTarget
+ * @param User $user
+ * @param LinkTarget[] $targets
*
* @return bool success
*/
- public function addWatchBatch( array $userTargetCombinations ) {
+ public function addWatchBatchForUser( User $user, array $targets ) {
if ( $this->loadBalancer->getReadOnlyReason() !== false ) {
return false;
}
+ // Only loggedin user can have a watchlist
+ if ( $user->isAnon() ) {
+ return false;
+ }
+
+ if ( !$targets ) {
+ return true;
+ }
$rows = [];
- foreach ( $userTargetCombinations as list( $user, $target ) ) {
- /**
- * @var User $user
- * @var LinkTarget $target
- */
-
- // Only loggedin user can have a watchlist
- if ( $user->isAnon() ) {
- continue;
- }
+ foreach ( $targets as $target ) {
$rows[] = [
'wl_user' => $user->getId(),
'wl_namespace' => $target->getNamespace(),
@@ -648,10 +648,6 @@ class WatchedItemStore {
$this->uncache( $user, $target );
}
- if ( !$rows ) {
- return false;
- }
-
$dbw = $this->getConnection( DB_MASTER );
foreach ( array_chunk( $rows, 100 ) as $toInsert ) {
// Use INSERT IGNORE to avoid overwriting the notification timestamp