X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FRawPage.php;h=93484829a14b06745282cd521f47cb56466c1fdc;hb=72a4abe588a7511ed5a92a5e30f889c60d824c1a;hp=a0b76886cdc48d63e11f166b6edb7b08f9d85c27;hpb=373393b0f0ba3060a078cd819f9572a606894492;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/RawPage.php b/includes/RawPage.php index a0b76886cd..93484829a1 100644 --- a/includes/RawPage.php +++ b/includes/RawPage.php @@ -7,12 +7,11 @@ * License: GPL (http://www.gnu.org/copyleft/gpl.html) * * @author Gabriel Wicke - * @package MediaWiki */ /** - * @todo document - * @package MediaWiki + * A simple method to retrieve the plain source of an article, + * using "action=raw" in the GET request string. */ class RawPage { var $mArticle, $mTitle, $mRequest; @@ -20,9 +19,8 @@ class RawPage { var $mSmaxage, $mMaxage; var $mContentType, $mExpandTemplates; - function RawPage( &$article, $request = false ) { + function __construct( &$article, $request = false ) { global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType; - global $wgUser; $allowedCTypes = array('text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit'); $this->mArticle =& $article; @@ -39,7 +37,7 @@ class RawPage { $maxage = $this->mRequest->getInt( 'maxage', $wgSquidMaxage ); $this->mExpandTemplates = $this->mRequest->getVal( 'templates' ) === 'expand'; $this->mUseMessageCache = $this->mRequest->getBool( 'usemsgcache' ); - + $oldid = $this->mRequest->getInt( 'oldid' ); switch ( $wgRequest->getText( 'direction' ) ) { case 'next': @@ -85,8 +83,7 @@ class RawPage { // Output may contain user-specific data; vary for open sessions $this->mPrivateCache = ( $this->mSmaxage == 0 ) || - ( isset( $_COOKIE[ini_get( 'session.name' )] ) || - $wgUser->isLoggedIn() ); + ( session_id() != '' ); if ( $ctype == '' or ! in_array( $ctype, $allowedCTypes ) ) { $this->mContentType = 'text/x-wiki'; @@ -137,7 +134,13 @@ class RawPage { # allow the client to cache this for 24 hours $mode = $this->mPrivateCache ? 'private' : 'public'; header( 'Cache-Control: '.$mode.', s-maxage='.$this->mSmaxage.', max-age='.$this->mMaxage ); - echo $this->getRawText(); + $text = $this->getRawText(); + + if( !wfRunHooks( 'RawPageViewBeforeOutput', array( &$this, &$text ) ) ) { + wfDebug( __METHOD__ . ': RawPageViewBeforeOutput hook broke raw page output.' ); + } + + echo $text; $wgOut->disable(); } @@ -189,6 +192,20 @@ class RawPage { header( "HTTP/1.0 404 Not Found" ); } + // Special-case for empty CSS/JS + // + // Internet Explorer for Mac handles empty files badly; + // particularly so when keep-alive is active. It can lead + // to long timeouts as it seems to sit there waiting for + // more data that never comes. + // + // Give it a comment... + if( strlen( $text ) == 0 && + ($this->mContentType == 'text/css' || + $this->mContentType == 'text/javascript' ) ) { + return "/* Empty */"; + } + return $this->parseArticleText( $text ); }