Merge "Remove references to field rev_text_id"
[lhc/web/wiklou.git] / includes / OutputPage.php
index 732e363..b0000ab 100644 (file)
@@ -1145,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()
@@ -1157,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;
@@ -1173,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;
                }
        }
@@ -2173,7 +2187,7 @@ class OutputPage extends ContextSource {
         * Parse wikitext and return the HTML (internal implementation helper)
         *
         * @param string $text
-        * @param Title The title to use
+        * @param Title $title The title to use
         * @param bool $linestart Is this the start of a line?
         * @param bool $tidy Whether the output should be tidied
         * @param bool $interface Use interface language (instead of content language) while parsing
@@ -2970,7 +2984,7 @@ class OutputPage extends ContextSource {
         */
        public function showFileRenameError( $old, $new ) {
                wfDeprecated( __METHOD__, '1.32' );
-               $this->showFatalError( $this->msg( 'filerenameerror', $old, $new )->escpaed() );
+               $this->showFatalError( $this->msg( 'filerenameerror', $old, $new )->escaped() );
        }
 
        /**
@@ -3209,7 +3223,10 @@ class OutputPage extends ContextSource {
                // Use an IE conditional comment to serve the script only to old IE
                $pieces[] = '<!--[if lt IE 9]>' .
                        ResourceLoaderClientHtml::makeLoad(
-                               ResourceLoaderContext::newDummyContext(),
+                               new ResourceLoaderContext(
+                                       $this->getResourceLoader(),
+                                       new FauxRequest( [] )
+                               ),
                                [ 'html5shiv' ],
                                ResourceLoaderModule::TYPE_SCRIPTS,
                                [ 'sync' => true ],
@@ -3737,8 +3754,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,
@@ -3748,7 +3766,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 ] ),
@@ -3770,26 +3788,24 @@ class OutputPage extends ContextSource {
                if ( $config->get( 'EnableCanonicalServerLink' ) ) {
                        if ( $canonicalUrl !== false ) {
                                $canonicalUrl = wfExpandUrl( $canonicalUrl, PROTO_CANONICAL );
-                       } else {
-                               if ( $this->isArticleRelated() ) {
-                                       // This affects all requests where "setArticleRelated" is true. This is
-                                       // typically all requests that show content (query title, curid, oldid, diff),
-                                       // and all wikipage actions (edit, delete, purge, info, history etc.).
-                                       // It does not apply to File pages and Special pages.
-                                       // 'history' and 'info' actions address page metadata rather than the page
-                                       // content itself, so they may not be canonicalized to the view page url.
-                                       // TODO: this ought to be better encapsulated in the Action class.
-                                       $action = Action::getActionName( $this->getContext() );
-                                       if ( in_array( $action, [ 'history', 'info' ] ) ) {
-                                               $query = "action={$action}";
-                                       } else {
-                                               $query = '';
-                                       }
-                                       $canonicalUrl = $this->getTitle()->getCanonicalURL( $query );
+                       } elseif ( $this->isArticleRelated() ) {
+                               // This affects all requests where "setArticleRelated" is true. This is
+                               // typically all requests that show content (query title, curid, oldid, diff),
+                               // and all wikipage actions (edit, delete, purge, info, history etc.).
+                               // It does not apply to File pages and Special pages.
+                               // 'history' and 'info' actions address page metadata rather than the page
+                               // content itself, so they may not be canonicalized to the view page url.
+                               // TODO: this ought to be better encapsulated in the Action class.
+                               $action = Action::getActionName( $this->getContext() );
+                               if ( in_array( $action, [ 'history', 'info' ] ) ) {
+                                       $query = "action={$action}";
                                } else {
-                                       $reqUrl = $this->getRequest()->getRequestURL();
-                                       $canonicalUrl = wfExpandUrl( $reqUrl, PROTO_CANONICAL );
+                                       $query = '';
                                }
+                               $canonicalUrl = $this->getTitle()->getCanonicalURL( $query );
+                       } else {
+                               $reqUrl = $this->getRequest()->getRequestURL();
+                               $canonicalUrl = wfExpandUrl( $reqUrl, PROTO_CANONICAL );
                        }
                }
                if ( $canonicalUrl !== false ) {
@@ -3933,10 +3949,8 @@ class OutputPage extends ContextSource {
         * @return string HTML fragment
         */
        protected function styleLink( $style, array $options ) {
-               if ( isset( $options['dir'] ) ) {
-                       if ( $this->getLanguage()->getDir() != $options['dir'] ) {
-                               return '';
-                       }
+               if ( isset( $options['dir'] ) && $this->getLanguage()->getDir() != $options['dir'] ) {
+                       return '';
                }
 
                if ( isset( $options['media'] ) ) {