jenkins-bot has submitted this change and it was merged.

Change subject: Use Config instead of globals
......................................................................


Use Config instead of globals

Change-Id: Ia01150e76e3a960841c096377d005521bbfdd4d0
---
M SpecialNotifyTranslators.php
M SpecialTranslatorSignup.php
M scripts/DigestEmailer.php
3 files changed, 34 insertions(+), 37 deletions(-)

Approvals:
  Nikerabbit: Checked; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/SpecialNotifyTranslators.php b/SpecialNotifyTranslators.php
index 4049f6e..60aca85 100644
--- a/SpecialNotifyTranslators.php
+++ b/SpecialNotifyTranslators.php
@@ -420,19 +420,22 @@
         * @return string Sinup URL
         */
        protected function getSignupURL() {
-               global $wgTranslationNotificationsAlwaysHttpsInEmail;
-
-               $urlType = $wgTranslationNotificationsAlwaysHttpsInEmail === 
false ?
-                       PROTO_CANONICAL :
-                       PROTO_HTTPS;
-
                $signupURL = SpecialPage::getTitleFor( 'TranslatorSignup' 
)->getFullURL(
                        '',
                        false,
-                       $urlType
+                       $this->getUrlProtocol()
                );
 
                return $signupURL;
+       }
+
+       /**
+        * @return string
+        */
+       protected function getUrlProtocol() {
+               return $this->getConfig()->get( 
'TranslationNotificationsAlwaysHttpsInEmail' ) === false
+                       ? PROTO_CANONICAL
+                       : PROTO_HTTPS;
        }
 
        /**
@@ -440,13 +443,7 @@
         * @return string Translation URL
         */
        protected function getTranslationURL( $languageCode ) {
-               global $wgTranslationNotificationsAlwaysHttpsInEmail;
-
                $page = TranslatablePage::newFromTitle( 
$this->translatablePageTitle );
-               $urlType = $wgTranslationNotificationsAlwaysHttpsInEmail === 
false ?
-                       PROTO_CANONICAL :
-                       PROTO_HTTPS;
-
                $translationURL = SpecialPage::getTitleFor( 'Translate' 
)->getFullURL(
                        [
                                'group' => $page->getMessageGroupId(),
@@ -454,7 +451,7 @@
                                'action' => 'page'
                        ],
                        false,
-                       $urlType
+                       $this->getUrlProtocol()
                );
 
                return $translationURL;
@@ -552,8 +549,6 @@
        protected function sendTranslationNotificationEmail( User $user,
                $languagesToNotify = []
        ) {
-               global $wgNoReplyAddress;
-
                $relevantLanguages = $this->getRelevantLanguages( $user, 
$languagesToNotify );
                $userFirstLanguage = Language::factory( 
$this->getUserFirstLanguage( $user ) );
                $emailSubject = self::getNotificationSubject( 
$userFirstLanguage );
@@ -583,7 +578,7 @@
 
                // Do not publish the sender's email, but include his/her name
                $emailFrom = new MailAddress(
-                       $wgNoReplyAddress,
+                       $this->getConfig()->get( 'NoReplyAddress' ),
                        $sender->getName(),
                        $sender->getRealName()
                );
@@ -628,12 +623,11 @@
                        $this->notificationText
                );
 
-               global $wgLocalInterwikis;
-
                $titleForMessage = $this->translatablePageTitle;
 
-               if ( $destination === 'talkpageInOtherWiki' && count( 
$wgLocalInterwikis ) ) {
-                       $titleForMessage = 
":$wgLocalInterwikis[0]:$titleForMessage|$titleForMessage";
+               $localInterwikis = $this->getConfig()->get( 'LocalInterwikis' );
+               if ( $destination === 'talkpageInOtherWiki' && count( 
$localInterwikis ) ) {
+                       $titleForMessage = 
":$localInterwikis[0]:$titleForMessage|$titleForMessage";
                }
 
                $text = $this->msg(
diff --git a/SpecialTranslatorSignup.php b/SpecialTranslatorSignup.php
index 2be9876..e1bc8f4 100644
--- a/SpecialTranslatorSignup.php
+++ b/SpecialTranslatorSignup.php
@@ -40,8 +40,6 @@
        }
 
        protected function alterForm( HTMLForm $form ) {
-               global $wgTranslationNotificationsSignupLegalMessage;
-
                $form->setWrapperLegend( false );
                $form->setId( 'translationnotifications-form' );
                $form->setSubmitID( 'translationnotifications-submit' );
@@ -49,21 +47,23 @@
                // Override FormSpecialPage. Otherwise 
'translationnotifications-text'
                // shown on Special:NotifyTranslators is shown here
                $form->setHeaderText( $this->msg( 'translatorsignup-summary' 
)->parseAsBlock() );
+       }
 
-               if ( $wgTranslationNotificationsSignupLegalMessage ) {
+       protected function postText() {
+               $legalMsg = $this->getConfig()->get( 
'TranslationNotificationsSignupLegalMessage' );
+               if ( $legalMsg ) {
                        // Show the legal text regarding the notifications.
                        // Do not show if value is empty or false.
-                       $legalText = Html::rawElement(
+                       return Html::rawElement(
                                'div',
                                [ 'class' => 'mw-infobox' ],
-                               $this->msg( 
$wgTranslationNotificationsSignupLegalMessage )->parseAsBlock()
+                               $this->msg( $legalMsg )->parseAsBlock()
                        );
-                       $form->addPostText( $legalText );
                }
+               return '';
        }
 
        protected function getFormFields() {
-               global $wgTranslationNotificationsContactMethods;
                $this->getOutput()->addModules( 
'ext.translationnotifications.translatorsignup' );
                $user = $this->getUser();
 
@@ -131,7 +131,9 @@
                        }
                }
 
-               foreach ( $wgTranslationNotificationsContactMethods as $method 
=> $value ) {
+               $config = $this->getConfig();
+               $contactMethods = $config->get( 
'TranslationNotificationsContactMethods' );
+               foreach ( $contactMethods as $method => $value ) {
                        if ( $value === false ) {
                                continue;
                        }
@@ -151,8 +153,8 @@
                                $m["cmethod-$method"]['disabled'] = 
!$user->canReceiveEmail();
                        }
 
-                       global $wgLocalInterwikis;
-                       if ( $method === 'talkpage-elsewhere' && count( 
$wgLocalInterwikis ) ) {
+                       $localInterwikis = $config->get( 'LocalInterwikis' );
+                       if ( $method === 'talkpage-elsewhere' && count( 
$localInterwikis ) ) {
                                $m['cmethod-talkpage-elsewhere-loc'] = [
                                        'type' => 'select',
                                        'default' => $user->getOption( 
'translationnotifications-cmethod-talkpage-elsewhere-loc' ),
diff --git a/scripts/DigestEmailer.php b/scripts/DigestEmailer.php
index 8f95b93..7aec0b5 100644
--- a/scripts/DigestEmailer.php
+++ b/scripts/DigestEmailer.php
@@ -42,7 +42,12 @@
        }
 
        public function sendEmails( $translators, $notifications ) {
-               global $wgNoReplyAddress, 
$wgTranslationNotificationsAlwaysHttpsInEmail;
+               $config = $this->getConfig();
+               // Initialize early to avoid calling these repeatedly within 
the loop
+               $noReplyAddress = $config->get( 'NoReplyAddress' );
+               $urlType = $config->get( 
'TranslationNotificationsAlwaysHttpsInEmail' ) === false
+                       ? PROTO_CANONICAL
+                       : PROTO_HTTPS;
 
                $mailstatus = [];
                foreach ( $translators as $translator ) {
@@ -90,10 +95,6 @@
                        }
                        $this->output( "\tSending notification since " .
                                date( 'D M j G:i:s T Y', $startTimeStamp ) . " 
\n" );
-
-                       $urlType = 
$wgTranslationNotificationsAlwaysHttpsInEmail === false ?
-                               PROTO_CANONICAL :
-                               PROTO_HTTPS;
 
                        foreach ( $notifications as $notification ) {
                                $announcedate = strtotime( 
$notification['announcedate'] );
@@ -179,7 +180,7 @@
                                $signupURL
                        )->inLanguage( $firstLangCode )->text();
 
-                       $emailFrom = new MailAddress( $wgNoReplyAddress );
+                       $emailFrom = new MailAddress( $noReplyAddress );
                        $emailTo = new MailAddress( $user );
                        $params = [
                                'to' => $emailTo,

-- 
To view, visit https://gerrit.wikimedia.org/r/293901
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia01150e76e3a960841c096377d005521bbfdd4d0
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/TranslationNotifications
Gerrit-Branch: master
Gerrit-Owner: Glaisher <[email protected]>
Gerrit-Reviewer: Glaisher <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to