Today, a friend of mine had a few really long wiki pages whose revision histories he wanted to delete (specifically, chapters 1-117 of The Count of Monte Cristo), to save some space in his database. So, he went to do php deleteOldRevisions.php --delete and then, oops, his finger slipped, and he accidentally hit enter when he meant to enter the page IDs. So he lost the old revisions for every page on his wiki. (See https://www.mediawiki.org/wiki/Manual:DeleteOldRevisions.php )
I think back to how, over the past months, he spent countless hours putting a detailed edit comment for almost every single revision, including wry remarks; friendly banter; Twitter-style 140-character social commentary and provocative philosophical musings on the meaning of life and the universe, and whatnot; and now all those are gone. (Now I feel smart for never bothering to enter any edit summaries on that wiki.)
I'm thinking, it's probably best for the script to ask "Are you sure (y/n)?" when the user doesn't put any page IDs.
The script should also probably have a parameter to allow the page titles to be read from a text file, kind of like what deleteBatch.php offers. https://www.mediawiki.org/wiki/Manual:DeleteBatch.php That would probably mitigate the potential for screw-ups.
I came up with something a little safer and easier for those who just want to delete old revisions from one namespace: https://www.mediawiki.org/ wiki/User:KryptoKronic/deleteOldRevisions.php
The output looks like this:
$ php deleteOldRevisions.php --delete 4
Delete old revisions
Limiting to namespaces 4 Limiting to page IDs 4,2 Limiting to page titles Project:Bar,Project:Foo Searching for active revisions...done. Searching for inactive revisions...done. 3 old revisions found. Abort with control-c in the next five seconds (skip this countdown with --quick) ... 0 Deleting...done. Searching for active text records in revisions table...done. Searching for active text records in archive table...done. Searching for inactive text records...done. 3 inactive items found. Deleting...done.
On Sat, Jul 1, 2017 at 2:41 AM, Jean Valjean jeanvaljean2718@gmail.com wrote:
I came up with something a little safer and easier for those who just want to delete old revisions from one namespace: https://www.mediawiki.org/ wiki/User:KryptoKronic/deleteOldRevisions.php
I don't know how easy it is to get pull requests merged, but if you want to get these improvements into core, you could click the 'edit' pen at https://github.com/wikimedia/mediawiki/blob/master/maintenance/deleteOldRevi... and submit a pull request.
Github is only a mirror of the code base-we dont use it for pull requests. If you want to submit a change, put a unified diff in https://tools.wmflabs.org/gerrit-patch-uploader/ or submit the change directly to gerrit.wikimedia.org (using the user account from wikitech.wikimedia.org). There is more info at https://www.mediawiki.org/wiki/How_to_become_a_MediaWiki_hacker
-- bawolff
On Saturday, July 1, 2017, Greg Rundlett (freephile) greg@freephile.com wrote:
On Sat, Jul 1, 2017 at 2:41 AM, Jean Valjean jeanvaljean2718@gmail.com wrote:
I came up with something a little safer and easier for those who just
want
to delete old revisions from one namespace: https://www.mediawiki.org/ wiki/User:KryptoKronic/deleteOldRevisions.php
I don't know how easy it is to get pull requests merged, but if you want
to
get these improvements into core, you could click the 'edit' pen at
https://github.com/wikimedia/mediawiki/blob/master/maintenance/deleteOldRevi...
and submit a pull request. _______________________________________________ MediaWiki-l mailing list To unsubscribe, go to: https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
Yeah, the reason I didn't submit it as a patch is that all I did was hack the extension to operate based on namespace rather than page IDs. Some people might look at that as a regression, if they wanted to continue using page IDs. I'm not really sure what would be the best way to make it capable of handling either page IDs or namespaces, at the option of the user, unless we were going to have it read in the page IDs from a file.
I wonder, does anyone have any use cases where they would prefer to use page IDs rather than page titles? I suspect the reason it was originally written to use page IDs is that it was simpler to code, given that the revision table has a rev_page field (for page ID) but no rev_page_namespace or rev_page_title field.
Some other possibilities are that it could delete old revisions of pages in a specified category or categories.
On Sat, Jul 1, 2017 at 2:12 PM, Greg Rundlett (freephile) < greg@freephile.com> wrote:
I don't know how easy it is to get pull requests merged, but if you want to get these improvements into core, you could click the 'edit' pen at https://github.com/wikimedia/mediawiki/blob/master/maintenance/ deleteOldRevisions.php and submit a pull request.
On Sat, Jul 1, 2017 at 12:07 AM, Jean Valjean jeanvaljean2718@gmail.com wrote:
Today, a friend of mine had a few really long wiki pages whose revision histories he wanted to delete (specifically, chapters 1-117 of The Count of Monte Cristo), to save some space in his database. So, he went to do php deleteOldRevisions.php --delete and then, oops, his finger slipped, and he accidentally hit enter when he meant to enter the page IDs. So he lost the old revisions for every page on his wiki. (See https://www.mediawiki.org/wiki/Manual:DeleteOldRevisions.php )
That really stinks, but that's why I use a simple script [1] to backup wikis in seconds prior to DB maintenance.
With this script saved in my ~/bin folder, I can simply "backup.db.sh wiki"
[1] https://freephile.org/wiki/Mysqldump
Greg Rundlett https://eQuality-Tech.com https://equality-tech.com/ https://freephile.org
mediawiki-l@lists.wikimedia.org