Use short assignment operator in PHP
[lhc/web/wiklou.git] / includes / OutputPage.php
index 9b766bb..9b7d9a0 100644 (file)
@@ -152,9 +152,6 @@ class OutputPage extends ContextSource {
        /** @var array */
        protected $mModules = [];
 
-       /** @var array */
-       protected $mModuleScripts = [];
-
        /** @var array */
        protected $mModuleStyles = [];
 
@@ -552,30 +549,12 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Get the list of script-only modules to load on this page.
-        *
-        * @param bool $filter
-        * @param string|null $position Unused
-        * @return array Array of module names
-        */
-       public function getModuleScripts( $filter = false, $position = null ) {
-               return $this->getModules( $filter, null, 'mModuleScripts',
-                       ResourceLoaderModule::TYPE_SCRIPTS
-               );
-       }
-
-       /**
-        * Load the scripts of one or more ResourceLoader modules, on this page.
-        *
-        * This method exists purely to provide the legacy behaviour of loading
-        * a module's scripts in the global scope, and without dependency resolution.
-        * See <https://phabricator.wikimedia.org/T188689>.
-        *
-        * @deprecated since 1.31 Use addModules() instead.
-        * @param string|array $modules Module name (string) or array of module names
+        * @deprecated since 1.33 Use getModules() instead.
+        * @return array
         */
-       public function addModuleScripts( $modules ) {
-               $this->mModuleScripts = array_merge( $this->mModuleScripts, (array)$modules );
+       public function getModuleScripts() {
+               wfDeprecated( __METHOD__, '1.33' );
+               return [];
        }
 
        /**
@@ -953,6 +932,8 @@ class OutputPage extends ContextSource {
         * good tags like \<i\> will be dropped entirely.
         *
         * @param string|Message $name
+        * @param-taint $name tainted
+        * Phan-taint-check gets very confused by $name being either a string or a Message
         */
        public function setPageTitle( $name ) {
                if ( $name instanceof Message ) {
@@ -966,7 +947,7 @@ class OutputPage extends ContextSource {
 
                # change "<i>foo&amp;bar</i>" to "foo&bar"
                $this->setHTMLTitle(
-                       $this->msg( 'pagetitle' )->rawParams( Sanitizer::stripAllTags( $nameWithTags ) )
+                       $this->msg( 'pagetitle' )->plaintextParams( Sanitizer::stripAllTags( $nameWithTags ) )
                                ->inContentLanguage()
                );
        }
@@ -1970,7 +1951,6 @@ class OutputPage extends ContextSource {
                $this->mNoGallery = $parserOutput->getNoGallery();
                $this->mHeadItems = array_merge( $this->mHeadItems, $parserOutput->getHeadItems() );
                $this->addModules( $parserOutput->getModules() );
-               $this->addModuleScripts( $parserOutput->getModuleScripts() );
                $this->addModuleStyles( $parserOutput->getModuleStyles() );
                $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
                $this->mPreventClickjacking = $this->mPreventClickjacking
@@ -2037,7 +2017,6 @@ class OutputPage extends ContextSource {
                $this->addParserOutputText( $parserOutput, $poOptions );
 
                $this->addModules( $parserOutput->getModules() );
-               $this->addModuleScripts( $parserOutput->getModuleScripts() );
                $this->addModuleStyles( $parserOutput->getModuleStyles() );
 
                $this->addJsConfigVars( $parserOutput->getJsConfigVars() );
@@ -2522,6 +2501,18 @@ class OutputPage extends ContextSource {
                return false;
        }
 
+       /**
+        * Get the Origin-Trial header values. This is used to enable Chrome Origin
+        * Trials: https://github.com/GoogleChrome/OriginTrials
+        *
+        * @return array
+        */
+       private function getOriginTrials() {
+               $config = $this->getConfig();
+
+               return $config->get( 'OriginTrials' );
+       }
+
        /**
         * Send cache control HTTP headers
         */
@@ -2688,6 +2679,11 @@ class OutputPage extends ContextSource {
                        $response->header( "X-Frame-Options: $frameOptions" );
                }
 
+               $originTrials = $this->getOriginTrials();
+               foreach ( $originTrials as $originTrial ) {
+                       $response->header( "Origin-Trial: $originTrial", false );
+               }
+
                ContentSecurityPolicy::sendHeaders( $this );
 
                if ( $this->mArticleBodyOnly ) {
@@ -3166,7 +3162,6 @@ class OutputPage extends ContextSource {
                        $rlClient->setConfig( $this->getJSVars() );
                        $rlClient->setModules( $this->getModules( /*filter*/ true ) );
                        $rlClient->setModuleStyles( $moduleStyles );
-                       $rlClient->setModuleScripts( $this->getModuleScripts( /*filter*/ true ) );
                        $rlClient->setExemptStates( $exemptStates );
                        $this->rlClient = $rlClient;
                }