From: Timo Tijhof Date: Thu, 12 Mar 2015 20:15:43 +0000 (+0100) Subject: Title: Consider empty edit notices to not exist X-Git-Tag: 1.31.0-rc.0~12046^2~1 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=840d01d05dace67aede23653c5b32f7ea8e5efaf;p=lhc%2Fweb%2Fwiklou.git Title: Consider empty edit notices to not exist Don't include edit notices that parse to nothing in the output array. Similar filtering logic currently exists in VisualEditor. This helps support systems like the one on English Wikipedia where an Editnotice page may exist, but conditionally outputs the actual notice. Bug: T91715 Change-Id: Ic8fb038fd6acf18830cafdd09a8ca86f3950c7a5 --- diff --git a/includes/Title.php b/includes/Title.php index b04bf0436c..f47300cd03 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4685,15 +4685,18 @@ class Title { $msg = wfMessage( $editnotice_ns ); if ( $msg->exists() ) { $html = $msg->parseAsBlock(); - $notices[$editnotice_ns] = Html::rawElement( - 'div', - array( 'class' => array( - 'mw-editnotice', - 'mw-editnotice-namespace', - Sanitizer::escapeClass( "mw-$editnotice_ns" ) - ) ), - $html - ); + // Edit notices may have complex logic, but output nothing (T91715) + if ( trim( $html ) !== '' ) { + $notices[$editnotice_ns] = Html::rawElement( + 'div', + array( 'class' => array( + 'mw-editnotice', + 'mw-editnotice-namespace', + Sanitizer::escapeClass( "mw-$editnotice_ns" ) + ) ), + $html + ); + } } if ( MWNamespace::hasSubpages( $this->getNamespace() ) ) { @@ -4705,15 +4708,17 @@ class Title { $msg = wfMessage( $editnotice_base ); if ( $msg->exists() ) { $html = $msg->parseAsBlock(); - $notices[$editnotice_base] = Html::rawElement( - 'div', - array( 'class' => array( - 'mw-editnotice', - 'mw-editnotice-base', - Sanitizer::escapeClass( "mw-$editnotice_base" ) - ) ), - $html - ); + if ( trim( $html ) !== '' ) { + $notices[$editnotice_base] = Html::rawElement( + 'div', + array( 'class' => array( + 'mw-editnotice', + 'mw-editnotice-base', + Sanitizer::escapeClass( "mw-$editnotice_base" ) + ) ), + $html + ); + } } } } else { @@ -4722,15 +4727,17 @@ class Title { $msg = wfMessage( $editnoticeText ); if ( $msg->exists() ) { $html = $msg->parseAsBlock(); - $notices[$editnoticeText] = Html::rawElement( - 'div', - array( 'class' => array( - 'mw-editnotice', - 'mw-editnotice-page', - Sanitizer::escapeClass( "mw-$editnoticeText" ) - ) ), - $html - ); + if ( trim( $html ) !== '' ) { + $notices[$editnoticeText] = Html::rawElement( + 'div', + array( 'class' => array( + 'mw-editnotice', + 'mw-editnotice-page', + Sanitizer::escapeClass( "mw-$editnoticeText" ) + ) ), + $html + ); + } } }