Do not lose message parameters in UploadFromChunks::verifyChunk()
authorMatthias Mullie <git@mullie.eu>
Thu, 15 Dec 2016 13:34:13 +0000 (14:34 +0100)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 21 Dec 2016 00:23:18 +0000 (00:23 +0000)
commit90cb6aaa50e6f9e2efe588230225791c7815fee2
tree36c7b0762f85cf63627af8697665d23b26957fb8
parentf1dbc763f85792806faba628057db62edf7366a0
Do not lose message parameters in UploadFromChunks::verifyChunk()

This change is similar to If9ce05045ada1e3f55e031639e4c4ebc2a216de8

Having verifyChunk inside doStashFile was annoying. We'd have to
catch the exception in UploadBase::tryStashFile in order to convert
it to a proper Status object instead of the generic one that is
currently built there.
I felt like UploadBase::tryStashFile shouldn't have to be aware of
this exception, so I moved that catch into a new
UploadFromChunks::tryStashFile.
It makes no sense to perform that check twice when running
tryStashFile, so I got rid of it in doStashFile. But that also
meant we had to add it to a few other (now deprecated) places calling
doStashFile... But they should be cleaned up at some point anyway.

This will make sure we get error output like this:
"code":"filetype-bad-ie-mime",
"key":"filetype-bad-ie-mime",
"params":["text/html"]

instead of:
"code":"stashfailed",
"key":"Cannot upload this file because Internet Explorer would detect it as \"text/html\", which is a disallowed and potentially dangerous file type.",
"params":[]

Bug: T32095
Change-Id: I2fa767656cb3a5b366210042b8b504dc10ddaf68
includes/upload/UploadFromChunks.php