Page MenuHomePhabricator

Don't delete recent changes entries associated with the title when deleting a page
Closed, ResolvedPublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • Move an existing page A to a new title B.
  • Delete the redirect at the old title A.

What happens?: All the edits made to the page prior to the move are gone from recent changes.

What should have happened instead?: All the edits made to the page prior to the move are still in recent changes under the (now redlinked) title A.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:

Currently, all non-log recent changes entries associated with the title of a deleted page are deleted regardless of their associated page ID. It would be better to only delete entries that are associated with the page ID.

The same thing would happen with reverted moves that require deleting the redirect. If one instead does a move-without-redirect from A to C and then move B back to A, then the edits made to the page prior to the move will not be gone from recent changes.

Event Timeline

This would require modifying LinksDeletionUpdate.php to no longer have $rcIdsForTitle.

kostajh subscribed.

Growth-Team won't have time to work on something like this anytime soon. It is probably worth getting some opinions/consensus on from a product perspective before any code changes are done.

From the patrollers' point of view, the current behavior is a bit destructive because it irreversibly deletes the rows and leaves no way to patrol them later, even though they have not expired yet. It's also inconsistent with the situation when the page is moved without leaving the redirect. Then, the rows are kept. Therefore, I second this request.

As for the actual bugfix, it's indeed in LinksDeletionUpdate:

// Find recentchanges entries to clean up...
$rcIdsForTitle = $dbw->selectFieldValues(
	'recentchanges',
	'rc_id',
	[
		'rc_type != ' . RC_LOG,
		'rc_namespace' => $title->getNamespace(),
		'rc_title' => $title->getDBkey(),
		'rc_timestamp < ' .
			$dbw->addQuotes( $dbw->timestamp( $this->timestamp ) )
	],
	__METHOD__
);
$rcIdsForPage = $dbw->selectFieldValues(
	'recentchanges',
	'rc_id',
	[ 'rc_type != ' . RC_LOG, 'rc_cur_id' => $id ],
	__METHOD__
);

$rcIdBatches = array_chunk( array_merge( $rcIdsForTitle, $rcIdsForPage ), $batchSize );

$rcIdsForTitle identifies rows by matching on the (rc_namespace, rc_title) pair, $rcIdsForPage matches on rc_cur_id. Usually, they will overlap (why is there no array_unique?). The proposed fix is to eliminate $rcIdsForTitle. The question is if there can be some rows not selected by the other query that we still want to have deleted. I believe not.

(I suspect that by doing that, we will also fix T140960.)

Change 879943 had a related patch set uploaded (by Matěj Suchánek; author: Matěj Suchánek):

[mediawiki/core@master] Select recent changes for deletion only by page id

https://gerrit.wikimedia.org/r/879943

Growth-Team won't have time to work on something like this anytime soon. It is probably worth getting some opinions/consensus on from a product perspective before any code changes are done.

@Trizek-WMF @KStoller-WMF there's a patch from @matej_suchanek to change this behavior. Could you please have a look at the task description and T140960 and let me know what you think about the proposed changes?

If I understand correctly, the following process fixed by this patch would be:

  1. Move an existing page A to a new title B.
  2. Delete the redirect at the old title A.
  3. Recent changes show changes made on B, including the ones that happen when B was A.

If it is right, then it is a valuable update.

Regarding T140960, how does it relate?

Regarding T140960, how does it relate?

The patch fixes both. They are the same problem from a technical point of view.

@kostajh These sound like logical changes to me. 👍
Thank you for the explanation and work on this, @matej_suchanek!

matej_suchanek changed the task status from Open to In Progress.Jan 26 2023, 7:29 AM
matej_suchanek claimed this task.

Change 879943 merged by jenkins-bot:

[mediawiki/core@master] Select recent changes for deletion only by page id

https://gerrit.wikimedia.org/r/879943

Now fixed along with T140960.