Fix TextContent::preSaveTransform() return type
authorBrad Jorsch <bjorsch@wikimedia.org>
Fri, 13 Dec 2013 17:51:47 +0000 (12:51 -0500)
committerBrad Jorsch <bjorsch@wikimedia.org>
Fri, 13 Dec 2013 18:20:22 +0000 (13:20 -0500)
TextContent::preSaveTransform should return an object of the same class
as $this, not a WikitextContent.

Apparently this was never noticed because most code paths rtrim the
input and TextContent::preSaveTransform returns $this if the rtrim is a
no-op on the input.

Bug: 58451
Change-Id: I9f8f78d52448d1ba055a654a12ff4fad86756110

includes/content/TextContent.php

index d03d61e..ffb5cf2 100644 (file)
@@ -151,7 +151,7 @@ class TextContent extends AbstractContent {
                $text = $this->getNativeData();
                $pst = rtrim( $text );
 
-               return ( $text === $pst ) ? $this : new WikitextContent( $pst );
+               return ( $text === $pst ) ? $this : new static( $pst );
        }
 
        /**