Allow setting anonnotice to "" to prevent fallback to sitenotice
authorKevin Israel <pleasestand@live.com>
Tue, 31 Mar 2015 17:42:32 +0000 (13:42 -0400)
committerKrinkle <krinklemail@gmail.com>
Tue, 7 Apr 2015 02:30:12 +0000 (02:30 +0000)
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

RELEASE-NOTES-1.25
includes/skins/Skin.php

index 1ec8b93..7fc13bd 100644 (file)
@@ -119,6 +119,9 @@ production.
   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
index dc25c6c..ac7a85b 100644 (file)
@@ -1477,7 +1477,8 @@ abstract class Skin extends ContextSource {
         * 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;
@@ -1493,7 +1494,9 @@ abstract class Skin extends ContextSource {
                        }
                } else {
                        $msg = $this->msg( $name )->inContentLanguage();
-                       if ( $msg->isDisabled() ) {
+                       if ( $msg->isBlank() ) {
+                               return '';
+                       } elseif ( $msg->isDisabled() ) {
                                return false;
                        }
                        $notice = $msg->plain();
@@ -1554,13 +1557,13 @@ abstract class Skin extends ContextSource {
                                $siteNotice = $this->getCachedNotice( 'sitenotice' );
                        } else {
                                $anonNotice = $this->getCachedNotice( 'anonnotice' );
-                               if ( !$anonNotice ) {
+                               if ( $anonNotice === false ) {
                                        $siteNotice = $this->getCachedNotice( 'sitenotice' );
                                } else {
                                        $siteNotice = $anonNotice;
                                }
                        }
-                       if ( !$siteNotice ) {
+                       if ( $siteNotice === false ) {
                                $siteNotice = $this->getCachedNotice( 'default' );
                        }
                }