From: Aaron Schulz Date: Fri, 16 May 2008 03:17:05 +0000 (+0000) Subject: Decrappify edit check for revision hook X-Git-Tag: 1.31.0-rc.0~47600 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=493d8451b88de96ced34e49409c31bd3cfbbe277;p=lhc%2Fweb%2Fwiklou.git Decrappify edit check for revision hook --- diff --git a/docs/hooks.txt b/docs/hooks.txt index 00eb28fe87..22125c528a 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -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. diff --git a/includes/Article.php b/includes/Article.php index cef4470b9e..fa2c58fe98 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -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 ); diff --git a/includes/Revision.php b/includes/Revision.php index a6f9604099..5d791677f0 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -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; diff --git a/includes/SpecialImport.php b/includes/SpecialImport.php index 76bd646ab5..da7a7662c9 100644 --- a/includes/SpecialImport.php +++ b/includes/SpecialImport.php @@ -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 ); diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index c0e2e0c20e..a98e71e887 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -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 ) ); diff --git a/includes/Title.php b/includes/Title.php index 0499d3fb52..28ee6fbdef 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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 diff --git a/includes/filerepo/ICRepo.php b/includes/filerepo/ICRepo.php index 805dc02ccf..9f2cc714b6 100644 --- a/includes/filerepo/ICRepo.php +++ b/includes/filerepo/ICRepo.php @@ -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 diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index 4978fd3af5..33de7322dd 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -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