Page MenuHomePhabricator

TextContent::preSaveTransform shouldn't return a WikitextContent when $this isn't a WikitextContent
Closed, ResolvedPublic

Description

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.


Version: 1.23.0
Severity: normal

Details

Reference
bz58451

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:20 AM
bzimport set Reference to bz58451.
Anomie created this task.Dec 13 2013, 6:20 PM

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