Manual talk:PurgeOldText.php

Latest comment: 1 year ago by 192.222.162.46 in topic Behaviour since 1.35

Equivalent SQL edit

As the code looks currently, this script is pretty simple and I'm fairly confident that it is equivalent to running this SQL query. This may be handy for anyone without SSH access to a server:

/* Purge any text records which are not referenced from a revision or archive record */
DELETE FROM mw_text WHERE old_id NOT IN (
   SELECT DISTINCT rev_text_id FROM mw_revision
) AND old_id NOT IN (
   SELECT DISTINCT ar_text_id FROM mw_archive
)

Note that this can run very slowly and hang your website for a time if you're using it to purge a lot of spam.

Interestingly there's a generic function PurgeRedundantText in Maintenance.php [1] which seems to be a duplicate of the logic in this class. Someone should fix that so it just calls it.

Another alternative for people stuck with no SSH access might be Extension:Maintenance or Extension:MaintenanceShell

-- Harry Wood (talk) 01:28, 8 October 2012 (UTC)Reply

Behaviour since 1.35 edit

This script no longer looks at the revision table or the archive table, it seems to now only search the content table for the old_id from the text table.


In my wiki (started at mediawiki version 1.35, since updated to 1.38), I have records in the text table with corresponding records in the content table, but nothing in page or archive. It seems as though these should qualify as records to be cleaned out by this script. 192.222.162.46 19:24, 8 November 2022 (UTC)Reply

Return to "PurgeOldText.php" page.