Manual:DeleteOrphanedRevisions.php

Details
deleteOrphanedRevisions.php is a maint-scripts>Special:MyLanguage/Manual:Maintenance scripts|maintenance script to delete revisions which refer to a non-existing page.

It is useful to deal with any orphaned revisions left over after manual deletions of page records from the database. After removing revisions, the script also runs purgeOldText.php to purge unused text records.