Merge "(Bug 41169) Apply rtrim on on preSaveTransfrom."
[lhc/web/wiklou.git] / includes / content / TextContent.php
index 5e60b3c..8e832ec 100644 (file)
@@ -116,6 +116,22 @@ class TextContent extends AbstractContent {
                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..
         *