Page MenuHomePhabricator

deleteBatch.php: accept minimal info (page ID, instead of full title + namespace)
Closed, ResolvedPublic

Description

At the moment the tool deleteBatch.php only works with page titles, with namespace.

Working with page titles is a significant obstacle for any database administrator who wants to use deleteBatch.php to cleanup a MediaWiki database. In fact, the database has no perception of namespace names, since namespace names are stored in PHP files, not in the database.

As solution, I usually fork that maintenance script to provide a --by-id flag. So I can have a similar easy workflow:

mysql wiki <<< "SELECT pageid ... WHERE ... = 'spam'" | ./deleteBatch.php --by-id

This --by-id flag (or anything similar - please propose) dramatically simplifies queries since you don't have to create super-enormous SQL if/switch-cases to match the namespace number and return the correct canonical namespace name, especially when you are looking for inter-namespace spam, and so, you are not just working on a specific namespace.

Maybe this is something that could be added upstream. And, I'm quite sure, that this may be a good first task. It's just a matter of:

  1. deciding a nice flag name - for instance - --by-id
  2. write 5-10 PHP lines

Event Timeline

valerio.bozzolan renamed this task from deleteBatch.php: accept with minimal info (page ID, instead of full title + namespace) to deleteBatch.php: accept minimal info (page ID, instead of full title + namespace).Feb 8 2024, 4:03 PM
valerio.bozzolan triaged this task as Low priority.

Change 1012916 had a related patch set uploaded (by Philipnelson99; author: Philipnelson99):

[mediawiki/core@master] allow maintenance/deleteBatch.php to accept page ID

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

@valerio.bozzolan I made the changes you requested but I haven't really used git-review or gerrit before and think I may have screwed something up there. Let me know if you want me to fix this and I will. Here's the associated change link on gerrit.

https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1013405

Change #1013405 had a related patch set uploaded (by Philipnelson99; author: Philipnelson99):

[mediawiki/core@master] allow maintenance/deleteBatch.php to accept page ID

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

Sorry my friend but I never understood how to use Gerrit D:

Anyway you are probably in this situation:

https://www.mediawiki.org/wiki/Gerrit/Tutorial#Amending_a_change_(your_own_or_someone_else's)

To apply that guide, try visiting the original page, download that patch as indicated:

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

Then follow the above guide to just "amend" your already-existing commit, and push that again

In the meanwhile, if you see any "Close" button on https://gerrit.wikimedia.org/r/1013405 let's close that duplicate 👍

If you find out how to do it, share it I'm very interested in it. Thanks!

Change #1013405 abandoned by Philipnelson99:

[mediawiki/core@master] allow maintenance/deleteBatch.php to accept page ID

Reason:

should've been an amend not a new change

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

@valerio.bozzolan I was not able to find a way to delete the change altogether so I just abandoned it, but I've uploaded a new patchset to the existing change 😊

Change #1012916 merged by jenkins-bot:

[mediawiki/core@master] allow maintenance/deleteBatch.php to accept page ID

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

Change #1015192 had a related patch set uploaded (by Reedy; author: Philipnelson99):

[mediawiki/core@REL1_41] allow maintenance/deleteBatch.php to accept page ID

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

Change #1015193 had a related patch set uploaded (by Reedy; author: Philipnelson99):

[mediawiki/core@REL1_40] allow maintenance/deleteBatch.php to accept page ID

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

Change #1015194 had a related patch set uploaded (by Reedy; author: Philipnelson99):

[mediawiki/core@REL1_39] allow maintenance/deleteBatch.php to accept page ID

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

Change #1015192 merged by jenkins-bot:

[mediawiki/core@REL1_41] allow maintenance/deleteBatch.php to accept page ID

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

Change #1015194 merged by jenkins-bot:

[mediawiki/core@REL1_39] allow maintenance/deleteBatch.php to accept page ID

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

Change #1015193 merged by jenkins-bot:

[mediawiki/core@REL1_40] allow maintenance/deleteBatch.php to accept page ID

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

Yes! I don't want to steal credit from you :D

Feel free to create an empty comment, with Add ActionChange StatusResolved and Submit

Thanks for this lovely feature that I will surely use in production intensively :3