Merge "Revert "Temporarily trim leading/trailing whitespace from parser test clauses""
[lhc/web/wiklou.git] / includes / OutputPage.php
index 0695443..cb90ccf 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 [];
        }
 
        /**
@@ -1166,6 +1145,20 @@ class OutputPage extends ContextSource {
                }
        }
 
+       /**
+        * Return effective list of advertised feed types
+        * @see addFeedLink()
+        *
+        * @return array Array of feed type names ( 'rss', 'atom' )
+        */
+       protected function getAdvertisedFeedTypes() {
+               if ( $this->getConfig()->get( 'Feed' ) ) {
+                       return $this->getConfig()->get( 'AdvertisedFeedTypes' );
+               } else {
+                       return [];
+               }
+       }
+
        /**
         * Add default feeds to the page header
         * This is mainly kept for backward compatibility, see OutputPage::addFeedLink()
@@ -1178,7 +1171,7 @@ class OutputPage extends ContextSource {
        public function setFeedAppendQuery( $val ) {
                $this->mFeedLinks = [];
 
-               foreach ( $this->getConfig()->get( 'AdvertisedFeedTypes' ) as $type ) {
+               foreach ( $this->getAdvertisedFeedTypes() as $type ) {
                        $query = "feed=$type";
                        if ( is_string( $val ) ) {
                                $query .= '&' . $val;
@@ -1194,7 +1187,7 @@ class OutputPage extends ContextSource {
         * @param string $href URL
         */
        public function addFeedLink( $format, $href ) {
-               if ( in_array( $format, $this->getConfig()->get( 'AdvertisedFeedTypes' ) ) ) {
+               if ( in_array( $format, $this->getAdvertisedFeedTypes() ) ) {
                        $this->mFeedLinks[$format] = $href;
                }
        }
@@ -1635,7 +1628,7 @@ class OutputPage extends ContextSource {
                }
 
                if ( !$this->mParserOptions ) {
-                       if ( !$this->getContext()->getUser()->isSafeToLoad() ) {
+                       if ( !$this->getUser()->isSafeToLoad() ) {
                                // $wgUser isn't unstubbable yet, so don't try to get a
                                // ParserOptions for it. And don't cache this ParserOptions
                                // either.
@@ -1972,7 +1965,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
@@ -2039,7 +2031,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() );
@@ -3185,7 +3176,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;
                }
@@ -3761,8 +3751,9 @@ class OutputPage extends ContextSource {
                        # or "Breaking news" one). For this, we see if $wgOverrideSiteFeed is defined.
                        # If so, use it instead.
                        $sitename = $config->get( 'Sitename' );
-                       if ( $config->get( 'OverrideSiteFeed' ) ) {
-                               foreach ( $config->get( 'OverrideSiteFeed' ) as $type => $feedUrl ) {
+                       $overrideSiteFeed = $config->get( 'OverrideSiteFeed' );
+                       if ( $overrideSiteFeed ) {
+                               foreach ( $overrideSiteFeed as $type => $feedUrl ) {
                                        // Note, this->feedLink escapes the url.
                                        $feedLinks[] = $this->feedLink(
                                                $type,
@@ -3772,7 +3763,7 @@ class OutputPage extends ContextSource {
                                }
                        } elseif ( !$this->getTitle()->isSpecial( 'Recentchanges' ) ) {
                                $rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
-                               foreach ( $config->get( 'AdvertisedFeedTypes' ) as $format ) {
+                               foreach ( $this->getAdvertisedFeedTypes() as $format ) {
                                        $feedLinks[] = $this->feedLink(
                                                $format,
                                                $rctitle->getLocalURL( [ 'feed' => $format ] ),