Merge "Improve docs for Title::getInternalURL/getCanonicalURL"
[lhc/web/wiklou.git] / includes / mail / EmailNotification.php
index 739dbec..acf2c2e 100644 (file)
@@ -24,7 +24,6 @@
  * @author Luke Welling lwelling@wikimedia.org
  */
 
-use MediaWiki\Linker\LinkTarget;
 use MediaWiki\MediaWikiServices;
 
 /**
@@ -76,30 +75,17 @@ class EmailNotification {
        protected $editor;
 
        /**
-        * @deprecated since 1.27 use WatchedItemStore::updateNotificationTimestamp directly
+        * Extensions that have hooks for
+        * UpdateUserMailerFormattedPageStatus (to provide additional
+        * pageStatus indicators) need a way to make sure that, when their
+        * hook is called in SendWatchlistemailNotification, they only
+        * handle notifications using their pageStatus indicator.
         *
-        * @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
+        * @since 1.33
+        * @return string
         */
-       public static function updateWatchlistTimestamp(
-               User $editor,
-               LinkTarget $linkTarget,
-               $timestamp
-       ) {
-               wfDeprecated( __METHOD__, '1.27' );
-               $config = RequestContext::getMain()->getConfig();
-               if ( !$config->get( 'EnotifWatchlist' ) && !$config->get( 'ShowUpdatedMarker' ) ) {
-                       return [];
-               }
-               return MediaWikiServices::getInstance()->getWatchedItemStore()->updateNotificationTimestamp(
-                       $editor,
-                       $linkTarget,
-                       $timestamp
-               );
+       public function getPageStatus() {
+               return $this->pageStatus;
        }
 
        /**
@@ -140,7 +126,7 @@ class EmailNotification {
                // If nobody is watching the page, and there are no users notified on all changes
                // don't bother creating a job/trying to send emails, unless it's a
                // talk page with an applicable notification.
-               if ( !count( $watchers ) && !count( $wgUsersNotifiedOnAllChanges ) ) {
+               if ( $watchers === [] && !count( $wgUsersNotifiedOnAllChanges ) ) {
                        $sendEmail = false;
                        // Only send notification for non minor edits, unless $wgEnotifMinorEdits
                        if ( !$minorEdit || ( $wgEnotifMinorEdits && !$editor->isAllowed( 'nominornewtalk' ) ) ) {
@@ -239,10 +225,9 @@ class EmailNotification {
                                                && $watchingUser->getId() != $userTalkId
                                                && !in_array( $watchingUser->getName(), $wgUsersNotifiedOnAllChanges )
                                                && !( $wgBlockDisablesLogin && $watchingUser->isBlocked() )
+                                               && Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] )
                                        ) {
-                                               if ( Hooks::run( 'SendWatchlistEmailNotification', [ $watchingUser, $title, $this ] ) ) {
-                                                       $this->compose( $watchingUser, self::WATCHLIST );
-                                               }
+                                               $this->compose( $watchingUser, self::WATCHLIST );
                                        }
                                }
                        }
@@ -342,8 +327,9 @@ class EmailNotification {
 
                $keys['$PAGETITLE'] = $this->title->getPrefixedText();
                $keys['$PAGETITLE_URL'] = $this->title->getCanonicalURL();
-               $keys['$PAGEMINOREDIT'] = "\n" . ( $this->minorEdit ?
-                       wfMessage( 'enotif_minoredit' )->inContentLanguage()->text() : '' );
+               $keys['$PAGEMINOREDIT'] = $this->minorEdit ?
+                       "\n\n" . wfMessage( 'enotif_minoredit' )->inContentLanguage()->text() :
+                       '';
                $keys['$UNWATCHURL'] = $this->title->getCanonicalURL( 'action=unwatch' );
 
                if ( $this->editor->isAnon() ) {