Page MenuHomePhabricator

Create check hook before really uploading file with infos about description page and file
Closed, ResolvedPublic

Description

I haven't found a hook that provides me the file, the wikitext and comment for the description page.

Neither UploadVerification nor UploadVerifyFile doesn't seem to include the necessary description page infos and UploadComplete is too late as file was already uploaded and page created.
and UploadForm:BeforeProcessing doesn't allow nice abort.

I think ideally the hook would run right at the start of UploadBase::performUpload and gets the file, pagetext etc. with the ability to cancel the upload.

Needed for AbuseFilter, T89252.

Event Timeline

Se4598 raised the priority of this task from to Medium.
Se4598 updated the task description. (Show Details)
Se4598 added a project: MediaWiki-Uploading.
Se4598 subscribed.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Se4598 set Security to None.
matmarex raised the priority of this task from Medium to High.Jun 17 2016, 12:14 PM

Change 295252 had a related patch set uploaded (by Bartosz Dziewoński):
Introduce new hook UploadVerifyUpload to allow preventing file uploads

https://gerrit.wikimedia.org/r/295252

Some of the changes I'm making will change the action=upload responses for non-hook-related errors slightly, for example:

BeforeAfter
1{
2 "error": {
3 "code": "internal-error",
4 "info": "An internal error occurred",
5 "0": [
6 "directorycreateerror",
7 "mwstore://local-backend/local-public/a/ad"
8 ],
9 "*": "See http://localhost:3080/w/api.php for API usage"
10 }
11}
1{
2 "error": {
3 "code": "internal-error",
4 "info": "Unknown error: \"directorycreateerror\"",
5 "0": [
6 "directorycreateerror",
7 "mwstore://local-backend/local-public/a/ad"
8 ],
9 "stashfailed": "Stashing temporary file failed: UploadStashFileException Error storing file in '/tmp/phpLn0Uqt': Directory \"mwstore://local-backend/local-temp/4/4d\" is read-only.",
10 "invalidparameter": null,
11 "*": "See http://localhost:3080/w/api.php for API usage"
12 }
13}

Change 295252 merged by jenkins-bot:
Introduce new hook UploadVerifyUpload to allow preventing file uploads

https://gerrit.wikimedia.org/r/295252