With the new behavior of using the ar_parent_id values for undeletion (see T183375 and T185167), undeletion can now make revisions with "broken" parent ids that do not point to an existing row in the revision table. Such revisions will show a green positive number in the history and user contributions pages as if they had parent id zero. An example of such a revision on Wikipedia is [[https://en.wikipedia.org/w/index.php?title=Bombshell:_The_Hedy_Lamarr_Story&oldid=823434018|revision 823434018]], whose parent id is 818256990. We need to create a maintenance script that will change all the "broken" parent ids to either the "most obvious value" (given by the previous revision by id or timestamp) or zero (to make them be actually treated as creations of new pages, with the "N" mark in the user contributions page).