*/
function checkLastModified ( $timestamp ) {
global $wgLang, $wgCachePages, $wgUser;
- $timestamp=wfTimestamp(TS_MW,$timestamp);
- if( !$wgCachePages ) {
- wfDebug( "CACHE DISABLED\n", false );
+ if ( !$timestamp || $timestamp == '19700101000000' ) {
+ wfDebug( "CACHE DISABLED, NO TIMESTAMP\n" );
return;
}
- if( isset( $_SERVER["HTTP_USER_AGENT"] ) &&
- preg_match( '/MSIE ([1-4]|5\.0)/', $_SERVER["HTTP_USER_AGENT"] ) ) {
- # IE 5.0 has probs with our caching
- wfDebug( "-- bad client, not caching\n", false );
+ if( !$wgCachePages ) {
+ wfDebug( "CACHE DISABLED\n", false );
return;
}
if( $wgUser->getOption( 'nocache' ) ) {
return;
}
+ $timestamp=wfTimestamp(TS_MW,$timestamp);
$lastmod = wfTimestamp( TS_RFC2822, max( $timestamp, $wgUser->mTouched ) );
if( !empty( $_SERVER['HTTP_IF_MODIFIED_SINCE'] ) ) {
$ismodsince = wfTimestamp( TS_MW, strtotime( $modsince ) );
wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false );
wfDebug( "-- we might send Last-Modified : $lastmod\n", false );
- if( ($ismodsince >= $timestamp ) and $wgUser->validateCache( $ismodsince ) ) {
+ if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) ) {
# Make sure you're in a place you can leave when you call us!
header( "HTTP/1.0 304 Not Modified" );
$this->mLastModified = $lastmod;
$this->mLastModified = $lastmod;
}
} else {
- wfDebug( "We're confused.\n", false );
+ wfDebug( "client did not send If-Modified-Since header\n", false );
$this->mLastModified = $lastmod;
}
}
function sendCacheControl() {
global $wgUseSquid, $wgUseESI;
- # FIXME: This header may cause trouble with some versions of Internet Explorer
+ # don't serve compressed data to clients who can't handle it
+ # maintain different caches for logged-in users and non-logged in ones
header( 'Vary: Accept-Encoding, Cookie' );
if( $this->mEnableClientCache ) {
if( $wgUseSquid && ! isset( $_COOKIE[ini_get( 'session.name') ] ) &&
}
function databaseError( $fname, $sql, $error, $errno ) {
- global $wgUser, $wgCommandLineMode;
+ global $wgUser, $wgCommandLineMode, $wgShowSQLErrors;
$this->setPageTitle( wfMsgNoDB( 'databaseerror' ) );
$this->setRobotpolicy( 'noindex,nofollow' );
$this->enableClientCache( false );
$this->mRedirect = '';
- if ( $wgCommandLineMode ) {
- $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
- htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
+ if( $wgShowSQLErrors ) {
+ if ( $wgCommandLineMode ) {
+ $msg = wfMsgNoDB( 'dberrortextcl', htmlspecialchars( $sql ),
+ htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
+ } else {
+ $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
+ htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
+ }
} else {
- $msg = wfMsgNoDB( 'dberrortext', htmlspecialchars( $sql ),
- htmlspecialchars( $fname ), $errno, htmlspecialchars( $error ) );
+ if( $wgCommandLineMode ) {
+ $msg = wfMsg( 'internalerror' );
+ } else {
+ $msg = htmlspecialchars( wfMsg( 'internalerror' ) );
+ }
}
if ( $wgCommandLineMode || !is_object( $wgUser )) {
global $wgDocType, $wgDTD, $wgContLanguageCode, $wgOutputEncoding, $wgMimeType;
global $wgUser, $wgContLang, $wgRequest;
- $xml = ($wgMimeType == 'text/xml');
- if( $xml ) {
+ if( $wgMimeType == 'text/xml' || $wgMimeType == 'application/xhtml+xml' || $wgMimeType == 'application/xml' ) {
$ret = "<" . "?xml version=\"1.0\" encoding=\"$wgOutputEncoding\" ?" . ">\n";
} else {
$ret = '';
if ( "" == $this->mHTMLtitle ) {
$this->mHTMLtitle = wfMsg( "pagetitle", $this->mPagetitle );
}
- if( $xml ) {
- $xmlbits = "xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"";
- } else {
- $xmlbits = '';
- }
+
$rtl = $wgContLang->isRTL() ? " dir='RTL'" : '';
- $ret .= "<html $xmlbits lang=\"$wgContLanguageCode\" $rtl>\n";
+ $ret .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"$wgContLanguageCode\" lang=\"$wgContLanguageCode\" $rtl>\n";
$ret .= "<head>\n<title>" . htmlspecialchars( $this->mHTMLtitle ) . "</title>\n";
array_push( $this->mMetatags, array( "http:Content-type", "$wgMimeType; charset={$wgOutputEncoding}" ) );