Last modified: 2013-12-13 19:03:58 UTC
Consider this API call: https://en.wikipedia.org/w/api.php?action=parse&text=Test%0A&pst=&onlypst=&contentformat=text%2Fplain&contentmodel=text It gives an error "Exception Caught: Format text/plain is not supported for content model wikitext", which makes no sense because the content model passed was text rather than wikitext. It works fine if you remove the trailing newline (the %0A). The problem turns out to be in TextContent::preSaveTransform: if there is trailing whitespace in the input then it returns a WikitextContent rather than a Content object of the same class as $this.
Change 101238 had a related patch set uploaded by Anomie: Fix TextContent::preSaveTransform() return type https://gerrit.wikimedia.org/r/101238
Change 101238 merged by jenkins-bot: Fix TextContent::preSaveTransform() return type https://gerrit.wikimedia.org/r/101238