X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Factions%2FRawAction.php;h=5bf24f60e683ccb0b3393d7310aa4b13d3619c6f;hb=dae0ebbe663b0dda2ddd04d69e552582a2fb2ff5;hp=b04ffbe2d969597c84b11e774bd7db9492db083b;hpb=a77c09c03baf8ee1dd7527db4c20c5be2cd2c298;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/actions/RawAction.php b/includes/actions/RawAction.php index b04ffbe2d9..5bf24f60e6 100644 --- a/includes/actions/RawAction.php +++ b/includes/actions/RawAction.php @@ -33,14 +33,6 @@ * @ingroup Actions */ class RawAction extends FormlessAction { - /** - * @var bool Does the request include a gen=css|javascript parameter - * @deprecated This used to be a string for "css" or "javascript" but - * it is no longer used. Setting this parameter results in empty content - * being served - */ - private $gen = false; - public function getName() { return 'raw'; } @@ -56,6 +48,7 @@ class RawAction extends FormlessAction { function onView() { $this->getOutput()->disable(); $request = $this->getRequest(); + $response = $request->response(); $config = $this->context->getConfig(); if ( !$request->checkUrlExtension() ) { @@ -66,42 +59,40 @@ class RawAction extends FormlessAction { return; // Client cache fresh and headers sent, nothing more to do. } - # special case for 'generated' raw things: user css/js - # This is deprecated and will only return empty content $gen = $request->getVal( 'gen' ); - $smaxage = $request->getIntOrNull( 'smaxage' ); - if ( $gen == 'css' || $gen == 'js' ) { $this->gen = true; - if ( $smaxage === null ) { - $smaxage = $config->get( 'SquidMaxage' ); - } } $contentType = $this->getContentType(); - # Force caching for CSS and JS raw content, default: 5 minutes. - # Note: If using a canonical url for userpage css/js, we send an HTCP purge. + $maxage = $request->getInt( 'maxage', $config->get( 'SquidMaxage' ) ); + $smaxage = $request->getIntOrNull( 'smaxage' ); if ( $smaxage === null ) { if ( $contentType == 'text/css' || $contentType == 'text/javascript' ) { + // CSS/JS raw content has its own CDN max age configuration. + // Note: Title::getCdnUrls() includes action=raw for css/js pages, + // so if using the canonical url, this will get HTCP purges. $smaxage = intval( $config->get( 'ForcedRawSMaxage' ) ); } else { + // No CDN cache for anything else $smaxage = 0; } } - $maxage = $request->getInt( 'maxage', $config->get( 'SquidMaxage' ) ); - - $response = $request->response(); + // Set standard Vary headers so cache varies on cookies and such (T125283) + $response->header( $this->getOutput()->getVaryHeader() ); + if ( $config->get( 'UseKeyHeader' ) ) { + $response->header( $this->getOutput()->getKeyHeader() ); + } $response->header( 'Content-type: ' . $contentType . '; charset=UTF-8' ); - # Output may contain user-specific data; - # vary generated content for open sessions on private wikis - $privateCache = !User::isEveryoneAllowed( 'read' ) && ( $smaxage == 0 || session_id() != '' ); - // Bug 53032 - make this private if user is logged in, - // so we don't accidentally cache cookies - $privateCache = $privateCache ?: $this->getUser()->isLoggedIn(); - # allow the client to cache this for 24 hours + // Output may contain user-specific data; + // vary generated content for open sessions on private wikis + $privateCache = !User::isEveryoneAllowed( 'read' ) && + ( $smaxage == 0 || MediaWiki\Session\SessionManager::getGlobalSession()->isPersistent() ); + // Don't accidentally cache cookies if user is logged in (T55032) + $privateCache = $privateCache || $this->getUser()->isLoggedIn(); $mode = $privateCache ? 'private' : 'public'; $response->header( 'Cache-Control: ' . $mode . ', s-maxage=' . $smaxage . ', max-age=' . $maxage @@ -117,7 +108,7 @@ class RawAction extends FormlessAction { $response->statusHeader( 404 ); } - if ( !Hooks::run( 'RawPageViewBeforeOutput', array( &$this, &$text ) ) ) { + if ( !Hooks::run( 'RawPageViewBeforeOutput', [ &$this, &$text ] ) ) { wfDebug( __METHOD__ . ": RawPageViewBeforeOutput hook broke raw page output.\n" ); } @@ -133,11 +124,6 @@ class RawAction extends FormlessAction { public function getRawText() { global $wgParser; - # No longer used - if ( $this->gen ) { - return ''; - } - $text = false; $title = $this->getTitle(); $request = $this->getRequest(); @@ -248,7 +234,7 @@ class RawAction extends FormlessAction { } } - $allowedCTypes = array( 'text/x-wiki', 'text/javascript', 'text/css', 'application/x-zope-edit' ); + $allowedCTypes = [ 'text/x-wiki', 'text/javascript', 'text/css', 'application/x-zope-edit' ]; if ( $ctype == '' || !in_array( $ctype, $allowedCTypes ) ) { $ctype = 'text/x-wiki'; }