Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/341391 )

Change subject: Defer wfMessage fetch for ExternalSurvey::isInsecure
......................................................................

Defer wfMessage fetch for ExternalSurvey::isInsecure

Avoids having to initialize LocalisationCache and MessageCache as part
of getEnabledSurveys(), as used by onResourceLoaderRegisterModules(),
because it runs as part of the class constructor, but is not used
by Survey::isEnabled()

Bug: T159748
Change-Id: I01cea46fa786341af073a78b294b8c5fcfba4f09
---
M includes/ExternalSurvey.php
1 file changed, 11 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/QuickSurveys 
refs/changes/91/341391/1

diff --git a/includes/ExternalSurvey.php b/includes/ExternalSurvey.php
index cc42e7d..33a037e 100644
--- a/includes/ExternalSurvey.php
+++ b/includes/ExternalSurvey.php
@@ -4,9 +4,9 @@
 
 class ExternalSurvey extends Survey {
        /**
-        * @var bool whether the survey runs on https or not.
+        * @var bool Whether the survey runs on HTTPS or not.
         */
-       private $isInsecure;
+       private $isInsecure = null;
 
        /**
         * @var string The name of the external survey.
@@ -47,12 +47,18 @@
                $this->name = $name;
                $this->link = $link;
                $this->instanceTokenParameterName = $instanceTokenParameterName;
-               $url = wfMessage( $this->link )->inContentLanguage()->plain();
-               $this->isInsecure = strpos( $url, 'http:' ) === 0;
        }
 
        public function getMessages() {
                return array_merge( parent::getMessages(), [ $this->link ] );
+       }
+
+       private function getIsInsecure() {
+               if ( $this->isInsecure === null ) {
+                       $url = wfMessage( $this->link 
)->inContentLanguage()->plain();
+                       $this->isInsecure = strpos( $url, 'http:' ) === 0;
+               }
+               return $this->isInsecure;
        }
 
        public function toArray() {
@@ -61,7 +67,7 @@
                        'type' => 'external',
                        'link' => $this->link,
                        'instanceTokenParameterName' => 
$this->instanceTokenParameterName,
-                       'isInsecure' => $this->isInsecure,
+                       'isInsecure' => $this->getIsInsecure(),
                ];
        }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I01cea46fa786341af073a78b294b8c5fcfba4f09
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/QuickSurveys
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to