Page MenuHomePhabricator

Commons AbuseFilter new_wikitext parameter not available for action=upload
Open, In Progress, Needs TriagePublicBUG REPORT


Steps to replicate the issue

Create an abuse filter that uses the new_wikitext parameter and then test these filter with edits and uploads on a file page.

For testing I used the following simple filter

(new_wikitext contains "Information")

on the page

What happens?:

All edits (action=edit) are marked as filter hits. But all uploads on the page (action=upload) are not marked as hits despite the Wikitext contains the string.

What should have happened instead?:

As per the documentation new_wikitext should also be available for upload actions.

"Variables related to the page edit, including summary, new_wikitext and several others, are now available for action='upload'."

Other information

If this is a mistake in the documentation the software should be changed to match the behavior described in the documentation as we need this feature on Commons to create template based exceptions for upload blocks.

The filter we want to get working is the following:

!("autopatrol" in user_rights)
& (action="upload")
& (page_first_contributor != user_name)
& (page_first_contributor != "")
& !(new_wikitext contains "{{Allow Overwriting}}")

Event Timeline

I can see two different issues here:

  • The link you provided is generated on the fly for a past change. It doesn't contain new_wikitext because the code for generating it is simply missing. I'm not sure if this is an oversight or if it is difficult to do (or it has become easy, but nobody has fixed it yet).
  • As far as I can see from the code, the variable should actually be set for uploads. And indeed, when I examine a filter hit for reupload (example), both old_wikitext and new_wikitext are set.

I see. This seem to be a problem with the testing environment.

I checked for the same edit in the testing environment: and in the log:

The log has old_wikitext and new_wikitext, the same edit in the testing environment does not have these parameters.

Some other parameters are also different, even the timestamp is different. These differences between the testing environment and and the actual log are really bad for debugging.

Change 956081 had a related patch set uploaded (by Matěj Suchánek; author: Matěj Suchánek):

[mediawiki/extensions/AbuseFilter@master] Load wikitext and derived vars for uploads in testing environment

matej_suchanek changed the task status from Open to In Progress.Sep 10 2023, 2:24 PM
matej_suchanek claimed this task.