diff options
Diffstat (limited to 'includes/RawPage.php')
-rw-r--r-- | includes/RawPage.php | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/includes/RawPage.php b/includes/RawPage.php index a0b76886..93484829 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 <wicke@wikidev.net> - * @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 ); } |