Page MenuHomePhabricator

Abuse filter disallowing deletions causes incorrect display in the UI, HTTP 500 API response
Closed, ResolvedPublic

Description

Abuse filter disallowing deletions causes incorrect display in the UI, HTTP 500 API response. I haven't been able to reproduce this locally, only on a production wiki.

To reproduce:
Visit https://id.wikipedia.org/wiki/MediaWiki:Copyright and then run the following JS in your browser to delete that page: [it should be deleted per T375789]

await ( new mw.Api() ).postWithToken( 'csrf', {
  action: 'delete',
  title: 'MediaWiki:Copyright',
  reason: 'Copyright message updates ([[phab:T375789|T375789]]): Delete unused message, the copyright footer on this wiki uses [[MediaWiki:Wikimedia-copyright]] instead'
} );

The API returns a HTTP 500, HTML response:

image.png (3,456×2,160 px, 509 KB)

Request from <my IP address> via cp3070 cp3070, Varnish XID 471260317
Upstream caches: cp3070 int
Error: 500, Internal Server Error at Wed, 16 Oct 2024 19:38:10 GMT

Try to delete it from the user interface: https://id.wikipedia.org/w/index.php?title=MediaWiki:Copyright&action=delete

You get an error from AbuseFilter with very messed up formatting:

image.png (1,903×3,610 px, 650 KB)

Expected behavior:
A readable AbuseFilter error.

Event Timeline

Looking at the UI error carefully, there are two problems:

  • The entire error message is red, because it's using the deprecated error class instead of a pretty error box. This is easy to fix.
  • The error message is shown twice, with the second instance being double-escaped. This seems to me to be a bug in MediaWiki's handling for the deprecated ArticleDelete hook, which AbuseFilter is using. Given that it's deprecated, I'm inclined to just update AF to use PageDelete instead, which shouldn't have this problem.

Change #1081214 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] DeleteAction: Modernize displaying errors

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

Change #1081215 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/extensions/AbuseFilter@master] Migrate 'ArticleDelete' hook to 'PageDelete' to fix error display

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

Change #1081215 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Migrate 'ArticleDelete' hook to 'PageDelete' to fix error display

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

Change #1081214 merged by jenkins-bot:

[mediawiki/core@master] Modernize status and error message handling

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

matmarex claimed this task.