r67849 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67848‎ | r67849 | r67850 >
Date:12:30, 11 June 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Remove newline from at start and end manually, because the regexp is too inefficient and fails otherwise
Modified paths:
  • /trunk/extensions/Translate/tag/TPParse.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/tag/TPParse.php
@@ -159,7 +159,7 @@
160160
161161 // Remove translation markup
162162 $cb = array( __CLASS__, 'replaceTagCb' );
163 - $text = preg_replace_callback( '~(<translate>\n??)(.*)(\n??</translate>)~sU', $cb, $text );
 163+ $text = preg_replace_callback( '~(<translate>)(.*)(</translate>)~sU', $cb, $text );
164164 $text = TranslatablePage::unArmourNowiki( $nph, $text );
165165
166166 return $text;
@@ -174,6 +174,6 @@
175175 }
176176
177177 protected static function replaceTagCb( $matches ) {
178 - return $matches[2];
 178+ return preg_replace( '~^\n|\n\z~', '', $matches[2] );
179179 }
180180 }

Status & tagging log