Decrappify edit check for revision hook
authorAaron Schulz <aaron@users.mediawiki.org>
Fri, 16 May 2008 03:17:05 +0000 (03:17 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Fri, 16 May 2008 03:17:05 +0000 (03:17 +0000)
docs/hooks.txt
includes/Article.php
includes/Revision.php
includes/SpecialImport.php
includes/SpecialUndelete.php
includes/Title.php
includes/filerepo/ICRepo.php
includes/filerepo/LocalFile.php

index 00eb28f..22125c5 100644 (file)
@@ -919,6 +919,7 @@ $user: the User object to load preferences from
 
 'RevisionInsertComplete': called after a revision is inserted into the DB
 $revision: the Revision
+$edit: was this a new edit?
 
 'SavePreferences': called at the end of PreferencesForm::savePreferences; 
                    returning false prevents the preferences from being saved.
index cef4470..fa2c58f 100644 (file)
@@ -1444,7 +1444,7 @@ class Article {
                                        ) );
 
                                $dbw->begin();
-                               $revisionId = $revision->insertOn( $dbw );
+                               $revisionId = $revision->insertOn( $dbw, true );
 
                                # Update page
                                $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision );
@@ -1512,7 +1512,7 @@ class Article {
                                'minor_edit' => $isminor,
                                'text'       => $text
                                ) );
-                       $revisionId = $revision->insertOn( $dbw );
+                       $revisionId = $revision->insertOn( $dbw, true );
 
                        $this->mTitle->resetArticleID( $newid );
 
index a6f9604..5d79167 100644 (file)
@@ -707,9 +707,10 @@ class Revision {
         * number on success and dies horribly on failure.
         *
         * @param Database $dbw
+        * @param bool $edit, was this a new edit? (optional)
         * @return int
         */
-       public function insertOn( &$dbw ) {
+       public function insertOn( &$dbw, $edit=false ) {
                global $wgDefaultExternalStore;
 
                wfProfileIn( __METHOD__ );
@@ -772,7 +773,7 @@ class Revision {
 
                $this->mId = !is_null($rev_id) ? $rev_id : $dbw->insertId();
                
-               wfRunHooks( 'RevisionInsertComplete', array( &$this ) );
+               wfRunHooks( 'RevisionInsertComplete', array( &$this, $edit ) );
                
                wfProfileOut( __METHOD__ );
                return $this->mId;
index 76bd646..da7a766 100644 (file)
@@ -218,7 +218,7 @@ class ImportReporter {
                        $dbw = wfGetDB( DB_MASTER );
                        $nullRevision = Revision::newNullRevision(
                                $dbw, $title->getArticleId(), $comment, true );
-                       $nullRevision->insertOn( $dbw );
+                       $nullRevision->insertOn( $dbw, true );
                        # Update page record
                        $article = new Article( $title );
                        $article->updateRevisionOn( $dbw, $nullRevision );
index c0e2e0c..a98e71e 100644 (file)
@@ -514,7 +514,7 @@ class PageArchive {
                                'deleted'        => $unsuppress ? 0 : $row->ar_deleted,
                                'len'        => $row->ar_len
                                ) );
-                       $revision->insertOn( $dbw );
+                       $revision->insertOn( $dbw, false );
                        $restored++;
 
                        wfRunHooks( 'ArticleRevisionUndeleted', array( &$this->title, $revision, $row->ar_page_id ) );
index 0499d3f..28ee6fb 100644 (file)
@@ -2596,7 +2596,7 @@ class Title {
 
                # Save a null revision in the page's history notifying of the move
                $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true );
-               $nullRevId = $nullRevision->insertOn( $dbw );
+               $nullRevId = $nullRevision->insertOn( $dbw, true );
 
                # Change the name of the target page:
                $dbw->update( 'page',
@@ -2622,7 +2622,7 @@ class Title {
                                'page'    => $newid,
                                'comment' => $comment,
                                'text'    => $redirectText ) );
-                       $redirectRevision->insertOn( $dbw );
+                       $redirectRevision->insertOn( $dbw, true );
                        $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
 
                        # Now, we record the link from the redirect to the new title.
@@ -2683,7 +2683,7 @@ class Title {
 
                # Save a null revision in the page's history notifying of the move
                $nullRevision = Revision::newNullRevision( $dbw, $oldid, $comment, true );
-               $nullRevId = $nullRevision->insertOn( $dbw );
+               $nullRevId = $nullRevision->insertOn( $dbw, true );
 
                # Rename page entry
                $dbw->update( 'page',
@@ -2709,7 +2709,7 @@ class Title {
                                'page'    => $newid,
                                'comment' => $comment,
                                'text'    => $redirectText ) );
-                       $redirectRevision->insertOn( $dbw );
+                       $redirectRevision->insertOn( $dbw, true );
                        $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
 
                        # Record the just-created redirect's linking to the page
index 805dc02..9f2cc71 100644 (file)
@@ -285,7 +285,7 @@ class ICFile extends LocalFile{
                if( $descTitle->exists() ) {
                        # Create a null revision
                        $nullRevision = Revision::newNullRevision( $dbw, $descTitle->getArticleId(), $log->getRcComment(), false );
-                       $nullRevision->insertOn( $dbw );
+                       $nullRevision->insertOn( $dbw, true );
                        $article->updateRevisionOn( $dbw, $nullRevision );
 
                        # Invalidate the cache for the description page
index 4978fd3..33de732 100644 (file)
@@ -862,7 +862,7 @@ class LocalFile extends File
                if( $descTitle->exists() ) {
                        # Create a null revision
                        $nullRevision = Revision::newNullRevision( $dbw, $descTitle->getArticleId(), $log->getRcComment(), false );
-                       $nullRevision->insertOn( $dbw );
+                       $nullRevision->insertOn( $dbw, true );
                        $article->updateRevisionOn( $dbw, $nullRevision );
 
                        # Invalidate the cache for the description page