r67825 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67824‎ | r67825 | r67826 >
Date:18:17, 10 June 2010
Author:nikerabbit
Status:ok
Tags:
Comment:
Fix part 2 of section editing, hopefully without causing regressions
Modified paths:
  • /trunk/extensions/Translate/scripts/pagetranslation-test-parser.php (modified) (history)
  • /trunk/extensions/Translate/tag/TPParse.php (modified) (history)
  • /trunk/extensions/Translate/tag/TPSection.php (modified) (history)
  • /trunk/extensions/Translate/tests/pagetranslation/LoneHeader.ptfile (added) (history)
  • /trunk/extensions/Translate/tests/pagetranslation/LoneHeader.ptsource (added) (history)

Diff [purge]

Index: trunk/extensions/Translate/scripts/pagetranslation-test-parser.php
@@ -42,12 +42,12 @@
4343 $parse = $translatablePage->getParse();
4444 if ( $failureExpected ) {
4545 $target = $parse->getTranslationPageText( new TestMessageCollection( "foo" ) );
46 - $this->output( "Testfile $filename should have failed... see $pattern.pttarget.fail" );
 46+ $this->output( "Testfile $filename should have failed... see $pattern.pttarget.fail\n" );
4747 file_put_contents( "$pattern.pttarget.fail", $target );
4848 }
4949 } catch ( TPException $e ) {
5050 if ( !$failureExpected ) {
51 - $this->output( "Testfile $filename failed to parse... see $pattern.ptfile.fail" );
 51+ $this->output( "Testfile $filename failed to parse... see $pattern.ptfile.fail\n" );
5252 file_put_contents( "$pattern.ptfile.fail", $e->getMessage() );
5353 }
5454 continue;
@@ -56,7 +56,7 @@
5757 if ( file_exists( "$pattern.ptsource" ) ) {
5858 $source = $parse->getSourcePageText();
5959 if ( $source !== file_get_contents( "$pattern.ptsource" ) ) {
60 - $this->output( "Testfile $filename failed with source page output... writing $pattern.ptsource.fail" );
 60+ $this->output( "Testfile $filename failed with source page output... writing $pattern.ptsource.fail\n" );
6161 file_put_contents( "$pattern.ptsource.fail", $source );
6262 }
6363 }
@@ -64,7 +64,7 @@
6565 if ( file_exists( "$pattern.pttarget" ) ) {
6666 $target = $parse->getTranslationPageText( new TestMessageCollection( "foo" ) );
6767 if ( $target !== file_get_contents( "$pattern.pttarget" ) ) {
68 - $this->output( "Testfile $filename failed with target page output... writing $pattern.pttarget.fail" );
 68+ $this->output( "Testfile $filename failed with target page output... writing $pattern.pttarget.fail\n" );
6969 file_put_contents( "$pattern.pttarget.fail", $target );
7070 }
7171 }
Index: trunk/extensions/Translate/tests/pagetranslation/LoneHeader.ptfile
@@ -0,0 +1,5 @@
 2+<translate>
 3+== One ==
 4+
 5+A cat sleeps.
 6+</translate>
Index: trunk/extensions/Translate/tests/pagetranslation/LoneHeader.ptsource
@@ -0,0 +1,6 @@
 2+<translate>
 3+== One == <!--T:-1-->
 4+
 5+<!--T:-1-->
 6+A cat sleeps.
 7+</translate>
Index: trunk/extensions/Translate/tag/TPParse.php
@@ -157,7 +157,7 @@
158158
159159 // Remove translation markup
160160 $cb = array( __CLASS__, 'replaceTagCb' );
161 - $text = preg_replace_callback( '~(<translate>\n?)(.*)(</translate>\n?)~sU', $cb, $text );
 161+ $text = preg_replace_callback( '~(<translate>\n??)(.*)(\n??</translate>)~sU', $cb, $text );
162162 $text = TranslatablePage::unArmourNowiki( $nph, $text );
163163
164164 return $text;
Index: trunk/extensions/Translate/tag/TPSection.php
@@ -22,8 +22,8 @@
2323 public function getMarkedText() {
2424 $id = isset( $this->name ) ? $this->name : $this->id;
2525 $header = "<!--T:{$id}-->";
26 - $re = '~^(=+.*?=+\s*?)\n~';
27 - $rep = "\\1 $header\n";
 26+ $re = '~^(=+.*?=+\s*?$)~m';
 27+ $rep = "\\1 $header";
2828 $count = 0;
2929
3030 $text = preg_replace( $re, $rep, $this->text, 1, $count );

Status & tagging log