From d3364da9cea7f8bb0b41611f44d185c51f6dd73c Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 4 Oct 2013 14:35:13 +1000 Subject: [PATCH] Fix revision table cleanup on delete The ContentHandler branch inappropriately moved this essential query to content-type-dependent code, despite the fact that revision table cleanup needs to be done independently of content type. Before r15707, the revision query was done immediately before the page query, but it was moved down to allow it to be brought into the same if (!$dbw->cascadingDeletes() ) block as the link updates. I have moved it to immediately after the page delete, so that the rollback which has since been added will not affect the expensive revision table query. This should fix the database corruption we are seeing on some page deletions (13 affected pages on enwiki, 14 on nlwiki, etc.) Bug: 53687 Change-Id: I7a54c4416be07fb8cc7a5698e77927ccb24cbd6e --- includes/LinksUpdate.php | 2 -- includes/WikiPage.php | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/LinksUpdate.php b/includes/LinksUpdate.php index 0b7393addb..24f1679e7d 100644 --- a/includes/LinksUpdate.php +++ b/includes/LinksUpdate.php @@ -868,8 +868,6 @@ class LinksDeletionUpdate extends SqlDataUpdate { # If using cascading deletes, we can skip some explicit deletes if ( !$this->mDb->cascadingDeletes() ) { - $this->mDb->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ ); - # Delete outgoing links $this->mDb->delete( 'pagelinks', array( 'pl_from' => $id ), __METHOD__ ); $this->mDb->delete( 'imagelinks', array( 'il_from' => $id ), __METHOD__ ); diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 048dd6887b..c36d5d0754 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -2696,6 +2696,10 @@ class WikiPage implements Page, IDBAccessObject { return $status; } + if ( !$dbw->cascadingDeletes() ) { + $dbw->delete( 'revision', array( 'rev_page' => $id ), __METHOD__ ); + } + $this->doDeleteUpdates( $id, $content ); // Log the deletion, if the page was suppressed, log it at Oversight instead -- 2.20.1