Merge "Fix slow queries in migrateActors.php"
[lhc/web/wiklou.git] / includes / mail / EmailNotification.php
index 2931d9d..8a089f6 100644 (file)
@@ -23,8 +23,8 @@
  * @author Tim Starling
  * @author Luke Welling lwelling@wikimedia.org
  */
-use MediaWiki\Linker\LinkTarget;
 
+use MediaWiki\Linker\LinkTarget;
 use MediaWiki\MediaWikiServices;
 
 /**
@@ -75,6 +75,20 @@ class EmailNotification {
         */
        protected $editor;
 
+       /**
+        * 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.
+        *
+        * @since 1.33
+        * @return string
+        */
+       public function getPageStatus() {
+               return $this->pageStatus;
+       }
+
        /**
         * @deprecated since 1.27 use WatchedItemStore::updateNotificationTimestamp directly
         *
@@ -90,7 +104,7 @@ class EmailNotification {
                LinkTarget $linkTarget,
                $timestamp
        ) {
-               // wfDeprecated( __METHOD__, '1.27' );
+               wfDeprecated( __METHOD__, '1.27' );
                $config = RequestContext::getMain()->getConfig();
                if ( !$config->get( 'EnotifWatchlist' ) && !$config->get( 'ShowUpdatedMarker' ) ) {
                        return [];
@@ -342,8 +356,8 @@ class EmailNotification {
 
                $keys['$PAGETITLE'] = $this->title->getPrefixedText();
                $keys['$PAGETITLE_URL'] = $this->title->getCanonicalURL();
-               $keys['$PAGEMINOREDIT'] = $this->minorEdit ?
-                       wfMessage( 'enotif_minoredit' )->inContentLanguage()->text() : '';
+               $keys['$PAGEMINOREDIT'] = "\n" . ( $this->minorEdit ?
+                       wfMessage( 'enotif_minoredit' )->inContentLanguage()->text() : '' );
                $keys['$UNWATCHURL'] = $this->title->getCanonicalURL( 'action=unwatch' );
 
                if ( $this->editor->isAnon() ) {
@@ -444,15 +458,16 @@ class EmailNotification {
        /**
         * Does the per-user customizations to a notification e-mail (name,
         * timestamp in proper timezone, etc) and sends it out.
-        * Returns true if the mail was sent successfully.
+        * Returns Status if email was sent successfully or not (Status::newGood()
+        * or Status::newFatal() respectively).
         *
         * @param User $watchingUser
         * @param string $source
-        * @return bool
+        * @return Status
         * @private
         */
        function sendPersonalised( $watchingUser, $source ) {
-               global $wgContLang, $wgEnotifUseRealName;
+               global $wgEnotifUseRealName;
                // From the PHP manual:
                //   Note: The to parameter cannot be an address in the form of
                //   "Something <someone@example.com>". The mail command will not parse
@@ -462,14 +477,15 @@ class EmailNotification {
                # $PAGEEDITDATE is the time and date of the page change
                # expressed in terms of individual local time of the notification
                # recipient, i.e. watching user
+               $contLang = MediaWikiServices::getInstance()->getContentLanguage();
                $body = str_replace(
                        [ '$WATCHINGUSERNAME',
                                '$PAGEEDITDATE',
                                '$PAGEEDITTIME' ],
                        [ $wgEnotifUseRealName && $watchingUser->getRealName() !== ''
                                ? $watchingUser->getRealName() : $watchingUser->getName(),
-                               $wgContLang->userDate( $this->timestamp, $watchingUser ),
-                               $wgContLang->userTime( $this->timestamp, $watchingUser ) ],
+                               $contLang->userDate( $this->timestamp, $watchingUser ),
+                               $contLang->userTime( $this->timestamp, $watchingUser ) ],
                        $this->body );
 
                $headers = [];
@@ -490,19 +506,18 @@ class EmailNotification {
         * @return Status|null
         */
        function sendImpersonal( $addresses ) {
-               global $wgContLang;
-
                if ( empty( $addresses ) ) {
                        return null;
                }
 
+               $contLang = MediaWikiServices::getInstance()->getContentLanguage();
                $body = str_replace(
                        [ '$WATCHINGUSERNAME',
                                '$PAGEEDITDATE',
                                '$PAGEEDITTIME' ],
                        [ wfMessage( 'enotif_impersonal_salutation' )->inContentLanguage()->text(),
-                               $wgContLang->date( $this->timestamp, false, false ),
-                               $wgContLang->time( $this->timestamp, false, false ) ],
+                               $contLang->date( $this->timestamp, false, false ),
+                               $contLang->time( $this->timestamp, false, false ) ],
                        $this->body );
 
                return UserMailer::send( $addresses, $this->from, $this->subject, $body, [