jenkins-bot has submitted this change and it was merged. ( 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(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified 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: merged Gerrit-Change-Id: I01cea46fa786341af073a78b294b8c5fcfba4f09 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/QuickSurveys Gerrit-Branch: master Gerrit-Owner: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: JGirault <jgira...@wikimedia.org> Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits