Index: trunk/phase3/includes/UserArray.php |
— | — | @@ -12,6 +12,17 @@ |
13 | 13 | return $userArray; |
14 | 14 | } |
15 | 15 | |
| 16 | + static function newFromIDs( $ids ) { |
| 17 | + $ids = array_map( 'intval', (array)$ids ); // paranoia |
| 18 | + if ( !$ids ) |
| 19 | + // Database::select() doesn't like empty arrays |
| 20 | + return new ArrayIterator(array()); |
| 21 | + $dbr = wfGetDB( DB_SLAVE ); |
| 22 | + $res = $dbr->select( 'user', '*', array( 'user_id' => $ids ), |
| 23 | + __METHOD__ ); |
| 24 | + return self::newFromResult( $res ); |
| 25 | + } |
| 26 | + |
16 | 27 | protected static function newFromResult_internal( $res ) { |
17 | 28 | $userArray = new UserArrayFromResult( $res ); |
18 | 29 | return $userArray; |
Index: trunk/phase3/includes/EnotifNotifyJob.php |
— | — | @@ -26,7 +26,8 @@ |
27 | 27 | $this->params['timestamp'], |
28 | 28 | $this->params['summary'], |
29 | 29 | $this->params['minorEdit'], |
30 | | - $this->params['oldid'] |
| 30 | + $this->params['oldid'], |
| 31 | + $this->params['watchers'] |
31 | 32 | ); |
32 | 33 | return true; |
33 | 34 | } |
Index: trunk/phase3/includes/UserMailer.php |
— | — | @@ -281,11 +281,42 @@ |
282 | 282 | * @param $oldid (default: false) |
283 | 283 | */ |
284 | 284 | function notifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid = false) { |
285 | | - global $wgEnotifUseJobQ; |
| 285 | + global $wgEnotifUseJobQ, $wgEnotifWatchlist, $wgShowUpdatedMarker; |
286 | 286 | |
287 | | - if( $title->getNamespace() < 0 ) |
| 287 | + if ($title->getNamespace() < 0) |
288 | 288 | return; |
289 | 289 | |
| 290 | + // Build a list of users to notfiy |
| 291 | + $watchers = array(); |
| 292 | + if ($wgEnotifWatchlist || $wgShowUpdatedMarker) { |
| 293 | + $dbw = wfGetDB( DB_MASTER ); |
| 294 | + $res = $dbw->select( array( 'watchlist' ), |
| 295 | + array( 'wl_user' ), |
| 296 | + array( |
| 297 | + 'wl_title' => $title->getDBkey(), |
| 298 | + 'wl_namespace' => $title->getNamespace(), |
| 299 | + 'wl_user != ' . intval( $editor->getID() ), |
| 300 | + 'wl_notificationtimestamp IS NULL', |
| 301 | + ), __METHOD__ |
| 302 | + ); |
| 303 | + while ($row = $dbw->fetchObject( $res ) ) { |
| 304 | + $watchers[] = intval( $row->wl_user ); |
| 305 | + } |
| 306 | + if ($watchers) { |
| 307 | + // Update wl_notificationtimestamp for all watching users except |
| 308 | + // the editor |
| 309 | + $dbw->begin(); |
| 310 | + $dbw->update( 'watchlist', |
| 311 | + array( /* SET */ |
| 312 | + 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp ) |
| 313 | + ), array( /* WHERE */ |
| 314 | + 'wl_user' => $watchers |
| 315 | + ), __METHOD__ |
| 316 | + ); |
| 317 | + $dbw->commit(); |
| 318 | + } |
| 319 | + } |
| 320 | + |
290 | 321 | if ($wgEnotifUseJobQ) { |
291 | 322 | $params = array( |
292 | 323 | "editor" => $editor->getName(), |
— | — | @@ -293,11 +324,12 @@ |
294 | 325 | "timestamp" => $timestamp, |
295 | 326 | "summary" => $summary, |
296 | 327 | "minorEdit" => $minorEdit, |
297 | | - "oldid" => $oldid); |
| 328 | + "oldid" => $oldid, |
| 329 | + "watchers" => $watchers); |
298 | 330 | $job = new EnotifNotifyJob( $title, $params ); |
299 | 331 | $job->insert(); |
300 | 332 | } else { |
301 | | - $this->actuallyNotifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid); |
| 333 | + $this->actuallyNotifyOnPageChange( $editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers ); |
302 | 334 | } |
303 | 335 | |
304 | 336 | } |
— | — | @@ -310,15 +342,16 @@ |
311 | 343 | * |
312 | 344 | * @param $editor User object |
313 | 345 | * @param $title Title object |
314 | | - * @param $timestamp |
315 | | - * @param $summary |
316 | | - * @param $minorEdit |
317 | | - * @param $oldid (default: false) |
| 346 | + * @param $timestamp string Edit timestamp |
| 347 | + * @param $summary string Edit summary |
| 348 | + * @param $minorEdit bool |
| 349 | + * @param $oldid int Revision ID |
| 350 | + * @param $watchers array of user IDs |
318 | 351 | */ |
319 | | - function actuallyNotifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid=false) { |
| 352 | + function actuallyNotifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid, $watchers) { |
320 | 353 | # we use $wgPasswordSender as sender's address |
321 | 354 | global $wgEnotifWatchlist; |
322 | | - global $wgEnotifMinorEdits, $wgEnotifUserTalk, $wgShowUpdatedMarker; |
| 355 | + global $wgEnotifMinorEdits, $wgEnotifUserTalk; |
323 | 356 | global $wgEnotifImpersonal; |
324 | 357 | |
325 | 358 | wfProfileIn( __METHOD__ ); |
— | — | @@ -363,30 +396,12 @@ |
364 | 397 | |
365 | 398 | if ( $wgEnotifWatchlist ) { |
366 | 399 | // Send updates to watchers other than the current editor |
367 | | - $userCondition = 'wl_user != ' . intval( $editor->getID() ); |
368 | | - if ( $userTalkId !== false ) { |
369 | | - // Already sent an email to this person |
370 | | - $userCondition .= ' AND wl_user != ' . intval( $userTalkId ); |
371 | | - } |
372 | | - $dbr = wfGetDB( DB_SLAVE ); |
373 | | - |
374 | | - list( $user ) = $dbr->tableNamesN( 'user' ); |
375 | | - $res = $dbr->select( array( 'watchlist', 'user' ), |
376 | | - array( "$user.*" ), |
377 | | - array( |
378 | | - 'wl_user=user_id', |
379 | | - 'wl_title' => $title->getDBkey(), |
380 | | - 'wl_namespace' => $title->getNamespace(), |
381 | | - $userCondition, |
382 | | - 'wl_notificationtimestamp IS NULL', |
383 | | - ), __METHOD__ |
384 | | - ); |
385 | | - $userArray = UserArray::newFromResult( $res ); |
386 | | - |
| 400 | + $userArray = UserArray::newFromIDs( $watchers ); |
387 | 401 | foreach ( $userArray as $watchingUser ) { |
388 | 402 | if ( $watchingUser->getOption( 'enotifwatchlistpages' ) && |
389 | 403 | ( !$minorEdit || $watchingUser->getOption('enotifminoredits') ) && |
390 | | - $watchingUser->isEmailConfirmed() ) |
| 404 | + $watchingUser->isEmailConfirmed() && |
| 405 | + $watchingUser->getID() != $userTalkId ) |
391 | 406 | { |
392 | 407 | $this->compose( $watchingUser ); |
393 | 408 | } |
— | — | @@ -400,31 +415,9 @@ |
401 | 416 | $this->compose( $user ); |
402 | 417 | } |
403 | 418 | |
404 | | - $latestTimestamp = Revision::getTimestampFromId( $title, $title->getLatestRevID(GAID_FOR_UPDATE) ); |
405 | | - // Do not update watchlists if something else already did. |
406 | | - if ( $timestamp >= $latestTimestamp && ($wgShowUpdatedMarker || $wgEnotifWatchlist) ) { |
407 | | - # Mark the changed watch-listed page with a timestamp, so that the page is |
408 | | - # listed with an "updated since your last visit" icon in the watch list. Do |
409 | | - # not do this to users for their own edits. |
410 | | - $dbw = wfGetDB( DB_MASTER ); |
411 | | - $dbw->begin(); |
412 | | - $dbw->update( 'watchlist', |
413 | | - array( /* SET */ |
414 | | - 'wl_notificationtimestamp' => $dbw->timestamp($timestamp) |
415 | | - ), array( /* WHERE */ |
416 | | - 'wl_title' => $title->getDBkey(), |
417 | | - 'wl_namespace' => $title->getNamespace(), |
418 | | - 'wl_notificationtimestamp IS NULL', // store oldest unseen change time |
419 | | - 'wl_user != ' . intval( $editor->getID() ) |
420 | | - ), __METHOD__ |
421 | | - ); |
422 | | - $dbw->commit(); |
423 | | - } |
424 | | - |
425 | 419 | $this->sendMails(); |
426 | | - |
427 | 420 | wfProfileOut( __METHOD__ ); |
428 | | - } # function NotifyOnChange |
| 421 | + } |
429 | 422 | |
430 | 423 | /** |
431 | 424 | * @private |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -225,10 +225,13 @@ |
226 | 226 | * (bug 17546) Correct Tongan language native name is "lea faka-Tonga" |
227 | 227 | * (bug 17621) Special:WantedFiles has no link to Special:Whatlinkshere |
228 | 228 | * (bug 17460) Client ecoding is now correctly set for PostgreSQL |
229 | | -* (bug 17648) Prevent floats from intruding into edit area in previews if no toolbar present |
| 229 | +* (bug 17648) Prevent floats from intruding into edit area in previews if no |
| 230 | + toolbar present |
230 | 231 | * (bug 16899) DISPLAYTITLE should allow Arabic and Persian harakats |
231 | 232 | * (bug 17692) Added (list of members) link to 'user' in Special:Listgrouprights |
232 | 233 | * (bug 17707) Show file destination as plain text if &wpForReUpload=1 |
| 234 | +* (bug 10172) Moved setting of "changed since last visit" flags out of the job |
| 235 | + queue |
233 | 236 | |
234 | 237 | == API changes in 1.15 == |
235 | 238 | * (bug 16858) Revamped list=deletedrevs to make listing deleted contributions |