* (bug 3990) Use existing session name if session.auto_start is on
Fixes checks for open sessions, such as the cookie warning on login.
Patch by Zbigniew Braniecki.
-
+* Add cache-safe alternate sitenotice for anonymous users. (MediaWiki:Anonnotice)
+ This is displayed instead of the regular sitenotice, if it exists. If not, the
+ regular sitenotice shows. If that doesn't exist, the value of $wgSiteNotice is used,
+ and if that's null, then nothing is shown.
=== Caveats ===
$y = $z;
}
-function wfGetSiteNotice() {
- global $wgSiteNotice, $wgTitle, $wgOut, $parserMemc, $wgDBname;
- $fname = 'wfGetSiteNotice';
+function wfGetCachedNotice( $name ) {
+ global $wgOut, $parserMemc, $wgDBname;
+ $fname = 'wfGetCachedNotice';
wfProfileIn( $fname );
-
- $shouldParse=false;
-
- $notice = wfMsgForContent( 'sitenotice' );
- if( $notice == '<sitenotice>' || $notice == '-' ) {
- $notice = '';
- }
- if( $notice == '' ) {
- # We may also need to override a message with eg downtime info
- # FIXME: make this work!
- $notice = $wgSiteNotice;
- }
- if($notice != '-' && $notice != '') {
- $cachednotice=$parserMemc->get("{$wgDBname}:sitenotice");
- if (is_array($cachednotice)) {
- if (md5($notice)==$cachednotice['hash']) {
- $notice = $cachednotice['html'];
- } else {
- $shouldParse=true;
- }
+
+ $needParse = false;
+ $notice = wfMsgForContent( $name );
+ if( $notice == '<'. $name . ';>' || $notice == '-' ) {
+ wfProfileOut( $fname );
+ return( false );
+ }
+
+ $cachedNotice = $parserMemc->get( $wgDBname . ':' . $name );
+ if( is_array( $cachedNotice ) ) {
+ if( md5( $notice ) == $cachedNotice['hash'] ) {
+ $notice = $cachedNotice['html'];
} else {
- $shouldParse=true;
+ $needParse = true;
}
- if ($shouldParse) {
- if( is_object( $wgOut ) ) {
- $parsed = $wgOut->parse( $notice );
- $parserMemc->set("{$wgDBname}:sitenotice",
- array('html' => $parsed, 'hash' => md5($notice)), 600);
- $notice = $parsed;
- } else {
- wfDebug( "wfGetSiteNotice called with no \$wgOut available" );
- $notice = '';
- }
+ } else {
+ $needParse = true;
+ }
+
+ if( $needParse ) {
+ if( is_object( $wgOut ) ) {
+ $parsed = $wgOut->parse( $notice );
+ $parserMemc->set( $wgDBname . ':' . $name, array( 'html' => $parsed, 'hash' => md5( $notice ) ), 600 );
+ $notice = $parsed;
+ } else {
+ wfDebug( 'wfGetCachedNotice called for ' . $name . ' with no $wgOut available' );
+ $notice = '';
}
}
+
wfProfileOut( $fname );
return $notice;
}
+function wfGetSiteNotice() {
+ global $wgUser, $wgSiteNotice;
+ $fname = 'wfGetSiteNotice';
+ wfProfileIn( $fname );
+
+ if( $wgUser->isLoggedIn() ) {
+ $siteNotice = wfGetCachedNotice( 'sitenotice' );
+ $siteNotice = !$siteNotice ? $wgSiteNotice : $siteNotice;
+ } else {
+ $anonNotice = wfGetCachedNotice( 'anonnotice' );
+ if( !$anonNotice ) {
+ $siteNotice = wfGetCachedNotice( 'sitenotice' );
+ $siteNotice = !$siteNotice ? $wgSiteNotice : $siteNotice;
+ } else {
+ $siteNotice = $anonNotice;
+ }
+ }
+
+ wfProfileOut( $fname );
+ return( $siteNotice );
+}
+
/**
* Format an XML element with given attributes and, optionally, text content.
* Element and attribute names are assumed to be ready for literal inclusion.