Merge "mw.Upload.BookletLayout: Require non-whitespace description"
[lhc/web/wiklou.git] / includes / OutputPage.php
index c35204d..78eb458 100644 (file)
@@ -233,8 +233,8 @@ class OutputPage extends ContextSource {
        private $mParseWarnings = array();
 
        /** @var int Cache stuff. Looks like mEnableClientCache */
-       protected $mSquidMaxage = 0;
-       /** @var int Upper limit on mSquidMaxage */
+       protected $mCdnMaxage = 0;
+       /** @var int Upper limit on mCdnMaxage */
        protected $mCdnMaxageLimit = INF;
 
        /**
@@ -1032,17 +1032,6 @@ class OutputPage extends ContextSource {
                $this->addSubtitle( $str );
        }
 
-       /**
-        * Add $str to the subtitle
-        *
-        * @deprecated since 1.19; use addSubtitle() instead
-        * @param string|Message $str String or Message to add to the subtitle
-        */
-       public function appendSubtitle( $str ) {
-               wfDeprecated( __METHOD__, '1.19' );
-               $this->addSubtitle( $str );
-       }
-
        /**
         * Add $str to the subtitle
         *
@@ -1354,6 +1343,8 @@ class OutputPage extends ContextSource {
                        array( &$this, $categories, &$this->mCategoryLinks ) )
                ) {
                        foreach ( $categories as $category => $type ) {
+                               // array keys will cast numeric category names to ints, so cast back to string
+                               $category = (string)$category;
                                $origcategory = $category;
                                $title = Title::makeTitleSafe( NS_CATEGORY, $category );
                                if ( !$title ) {
@@ -1941,24 +1932,32 @@ class OutputPage extends ContextSource {
                return Parser::stripOuterParagraph( $parsed );
        }
 
+       /**
+        * @param $maxage
+        * @deprecated since 1.27 Use setCdnMaxage() instead
+        */
+       public function setSquidMaxage( $maxage ) {
+               $this->setCdnMaxage( $maxage );
+       }
+
        /**
         * Set the value of the "s-maxage" part of the "Cache-control" HTTP header
         *
-        * @param int $maxage Maximum cache time on the Squid, in seconds.
+        * @param int $maxage Maximum cache time on the CDN, in seconds.
         */
-       public function setSquidMaxage( $maxage ) {
-               $this->mSquidMaxage = min( $maxage, $this->mCdnMaxageLimit );
+       public function setCdnMaxage( $maxage ) {
+               $this->mCdnMaxage = min( $maxage, $this->mCdnMaxageLimit );
        }
 
        /**
         * Lower the value of the "s-maxage" part of the "Cache-control" HTTP header
         *
-        * @param int $maxage Maximum cache time on the Squid, in seconds
+        * @param int $maxage Maximum cache time on the CDN, in seconds
         * @since 1.27
         */
        public function lowerCdnMaxage( $maxage ) {
                $this->mCdnMaxageLimit = min( $maxage, $this->mCdnMaxageLimit );
-               $this->setSquidMaxage( $this->mSquidMaxage );
+               $this->setCdnMaxage( $this->mCdnMaxage );
        }
 
        /**
@@ -2179,27 +2178,27 @@ class OutputPage extends ContextSource {
                if ( $this->mEnableClientCache ) {
                        if (
                                $config->get( 'UseSquid' ) && session_id() == '' && !$this->isPrintable() &&
-                               $this->mSquidMaxage != 0 && !$this->haveCacheVaryCookies()
+                               $this->mCdnMaxage != 0 && !$this->haveCacheVaryCookies()
                        ) {
                                if ( $config->get( 'UseESI' ) ) {
                                        # We'll purge the proxy cache explicitly, but require end user agents
                                        # to revalidate against the proxy on each visit.
-                                       # Surrogate-Control controls our Squid, Cache-Control downstream caches
+                                       # Surrogate-Control controls our CDN, Cache-Control downstream caches
                                        wfDebug( __METHOD__ . ": proxy caching with ESI; {$this->mLastModified} **\n", 'log' );
                                        # start with a shorter timeout for initial testing
                                        # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
                                        $response->header( 'Surrogate-Control: max-age=' . $config->get( 'SquidMaxage' )
-                                               . '+' . $this->mSquidMaxage . ', content="ESI/1.0"' );
+                                               . '+' . $this->mCdnMaxage . ', content="ESI/1.0"' );
                                        $response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
                                } else {
                                        # We'll purge the proxy cache for anons explicitly, but require end user agents
                                        # to revalidate against the proxy on each visit.
-                                       # IMPORTANT! The Squid needs to replace the Cache-Control header with
+                                       # IMPORTANT! The CDN needs to replace the Cache-Control header with
                                        # Cache-Control: s-maxage=0, must-revalidate, max-age=0
                                        wfDebug( __METHOD__ . ": local proxy caching; {$this->mLastModified} **\n", 'log' );
                                        # start with a shorter timeout for initial testing
                                        # header( "Cache-Control: s-maxage=2678400, must-revalidate, max-age=0" );
-                                       $response->header( 'Cache-Control: s-maxage=' . $this->mSquidMaxage
+                                       $response->header( 'Cache-Control: s-maxage=' . $this->mCdnMaxage
                                                . ', must-revalidate, max-age=0' );
                                }
                        } else {
@@ -2429,7 +2428,7 @@ class OutputPage extends ContextSource {
                        # not especially useful as a returnto parameter. Use the title
                        # from the request instead, if there was one.
                        $request = $this->getRequest();
-                       $returnto = Title::newFromURL( $request->getVal( 'title', '' ) );
+                       $returnto = Title::newFromText( $request->getVal( 'title', '' ) );
                        if ( $action == 'edit' ) {
                                $msg = 'whitelistedittext';
                                $displayReturnto = $returnto;
@@ -2500,16 +2499,6 @@ class OutputPage extends ContextSource {
                throw new PermissionsError( $permission );
        }
 
-       /**
-        * Produce the stock "please login to use the wiki" page
-        *
-        * @deprecated since 1.19; throw the exception directly
-        */
-       public function loginToUse() {
-               wfDeprecated( __METHOD__, '1.19' );
-               throw new PermissionsError( 'read' );
-       }
-
        /**
         * Format a list of error messages
         *
@@ -2901,7 +2890,7 @@ class OutputPage extends ContextSource {
                                // on-wiki like user pages, or user preferences; we need to find the highest
                                // timestamp of these user-changeable modules so we can ensure cache misses on change
                                // This should NOT be done for the site group (bug 27564) because anons get that too
-                               // and we shouldn't be putting timestamps in Squid-cached HTML
+                               // and we shouldn't be putting timestamps in CDN-cached HTML
                                $version = null;
                                if ( $group === 'user' ) {
                                        $query['version'] = $resourceLoader->getCombinedVersion( $context, array_keys( $grpModules ) );
@@ -3513,13 +3502,15 @@ class OutputPage extends ContextSource {
 
                # Feeds
                if ( $config->get( 'Feed' ) ) {
+                       $feedLinks = array();
+
                        foreach ( $this->getSyndicationLinks() as $format => $link ) {
                                # Use the page name for the title.  In principle, this could
                                # lead to issues with having the same name for different feeds
                                # corresponding to the same page, but we can't avoid that at
                                # this low a level.
 
-                               $tags[] = $this->feedLink(
+                               $feedLinks[] = $this->feedLink(
                                        $format,
                                        $link,
                                        # Used messages: 'page-rss-feed' and 'page-atom-feed' (for an easier grep)
@@ -3540,7 +3531,7 @@ class OutputPage extends ContextSource {
                        if ( $config->get( 'OverrideSiteFeed' ) ) {
                                foreach ( $config->get( 'OverrideSiteFeed' ) as $type => $feedUrl ) {
                                        // Note, this->feedLink escapes the url.
-                                       $tags[] = $this->feedLink(
+                                       $feedLinks[] = $this->feedLink(
                                                $type,
                                                $feedUrl,
                                                $this->msg( "site-{$type}-feed", $sitename )->text()
@@ -3549,7 +3540,7 @@ class OutputPage extends ContextSource {
                        } elseif ( !$this->getTitle()->isSpecial( 'Recentchanges' ) ) {
                                $rctitle = SpecialPage::getTitleFor( 'Recentchanges' );
                                foreach ( $config->get( 'AdvertisedFeedTypes' ) as $format ) {
-                                       $tags[] = $this->feedLink(
+                                       $feedLinks[] = $this->feedLink(
                                                $format,
                                                $rctitle->getLocalURL( array( 'feed' => $format ) ),
                                                # For grep: 'site-rss-feed', 'site-atom-feed'
@@ -3557,6 +3548,13 @@ class OutputPage extends ContextSource {
                                        );
                                }
                        }
+
+                       # Allow extensions to change the list pf feeds. This hook is primarily for changing,
+                       # manipulating or removing existing feed tags. If you want to add new feeds, you should
+                       # use OutputPage::addFeedLink() instead.
+                       Hooks::run( 'AfterBuildFeedLinks', array( &$feedLinks ) );
+
+                       $tags += $feedLinks;
                }
 
                # Canonical URL