From 840d01d05dace67aede23653c5b32f7ea8e5efaf Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 12 Mar 2015 21:15:43 +0100 Subject: [PATCH] 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 --- includes/Title.php | 61 ++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 27 deletions(-) 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 + ); + } } } -- 2.20.1