Partial revert of r41018 "Wrap $log->addEntry() in transaction"
authorAryeh Gregor <simetrical@users.mediawiki.org>
Mon, 16 Feb 2009 16:50:22 +0000 (16:50 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Mon, 16 Feb 2009 16:50:22 +0000 (16:50 +0000)
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

index 4960e9e..0ac7481 100644 (file)
@@ -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;