Wikitext should not have trailing whitespace.
Change-Id: I75eb1c4bef7217ec2b7440594e3fc4b68dc3c022
return $this->getNativeData();
}
+ /**
+ * Returns a Content object with pre-save transformations applied.
+ * This implementation just trims trailing whitespace.
+ *
+ * @param $title Title
+ * @param $user User
+ * @param $popts ParserOptions
+ * @return Content
+ */
+ public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) {
+ $text = $this->getNativeData();
+ $pst = rtrim( $text );
+
+ return ( $text === $pst ) ? $this : new WikitextContent( $pst );
+ }
+
/**
* Diff this content object with another content object..
*
$text = $this->getNativeData();
$pst = $wgParser->preSaveTransform( $text, $title, $user, $popts );
+ rtrim( $pst );
- return new WikitextContent( $pst );
+ return ( $text === $pst ) ? $this : new WikitextContent( $pst );
}
/**
array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
),
+ array( " Foo \n ",
+ " Foo",
+ ),
);
}
public function dataPreSaveTransform() {
return array(
- array( 'hello this is ~~~',
- "hello this is ~~~",
+ array( #0: no signature resolution
+ "hello this is ~~~",
+ "hello this is ~~~",
+ ),
+ array( #1: rtrim
+ " Foo \n ",
+ " Foo",
),
);
}
public function dataGetSecondaryDataUpdates() {
return array(
- array("WikitextContentTest_testGetSecondaryDataUpdates_1",
+ array( "WikitextContentTest_testGetSecondaryDataUpdates_1",
CONTENT_MODEL_WIKITEXT, "hello ''world''\n",
array( 'LinksUpdate' => array( 'mRecursive' => true,
'mLinks' => array() ) )
),
- array("WikitextContentTest_testGetSecondaryDataUpdates_2",
+ array( "WikitextContentTest_testGetSecondaryDataUpdates_2",
CONTENT_MODEL_WIKITEXT, "hello [[world test 21344]]\n",
array( 'LinksUpdate' => array( 'mRecursive' => true,
'mLinks' => array( array( 'World_test_21344' => 0 ) ) ) )
array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
),
+ array( // rtrim
+ " Foo \n ",
+ " Foo",
+ ),
);
}