Page MenuHomePhabricator

deleteBatch.php, given a File: redirect, deletes both the redirect and the target's uploaded file
Closed, ResolvedPublic


If you delete a File: redirect using maintenance/deleteBatch.php, the script deletes not only the redirect (correct behavior), but also the uploaded file it points to (arguably incorrect behavior). This destructive act is IMHO a bug because:

  • If you perform the same action in the MediaWiki GUI, using the Delete menu item on a File: redirect, the deletion does not touch the uploaded file in the target article.
  • In other namespaces, when you delete a redirect with deleteBatch.php, the deletion does not touch the target of that redirect.

Steps to reproduce:

  1. Upload an image to File:Example.jpg.
  2. Move File:Example.jpg to File:Renamed.jpg. The original File:Example.jpg is now a redirect.
  3. Create a file bug.txt containing this single line:


  1. Run this command:

php deleteBatch.php bug.txt

  1. The redirect File:Example.jpg has been deleted (correct), and the article File:Renamed.jpg still exists (correct), but the actual uploaded file has been deleted (bad). The article File:Renamed.jpg displays, "No file by this name exists, but you can upload it."

Version: 1.20.x
Severity: major



Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:56 AM
bzimport set Reference to bz52587.

If you really run 1.20.2: Please upgrade to 1.20.6 first and report back.

Would love to upgrade but it's not going to happen soon.

My "steps to reproduce" take about 60 seconds. Would you be willing to try them on a 1.20.6 (or even newer) system?

  1. Create a redirect "File:My_redirect.jpg" to any uploaded file on your wiki (say File:Foo.jpg")
  2. Run php deleteBatch.php foo.txt, where foo.txt contains only the line "File:My_redirect.jpg".
  3. Hit File:Foo.jpg and see that the uploaded file is deleted.

I confirmed that this happens in 1.20.6.

Change 132339 had a related patch set uploaded by Withoutaname:
Prevent deleteBatch.php deleting files from redirects

Change 132339 merged by jenkins-bot:
Prevent deleteBatch.php deleting files from redirects