Previously we only used Message::isDisabled (non-existent, empty string,
or "-") to decide whether to show a notice. If 'anonnotice' was disabled
'sitenotice' was shown instead.
When addressing logged-in users only, wikis typically use 'sitenotice'
and then put invisible content in 'anonnotice' (so that it shadows the
'sitenotice'). Now that the DismissableSiteNotice extension supports
closing of the notice for anonymous users (as of I87df3301c), this
becomes problematic as it has no way of knowing the notice was meant to
be invisible (and thus renders bogus "[close]" to all users).
This supersedes hacks such as <p></p> or <span></span>. Instead, the
empty string can now be used to have no anonnotice content, but also
don't show the 'sitenotice'.
Disabling with '-' (default) can still used to fallback to 'sitenotice'.
Also changed the code to, for consistency, allow hiding $wgSiteNotice
for all users by setting the sitenotice message to "-".
Bug: T94536
Change-Id: I11b8b883d480d0e07d8b395dd92360cb15de7c5b
proper, published library, which is now tagged as v1.0.0.
* A new message (defaulting to blank), 'editnotice-notext', can be shown to users
when they are editing if no edit notices apply to the page being edited.
proper, published library, which is now tagged as v1.0.0.
* A new message (defaulting to blank), 'editnotice-notext', can be shown to users
when they are editing if no edit notices apply to the page being edited.
+* (T94536) You can now make the sitenotice appear to logged-in users only by
+ editing MediaWiki:Anonnotice and replacing its content with "". Setting it to
+ "-" (default) will continue disable it and fallback to MediaWiki:Sitenotice.
==== External libraries ====
* MediaWiki now requires certain external libraries to be installed. In the past
==== External libraries ====
* MediaWiki now requires certain external libraries to be installed. In the past
* Get a cached notice
*
* @param string $name Message name, or 'default' for $wgSiteNotice
* Get a cached notice
*
* @param string $name Message name, or 'default' for $wgSiteNotice
- * @return string HTML fragment
+ * @return string|bool HTML fragment, or false to indicate that the caller
+ * should fall back to the next notice in its sequence
*/
private function getCachedNotice( $name ) {
global $wgRenderHashAppend, $parserMemc, $wgContLang;
*/
private function getCachedNotice( $name ) {
global $wgRenderHashAppend, $parserMemc, $wgContLang;
}
} else {
$msg = $this->msg( $name )->inContentLanguage();
}
} else {
$msg = $this->msg( $name )->inContentLanguage();
- if ( $msg->isDisabled() ) {
+ if ( $msg->isBlank() ) {
+ return '';
+ } elseif ( $msg->isDisabled() ) {
return false;
}
$notice = $msg->plain();
return false;
}
$notice = $msg->plain();
$siteNotice = $this->getCachedNotice( 'sitenotice' );
} else {
$anonNotice = $this->getCachedNotice( 'anonnotice' );
$siteNotice = $this->getCachedNotice( 'sitenotice' );
} else {
$anonNotice = $this->getCachedNotice( 'anonnotice' );
+ if ( $anonNotice === false ) {
$siteNotice = $this->getCachedNotice( 'sitenotice' );
} else {
$siteNotice = $anonNotice;
}
}
$siteNotice = $this->getCachedNotice( 'sitenotice' );
} else {
$siteNotice = $anonNotice;
}
}
+ if ( $siteNotice === false ) {
$siteNotice = $this->getCachedNotice( 'default' );
}
}
$siteNotice = $this->getCachedNotice( 'default' );
}
}