From 16cdbfd22248217b831249addcf28cb030122767 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Mon, 18 Dec 2006 19:30:26 +0000 Subject: [PATCH] * (bug 8310) Blank line added to top of 'post' when page is blank --- RELEASE-NOTES | 1 + includes/Article.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 7fe83fd42a..e19b27ee76 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -344,6 +344,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 2785) Accept optional colon prefix in links when formatting comments * Don't show "you can view and copy the source of this page" message for pages which don't exist +* (bug 8310) Blank line added to top of 'post' when page is blank == Languages updated == diff --git a/includes/Article.php b/includes/Article.php index 1e2a9a6496..0ebd440097 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1134,13 +1134,18 @@ class Article { } $oldtext = $rev->getText(); - if($section=='new') { - if($summary) $subject="== {$summary} ==\n\n"; - $text=$oldtext."\n\n".$subject.$text; + if( $section == 'new' ) { + # Inserting a new section + $subject = $summary ? "== {$summary} ==\n\n" : ''; + $text = strlen( trim( $oldtext ) ) > 0 + ? "{$oldtext}\n\n{$subject}{$text}" + : "{$oldtext}{$subject}{$text}"; } else { + # Replacing an existing section; roll out the big guns global $wgParser; $text = $wgParser->replaceSection( $oldtext, $section, $text ); } + } wfProfileOut( __METHOD__ ); -- 2.20.1