* @param $oldid (default: false)
*/
function actuallyNotifyOnPageChange($editor, $title, $timestamp, $summary, $minorEdit, $oldid=false) {
-
# we use $wgPasswordSender as sender's address
global $wgEnotifWatchlist;
global $wgEnotifMinorEdits, $wgEnotifUserTalk, $wgShowUpdatedMarker;
if ( $wgEnotifWatchlist ) {
// Send updates to watchers other than the current editor
- $userCondition = 'wl_user != ' . $editor->getID();
+ $userCondition = 'wl_user != ' . intval( $editor->getID() );
if ( $userTalkId !== false ) {
// Already sent an email to this person
$userCondition .= ' AND wl_user != ' . intval( $userTalkId );
$dbr = wfGetDB( DB_SLAVE );
list( $user ) = $dbr->tableNamesN( 'user' );
-
$res = $dbr->select( array( 'watchlist', 'user' ),
array( "$user.*" ),
array(
'wl_namespace' => $title->getNamespace(),
$userCondition,
'wl_notificationtimestamp IS NULL',
- ), __METHOD__ );
+ ), __METHOD__
+ );
$userArray = UserArray::newFromResult( $res );
foreach ( $userArray as $watchingUser ) {
$this->compose( $user );
}
- $this->sendMails();
-
- $latestTimestamp = Revision::getTimestampFromId( $title, $title->getLatestRevID() );
+ $latestTimestamp = Revision::getTimestampFromId( $title, $title->getLatestRevID(GAID_FOR_UPDATE) );
// Do not update watchlists if something else already did.
if ( $timestamp >= $latestTimestamp && ($wgShowUpdatedMarker || $wgEnotifWatchlist) ) {
# Mark the changed watch-listed page with a timestamp, so that the page is
# listed with an "updated since your last visit" icon in the watch list. Do
# not do this to users for their own edits.
$dbw = wfGetDB( DB_MASTER );
+ $dbw->begin();
$dbw->update( 'watchlist',
array( /* SET */
'wl_notificationtimestamp' => $dbw->timestamp($timestamp)
), array( /* WHERE */
'wl_title' => $title->getDBkey(),
'wl_namespace' => $title->getNamespace(),
- 'wl_notificationtimestamp IS NULL',
- 'wl_user != ' . $editor->getID()
+ 'wl_notificationtimestamp IS NULL', // store oldest unseen change time
+ 'wl_user != ' . intval( $editor->getID() )
), __METHOD__
);
+ $dbw->commit();
}
+
+ $this->sendMails();
wfProfileOut( __METHOD__ );
} # function NotifyOnChange