* Make sure we have the right article ID, not slave lagged. (bug 8072)
authorAaron Schulz <aaron@users.mediawiki.org>
Tue, 16 Sep 2008 17:08:08 +0000 (17:08 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Tue, 16 Sep 2008 17:08:08 +0000 (17:08 +0000)
* Make FileDeleteForm use hook properly

includes/Article.php
includes/FileDeleteForm.php

index aa5e5b6..9a8b274 100644 (file)
@@ -2262,12 +2262,12 @@ class Article {
                global $wgOut, $wgUser;
                wfDebug( __METHOD__."\n" );
 
-               $id = $this->getId();
+               $id = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
 
                $error = '';
 
-               if (wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error))) {
-                       if ( $this->doDeleteArticle( $reason, $suppress ) ) {
+               if ( wfRunHooks('ArticleDelete', array(&$this, &$wgUser, &$reason, &$error)) ) {
+                       if ( $this->doDeleteArticle( $reason, $suppress, $id ) ) {
                                $deleted = $this->mTitle->getPrefixedText();
 
                                $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) );
@@ -2292,7 +2292,7 @@ class Article {
         * Deletes the article with database consistency, writes logs, purges caches
         * Returns success
         */
-       function doDeleteArticle( $reason, $suppress = false ) {
+       function doDeleteArticle( $reason, $suppress = false, $id = 0 ) {
                global $wgUseSquid, $wgDeferredUpdateList;
                global $wgUseTrackbacks;
 
@@ -2301,7 +2301,7 @@ class Article {
                $dbw = wfGetDB( DB_MASTER );
                $ns = $this->mTitle->getNamespace();
                $t = $this->mTitle->getDBkey();
-               $id = $this->mTitle->getArticleID();
+               $id = $id ? $id : $this->mTitle->getArticleID( GAID_FOR_UPDATE );
 
                if ( $t == '' || $id == 0 ) {
                        return false;
index ae144d7..4f6986a 100644 (file)
@@ -105,11 +105,12 @@ class FileDeleteForm {
                } else {
                        $status = $file->delete( $reason, $suppress );
                        if( $status->ok ) {
+                               $id = $title->getArticleID( GAID_FOR_UPDATE );
                                // Need to delete the associated article
                                $article = new Article( $title );
                                if( wfRunHooks('ArticleDelete', array(&$article, &$wgUser, &$reason)) ) {
-                                       if( $article->doDeleteArticle( $reason, $suppress ) )
-                                               wfRunHooks('ArticleDeleteComplete', array(&$article, &$wgUser, $reason));
+                                       if( $article->doDeleteArticle( $reason, $suppress, $id ) )
+                                               wfRunHooks('ArticleDeleteComplete', array(&$article, &$wgUser, $reason, $id));
                                }
                        }
                }