Commit graph

11 commits

Author SHA1 Message Date
jenkins-bot
734361ee34 Merge "Switch between file deletion and normal deletion in WikiFilePage" 2021-11-18 03:31:26 +00:00
Daimona Eaytoy
feadffbad4 Switch between file deletion and normal deletion in WikiFilePage
When we get to FileDeleteAction is already too late: even if we call the
parent method, the other class methods will still be called due to
inheritance. So do that earlier, and don't create a FileDeleteAction at
all if the file cannot be deleted.

Bug: T295435
Change-Id: I2f9a7557518836fd22763fe3301538fe08f38fda
2021-11-12 18:27:11 +00:00
Daimona Eaytoy
1ccd95dca4 Deprecate $hasHistory param to ContentHandler::getAutoDeleteReason()
Unused except for DeleteAction, which now uses a custom query (similar
to the one in ContentHandler::getAutoDeleteReason). Passing the
parameter is hence hard-deprecated, and it will be removed in 1.39.

Also escalate the exception logging from wfDebug to error, since we want
to know what exceptions are being caught.

Bug: T288282
Change-Id: I91ed9574da68bc7ff36e968f016da390b6d295ed
2021-11-11 23:14:42 +00:00
Daimona Eaytoy
6cbff5bbac Make DeleteAction and FileDeleteAction share showForm
Use getTitle() in FileDeleteAction, it's the same as using the old
$this->file.

Use a single showForm method for both classes, and a separate method to
add handy links. When switching to FormAction, the former will be
replaced by getFormFields(), the latter by postText(). However, before
doing that, the following things should be addressed:
- The onArticleConfirmDelete hook, which allows changing the reason.
  This hook should be replaced in the long term, but for now it might be
  sufficient to add it to the common UI logic and only run it for
  non-file pages.
- The horrible $hasHistory hack. This is going to be a tad more
  complicated because we need to remove it from WikiPage and
  ContentHandler, and replace it with something else.

Bug: T288282
Change-Id: I965c32457b1426ece9781221a95337d295b9e1a2
2021-11-08 13:46:57 +00:00
Tim Starling
61726a9959 Fix oldimage deletion error message
filedeleteerror-short was repeated as an h2, but the parameters aren't
appropriate for prepareMessage() and filedeleteerror-short-old doesn't
exist. The message is used correctly in the following line.

Change-Id: I07481bd7d43e0596af3de183aa7814572805c8c2
2021-11-02 21:35:55 +00:00
Daimona Eaytoy
23ec8052ce Final sync of DeleteAction and FileDeleteAction forms
Fix the last drifts between the two. Custom CSS IDs/names/classes in
FileDeleteForm were replaced with the base one, as I think it's better
to be consistent, and it wouldn't be trivial to allow changing those
values in a clean way. Question for reviewers: should this part be
announced on tech news in case somebody is using those values in a
script?

Move the file delete intro above the form, like we do for normal
deletion.

For normal deletion, use the content of the wpReason field as default
value for that field, not the result of merging the dropdown and the
"other" field, which doesn't seem correct (the file version was already
doing this).

Make the file deletion form use the title as token salt like the base
form -- it shouldn't make any difference AFAICS.

After this patch, it should be possible to make DeleteAction extend
FormAction with low effort.

Bug: T288282
Change-Id: I8b115ecb1c94af63d686a575b18362ac32105ae2
2021-10-13 13:48:24 +00:00
Daimona Eaytoy
39b19c05a7 DeleteAction: allow easy override of form messages
The two forms (article delete vs file delete) are basically identical,
but use different messages. Even if some file-specific messages might
possibly be deleted in favour of the base ones, it's still hard to
generate the form fields from a single place. Thus, this change
introduces a couple of methods to allow overriding the messages.

Bug: T288282
Change-Id: I1c26b24c16cb6ab6840edaca4bce0d582518b95d
2021-10-06 11:44:27 +00:00
Daimona Eaytoy
c0c213ba46 DeleteAction-related cleanup, part 3
Move all output-related code from Article to DeleteAction.
Article::doDelete is now deprecated, because there are some callers in
the wild, although I don't think any caller should need it.

Kill some ancient-PHP-style pass-by-refs that are useless and only make
the code more error-prone for both the caller and the callee.

Bug: T288282
Change-Id: Ic1de0ed8ebba15da5ed9f5cd11625017360a7672
2021-10-06 13:43:54 +02:00
Daimona Eaytoy
85b6398f2b Clean up DeleteAction and FileDeleteAction, part 2
Factor out more common code, fix small drifts. Still more things to
clean up.

Bug: T288282
Change-Id: I17c7d9213781089458f0780d64332ba32c5b8430
2021-10-06 11:41:31 +00:00
Daimona Eaytoy
44ebf006ae Clean up DeleteAction and FileDeleteAction, part 1
Sync similar sections, factor out some common logic, fix some drifts
between the two.

Bug: T288282
Change-Id: I00db5118777bf744b924b8c3e3da53b1c5a35f5c
2021-09-28 13:07:58 +00:00
Daimona Eaytoy
0ef73ec13e Move some methods from FileDeleteForm to a subclass of DeleteAction
This is where the UI logic is supposed to live. The remaining methods in
FileDeleteForm will later be deprecated in favour of a dedicated command
object.

This patch tries to move the code to the new class with minimal changes,
with cleanup left to do for later.

Also change return typehints and docs for getFile(): WikiFilePage::loadFile()
is guaranteed to load a file. The "|bool" would confuse PHPStorm and
phan.

Note that FileDeleteForm is unused everywhere, except for some static
methods not touched by this patch.

Bug: T288282
Change-Id: I4fa1dfa096cd2ae7a58067764b12a275b1cce1d5
2021-09-17 22:13:19 +02:00