X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=e06fad96bd3ef71546e11bd38e5c16eb7fc73eec;hb=419db58c8b224db5096a1564a09177a0d0509662;hp=67c54bb16c89e6a99f30900c520097e1717a1dc5;hpb=b59ca1b44cab5f114cb4f12501e1278c2413a716;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 67c54bb16c..e06fad96bd 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -229,9 +229,6 @@ class OutputPage extends ContextSource { /** @var string */ private $mPageTitleActionText = ''; - /** @var array */ - private $mParseWarnings = array(); - /** @var int Cache stuff. Looks like mEnableClientCache */ protected $mCdnMaxage = 0; /** @var int Upper limit on mCdnMaxage */ @@ -816,7 +813,7 @@ class OutputPage extends ContextSource { $clientHeader = $this->getRequest()->getHeader( 'If-Modified-Since' ); if ( $clientHeader === false ) { - wfDebug( __METHOD__ . ": client did not send If-Modified-Since header\n", 'log' ); + wfDebug( __METHOD__ . ": client did not send If-Modified-Since header", 'private' ); return false; } @@ -845,17 +842,17 @@ class OutputPage extends ContextSource { } wfDebug( __METHOD__ . ": client sent If-Modified-Since: " . - wfTimestamp( TS_ISO_8601, $clientHeaderTime ) . "\n", 'log' ); + wfTimestamp( TS_ISO_8601, $clientHeaderTime ), 'private' ); wfDebug( __METHOD__ . ": effective Last-Modified: " . - wfTimestamp( TS_ISO_8601, $maxModified ) . "\n", 'log' ); + wfTimestamp( TS_ISO_8601, $maxModified ), 'private' ); if ( $clientHeaderTime < $maxModified ) { - wfDebug( __METHOD__ . ": STALE, $info\n", 'log' ); + wfDebug( __METHOD__ . ": STALE, $info", 'private' ); return false; } # Not modified # Give a 304 Not Modified response code and disable body output - wfDebug( __METHOD__ . ": NOT MODIFIED, $info\n", 'log' ); + wfDebug( __METHOD__ . ": NOT MODIFIED, $info", 'private' ); ini_set( 'zlib.output_compression', 0 ); $this->getRequest()->response()->statusHeader( 304 ); $this->sendCacheControl(); @@ -1773,7 +1770,6 @@ class OutputPage extends ContextSource { $this->mNewSectionLink = $parserOutput->getNewSection(); $this->mHideNewSectionLink = $parserOutput->getHideNewSection(); - $this->mParseWarnings = $parserOutput->getWarnings(); if ( !$parserOutput->isCacheable() ) { $this->enableClientCache( false ); } @@ -2184,7 +2180,7 @@ class OutputPage extends ContextSource { # We'll purge the proxy cache explicitly, but require end user agents # to revalidate against the proxy on each visit. # Surrogate-Control controls our CDN, Cache-Control downstream caches - wfDebug( __METHOD__ . ": proxy caching with ESI; {$this->mLastModified} **\n", 'log' ); + wfDebug( __METHOD__ . ": proxy caching with ESI; {$this->mLastModified} **", 'private' ); # 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' ) @@ -2195,7 +2191,7 @@ class OutputPage extends ContextSource { # to revalidate against the proxy on each visit. # 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' ); + wfDebug( __METHOD__ . ": local proxy caching; {$this->mLastModified} **", 'private' ); # 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->mCdnMaxage @@ -2204,7 +2200,7 @@ class OutputPage extends ContextSource { } else { # We do want clients to cache if they can, but they *must* check for updates # on revisiting the page. - wfDebug( __METHOD__ . ": private caching; {$this->mLastModified} **\n", 'log' ); + wfDebug( __METHOD__ . ": private caching; {$this->mLastModified} **", 'private' ); $response->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' ); $response->header( "Cache-Control: private, must-revalidate, max-age=0" ); } @@ -2212,7 +2208,7 @@ class OutputPage extends ContextSource { $response->header( "Last-Modified: {$this->mLastModified}" ); } } else { - wfDebug( __METHOD__ . ": no caching **\n", 'log' ); + wfDebug( __METHOD__ . ": no caching **", 'private' ); # In general, the absence of a last modified header should be enough to prevent # the client from using its cache. We send a few other things just to make sure. @@ -2338,15 +2334,6 @@ class OutputPage extends ContextSource { print $ins; } - /** - * Produce a "user is blocked" page. - * @deprecated since 1.18 - */ - function blockedPage() { - wfDeprecated( __METHOD__, '1.18' ); - throw new UserBlockedError( $this->getUser()->mBlock ); - } - /** * Prepare this object to display an error page; disable caching and * indexing, clear the current text and redirect, set the page's title @@ -2488,17 +2475,6 @@ class OutputPage extends ContextSource { $this->returnToMain(); } - /** - * Display an error page noting that a given permission bit is required. - * @deprecated since 1.18, just throw the exception directly - * @param string $permission Key required - * @throws PermissionsError - */ - public function permissionRequired( $permission ) { - wfDeprecated( __METHOD__, '1.18' ); - throw new PermissionsError( $permission ); - } - /** * Format a list of error messages * @@ -3502,13 +3478,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) @@ -3529,7 +3507,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() @@ -3538,7 +3516,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' @@ -3546,6 +3524,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 @@ -3824,6 +3809,58 @@ class OutputPage extends ContextSource { return $link; } + /** + * Transform path to web-accessible static resource. + * + * This is used to add a validation hash as query string. + * This aids various behaviors: + * + * - Put long Cache-Control max-age headers on responses for improved + * cache performance. + * - Get the correct version of a file as expected by the current page. + * - Instantly get the updated version of a file after deployment. + * + * Avoid using this for urls included in HTML as otherwise clients may get different + * versions of a resource when navigating the site depending on when the page was cached. + * If changes to the url propagate, this is not a problem (e.g. if the url is in + * an external stylesheet). + * + * @since 1.27 + * @param Config $config + * @param string $path Path-absolute URL to file (from document root, must start with "/") + * @return string URL + */ + public static function transformResourcePath( Config $config, $path ) { + global $IP; + $remotePath = $config->get( 'ResourceBasePath' ); + if ( strpos( $path, $remotePath ) !== 0 ) { + // Path is outside wgResourceBasePath, ignore. + return $path; + } + $path = RelPath\getRelativePath( $path, $remotePath ); + return self::transformFilePath( $remotePath, $IP, $path ); + } + + /** + * Utility method for transformResourceFilePath(). + * + * Caller is responsible for ensuring the file exists. Emits a PHP warning otherwise. + * + * @since 1.27 + * @param string $remotePath URL path that points to $localPath + * @param string $localPath File directory exposed at $remotePath + * @param string $file Path to target file relative to $localPath + * @return string URL + */ + public static function transformFilePath( $remotePath, $localPath, $file ) { + $hash = md5_file( "$localPath/$file" ); + if ( $hash === false ) { + wfLogWarning( __METHOD__ . ": Failed to hash $localPath/$file" ); + $hash = ''; + } + return "$remotePath/$file?" . substr( $hash, 0, 5 ); + } + /** * Transform "media" attribute based on request parameters * @@ -3944,20 +3981,6 @@ class OutputPage extends ContextSource { $this->addWikiText( $s ); } - /** - * Include jQuery core. Use this to avoid loading it multiple times - * before we get a usable script loader. - * - * @param array $modules List of jQuery modules which should be loaded - * @return array The list of modules which were not loaded. - * @since 1.16 - * @deprecated since 1.17 - */ - public function includeJQuery( array $modules = array() ) { - wfDeprecated( __METHOD__, '1.17' ); - return array(); - } - /** * Enables/disables TOC, doesn't override __NOTOC__ * @param bool $flag