From fa132be8938cfbbef3eddb3e490069d2ec98d603 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 18 May 2012 18:58:21 +0200 Subject: [PATCH] fix for Ibe3e88fa: restoring doDeleteUpdates(). When generalizing LinksUpdate to DataUpdate and introducing WikiPage::getDeletionUpdates(), WikiPage::doDeleteUpdates() was removed, even though it was still used by Title::moveToInternal(). This patch restores WikiPage::doDeleteUpdates(), using the new logic based on WikiPage::getDeletionUpdates() to implement it. Change-Id: I12a49d5ca3ccb6bb9cbb63dde436bcf2a7d8a985 --- includes/WikiPage.php | 39 +++++++++++++++---------- tests/phpunit/includes/WikiPageTest.php | 15 ++++++++++ 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/includes/WikiPage.php b/includes/WikiPage.php index b326eb4838..fffd5f644e 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -2225,21 +2225,7 @@ class WikiPage extends Page { return WikiPage::DELETE_NO_REVISIONS; } - # update site status - DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, - (int)$this->isCountable(), -1 ) ); - - # remove secondary indexes, etc - $updates = $this->getDeletionUpdates( ); - DataUpdate::runUpdates( $updates ); - - # Clear caches - WikiPage::onArticleDelete( $this->mTitle ); - - # Reset this object - $this->clear(); - - # Clear the cached article id so the interface doesn't act like we exist - $this->mTitle->resetArticleID( 0 ); + $this->doDeleteUpdates( $id ); # Log the deletion, if the page was suppressed, log it at Oversight instead $logtype = $suppress ? 'suppress' : 'delete'; @@ -2259,6 +2245,29 @@ class WikiPage extends Page { return WikiPage::DELETE_SUCCESS; } + /** + * Do some database updates after deletion + * + * @param $id Int: page_id value of the page being deleted (B/C, currently unused) + */ + public function doDeleteUpdates( $id ) { + # update site status + DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, - (int)$this->isCountable(), -1 ) ); + + # remove secondary indexes, etc + $updates = $this->getDeletionUpdates( ); + DataUpdate::runUpdates( $updates ); + + # Clear caches + WikiPage::onArticleDelete( $this->mTitle ); + + # Reset this object + $this->clear(); + + # Clear the cached article id so the interface doesn't act like we exist + $this->mTitle->resetArticleID( 0 ); + } + /** * Roll back the most recent consecutive set of edits to a page * from the same user; fails if there are no eligible edits to diff --git a/tests/phpunit/includes/WikiPageTest.php b/tests/phpunit/includes/WikiPageTest.php index 88c26ef7e9..65abdabf3a 100644 --- a/tests/phpunit/includes/WikiPageTest.php +++ b/tests/phpunit/includes/WikiPageTest.php @@ -142,6 +142,21 @@ class WikiPageTest extends MediaWikiTestCase { $this->assertEquals( 0, $n, 'pagelinks should contain no more links from the page' ); } + public function testDoDeleteUpdates() { + $page = $this->createPage( "WikiPageTest_testDoDeleteArticle", "[[original text]] foo" ); + $id = $page->getId(); + + $page->doDeleteUpdates( $id ); + + # ------------------------ + $dbr = wfGetDB( DB_SLAVE ); + $res = $dbr->select( 'pagelinks', '*', array( 'pl_from' => $id ) ); + $n = $res->numRows(); + $res->free(); + + $this->assertEquals( 0, $n, 'pagelinks should contain no more links from the page' ); + } + public function testGetRevision() { $page = $this->newPage( "WikiPageTest_testGetRevision" ); -- 2.20.1