From 86bbdc25f461ac3a41106c05c736fb3ac0718e69 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Mon, 16 Feb 2009 16:50:22 +0000 Subject: [PATCH] Partial revert of r41018 "Wrap $log->addEntry() in transaction" In addition to wrapping the given function call in a transaction, the commit also (without explanation or apparent purpose) moved a block of code to a totally different place, which broke it entirely. Specifically, it moved the update of the category table on article delete to AFTER THE CATEGORYLINKS ROWS WERE ALREADY DELETED, which meant that it found the article was in no categories, and article deletions silently failed to decrement the category count (bug 17155). Could you PLEASE not commit all sorts of stuff under the guise of one-line commit messages that don't actually relate to what you did. Thank you. --- includes/Article.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 4960e9ed52..0ac7481a76 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -2549,6 +2549,14 @@ class Article { $dbw->delete( 'langlinks', array( 'll_from' => $id ) ); $dbw->delete( 'redirect', array( 'rd_from' => $id ) ); } + + # Fix category table counts + $cats = array(); + $res = $dbw->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__ ); + foreach( $res as $row ) { + $cats []= $row->cl_to; + } + $this->updateCategoryCounts( array(), $cats ); # If using cleanup triggers, we can skip some manual deletes if( !$dbw->cleanupTriggers() ) { @@ -2565,14 +2573,6 @@ class Article { # Clear caches Article::onArticleDelete( $this->mTitle ); - - # Fix category table counts - $cats = array(); - $res = $dbw->select( 'categorylinks', 'cl_to', array( 'cl_from' => $id ), __METHOD__ ); - foreach( $res as $row ) { - $cats []= $row->cl_to; - } - $this->updateCategoryCounts( array(), $cats ); # Clear the cached article id so the interface doesn't act like we exist $this->mTitle->resetArticleID( 0 ); @@ -2584,7 +2584,7 @@ class Article { # Make sure logging got through $log->addEntry( 'delete', $this->mTitle, $reason, array() ); - + $dbw->commit(); return true; -- 2.20.1