When possible, Special:Undelete should use the same page_id that is in archive.page_id. Recreated pages should also use the page_id stored in archive.page_id.
Sample cases:
#1 (Simple case): A page is deleted and then undeleted. This presents no complications.
#2 (Simple case): A page is deleted, then recreated, then deleted, and then all the revisions are restored. Since the same page_id stored in archive.ar_page_id was used for the re-creation, all the deleted revisions will have the same archive.page_id and will be restored to it.
#3 (Less simple case): There are a bunch of archive rows with different ar_page_id with the same ar_namespace and ar_title from the legacy system (i.e. what we currently use). Any page recreations or undeletions should probably use the highest ar_page_id with that namespace and title.
#4 (Less simple case): A page is deleted, then another page is moved to that same page namespace and title, and then the deleted revisions are restored into it. They will have to be restored to the new page ID. Maybe this straight-up shouldn't be allowed.
#5 (Less simple case): Page "foo" (page_id 1) is deleted, then another page "foo" (page_id 1) is recreated and moved to "bar", then another page "foo" (page_id 2) is created, then the deleted revisions are restored. They will have to be restored to page_id 2 because bar was recreated under page_id 1.
In cases #3, #4 and #5, it won't always be possible to restore all of the revisions to the same page_id that's in the ar_page_id, but this system would keep page_id and rev_page consistent over deletions, recreations, and restorations better than our current system does.
Of course, bug 11402's being fixed would render some of this moot. But it illustrates some of the challenges involved in keep page_id consistently consistent.
Version: 1.23.0
Severity: normal
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=26123
https://bugzilla.wikimedia.org/show_bug.cgi?id=54398