protected $subject, $body, $replyto, $from;
protected $timestamp, $summary, $minorEdit, $oldid, $composed_common, $pageStatus;
- protected $mailTargets = array();
+ protected $mailTargets = [];
/**
* @var Title
protected $editor;
/**
+ * @deprecated since 1.27 use WatchedItemStore::updateNotificationTimestamp directly
+ *
* @param User $editor The editor that triggered the update. Their notification
* timestamp will not be updated(they have already seen it)
* @param LinkTarget $linkTarget The link target of the title to update timestamps for
* @param string $timestamp Set the update timestamp to this value
+ *
* @return int[] Array of user IDs
*/
public static function updateWatchlistTimestamp(
LinkTarget $linkTarget,
$timestamp
) {
- global $wgEnotifWatchlist, $wgShowUpdatedMarker;
-
- if ( !$wgEnotifWatchlist && !$wgShowUpdatedMarker ) {
- return array();
+ // wfDeprecated( __METHOD__, '1.27' );
+ $config = RequestContext::getMain()->getConfig();
+ if ( !$config->get( 'EnotifWatchlist' ) && !$config->get( 'ShowUpdatedMarker' ) ) {
+ return [];
}
-
- $dbw = wfGetDB( DB_MASTER );
- $res = $dbw->select( array( 'watchlist' ),
- array( 'wl_user' ),
- array(
- 'wl_user != ' . intval( $editor->getID() ),
- 'wl_namespace' => $linkTarget->getNamespace(),
- 'wl_title' => $linkTarget->getDBkey(),
- 'wl_notificationtimestamp IS NULL',
- ), __METHOD__
+ return WatchedItemStore::getDefaultInstance()->updateNotificationTimestamp(
+ $editor,
+ $linkTarget,
+ $timestamp
);
-
- $watchers = array();
- foreach ( $res as $row ) {
- $watchers[] = intval( $row->wl_user );
- }
-
- if ( $watchers ) {
- // Update wl_notificationtimestamp for all watching users except the editor
- $fname = __METHOD__;
- $dbw->onTransactionIdle(
- function () use ( $dbw, $timestamp, $watchers, $linkTarget, $fname ) {
- $dbw->update( 'watchlist',
- array( /* SET */
- 'wl_notificationtimestamp' => $dbw->timestamp( $timestamp )
- ), array( /* WHERE */
- 'wl_user' => $watchers,
- 'wl_namespace' => $linkTarget->getNamespace(),
- 'wl_title' => $linkTarget->getDBkey(),
- ), $fname
- );
- }
- );
- }
-
- return $watchers;
}
/**
}
// update wl_notificationtimestamp for watchers
- $watchers = self::updateWatchlistTimestamp( $editor, $title, $timestamp );
+ $config = RequestContext::getMain()->getConfig();
+ $watchers = [];
+ if ( $config->get( 'EnotifWatchlist' ) || $config->get( 'ShowUpdatedMarker' ) ) {
+ $watchers = WatchedItemStore::getDefaultInstance()->updateNotificationTimestamp(
+ $editor,
+ $title,
+ $timestamp
+ );
+ }
$sendEmail = true;
// $watchers deals with $wgEnotifWatchlist.
if ( $sendEmail ) {
JobQueueGroup::singleton()->lazyPush( new EnotifNotifyJob(
$title,
- array(
+ [
'editor' => $editor->getName(),
- 'editorID' => $editor->getID(),
+ 'editorID' => $editor->getId(),
'timestamp' => $timestamp,
'summary' => $summary,
'minorEdit' => $minorEdit,
'oldid' => $oldid,
'watchers' => $watchers,
'pageStatus' => $pageStatus
- )
+ ]
) );
}
}
$this->composed_common = false;
$this->pageStatus = $pageStatus;
- $formattedPageStatus = array( 'deleted', 'created', 'moved', 'restored', 'changed' );
+ $formattedPageStatus = [ 'deleted', 'created', 'moved', 'restored', 'changed' ];
- Hooks::run( 'UpdateUserMailerFormattedPageStatus', array( &$formattedPageStatus ) );
+ Hooks::run( 'UpdateUserMailerFormattedPageStatus', [ &$formattedPageStatus ] );
if ( !in_array( $this->pageStatus, $formattedPageStatus ) ) {
throw new MWException( 'Not a valid page status!' );
}
if ( $watchingUser->getOption( 'enotifwatchlistpages' )
&& ( !$minorEdit || $watchingUser->getOption( 'enotifminoredits' ) )
&& $watchingUser->isEmailConfirmed()
- && $watchingUser->getID() != $userTalkId
+ && $watchingUser->getId() != $userTalkId
&& !in_array( $watchingUser->getName(), $wgUsersNotifiedOnAllChanges )
&& !( $wgBlockDisablesLogin && $watchingUser->isBlocked() )
) {
- if ( Hooks::run( 'SendWatchlistEmailNotification', array( $watchingUser, $title, $this ) ) ) {
+ if ( Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] ) ) {
$this->compose( $watchingUser, self::WATCHLIST );
}
}
) {
if ( !$targetUser->isEmailConfirmed() ) {
wfDebug( __METHOD__ . ": talk page owner doesn't have validated email\n" );
- } elseif ( !Hooks::run( 'AbortTalkPageEmailNotification', array( $targetUser, $title ) ) ) {
+ } elseif ( !Hooks::run( 'AbortTalkPageEmailNotification', [ $targetUser, $title ] ) ) {
wfDebug( __METHOD__ . ": talk page update notification is aborted for this user\n" );
} else {
wfDebug( __METHOD__ . ": sending talk page update notification\n" );
# named variables when composing your notification emails while
# simply editing the Meta pages
- $keys = array();
- $postTransformKeys = array();
+ $keys = [];
+ $postTransformKeys = [];
$pageTitleUrl = $this->title->getCanonicalURL();
$pageTitle = $this->title->getPrefixedText();
if ( $this->oldid ) {
// Always show a link to the diff which triggered the mail. See bug 32210.
$keys['$NEWPAGE'] = "\n\n" . wfMessage( 'enotif_lastdiff',
- $this->title->getCanonicalURL( array( 'diff' => 'next', 'oldid' => $this->oldid ) ) )
+ $this->title->getCanonicalURL( [ 'diff' => 'next', 'oldid' => $this->oldid ] ) )
->inContentLanguage()->text();
if ( !$wgEnotifImpersonal ) {
// For personal mail, also show a link to the diff of all changes
// since last visited.
$keys['$NEWPAGE'] .= "\n\n" . wfMessage( 'enotif_lastvisited',
- $this->title->getCanonicalURL( array( 'diff' => '0', 'oldid' => $this->oldid ) ) )
+ $this->title->getCanonicalURL( [ 'diff' => '0', 'oldid' => $this->oldid ] ) )
->inContentLanguage()->text();
}
$keys['$OLDID'] = $this->oldid;
# expressed in terms of individual local time of the notification
# recipient, i.e. watching user
$body = str_replace(
- array( '$WATCHINGUSERNAME',
+ [ '$WATCHINGUSERNAME',
'$PAGEEDITDATE',
- '$PAGEEDITTIME' ),
- array( $wgEnotifUseRealName && $watchingUser->getRealName() !== ''
+ '$PAGEEDITTIME' ],
+ [ $wgEnotifUseRealName && $watchingUser->getRealName() !== ''
? $watchingUser->getRealName() : $watchingUser->getName(),
$wgContLang->userDate( $this->timestamp, $watchingUser ),
- $wgContLang->userTime( $this->timestamp, $watchingUser ) ),
+ $wgContLang->userTime( $this->timestamp, $watchingUser ) ],
$this->body );
- $headers = array();
+ $headers = [];
if ( $source === self::WATCHLIST ) {
$headers['List-Help'] = 'https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Watchlist';
}
- return UserMailer::send( $to, $this->from, $this->subject, $body, array(
+ return UserMailer::send( $to, $this->from, $this->subject, $body, [
'replyTo' => $this->replyto,
'headers' => $headers,
- ) );
+ ] );
}
/**
}
$body = str_replace(
- array( '$WATCHINGUSERNAME',
+ [ '$WATCHINGUSERNAME',
'$PAGEEDITDATE',
- '$PAGEEDITTIME' ),
- array( wfMessage( 'enotif_impersonal_salutation' )->inContentLanguage()->text(),
+ '$PAGEEDITTIME' ],
+ [ wfMessage( 'enotif_impersonal_salutation' )->inContentLanguage()->text(),
$wgContLang->date( $this->timestamp, false, false ),
- $wgContLang->time( $this->timestamp, false, false ) ),
+ $wgContLang->time( $this->timestamp, false, false ) ],
$this->body );
- return UserMailer::send( $addresses, $this->from, $this->subject, $body, array(
+ return UserMailer::send( $addresses, $this->from, $this->subject, $body, [
'replyTo' => $this->replyto,
- ) );
+ ] );
}
}