From: Brion Vibber Date: Sun, 13 Mar 2005 07:49:15 +0000 (+0000) Subject: Change interface to Article::updateRevisionOn() to take a Revision object instead... X-Git-Tag: 1.5.0alpha1~634 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=52d6ed34f1ce87ed326f88f8191f9ca566362cfa;p=lhc%2Fweb%2Fwiklou.git Change interface to Article::updateRevisionOn() to take a Revision object instead of pieces --- diff --git a/includes/Article.php b/includes/Article.php index aa292edad8..16bee2175e 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -742,8 +742,8 @@ class Article { * Update the page record to point to a newly saved revision. * * @param Database $dbw - * @param int $revId - * @param string $text -- used to set length and redirect status if given + * @param Revision $revision -- for ID number, and text used to set + length and redirect status fields * @param int $lastRevision -- if given, will not overwrite the page field * when different from the currently set value. * Giving 0 indicates the new page flag should @@ -751,7 +751,7 @@ class Article { * @return bool true on success, false on failure * @access private */ - function updateRevisionOn( &$dbw, $revId, $text = '', $lastRevision = null ) { + function updateRevisionOn( &$dbw, $revision, $lastRevision = null ) { $fname = 'Article::updateToRevision'; wfProfileIn( $fname ); @@ -760,9 +760,10 @@ class Article { # An extra check against threads stepping on each other $conditions['page_latest'] = $lastRevision; } + $text = $revision->getText(); $dbw->update( 'page', array( /* SET */ - 'page_latest' => $revId, + 'page_latest' => $revision->getId(), 'page_touched' => $dbw->timestamp(), 'page_is_new' => ($lastRevision === 0) ? 0 : 1, 'page_is_redirect' => Article::isRedirect( $text ), @@ -804,7 +805,7 @@ class Article { $prev = 0; } - $ret = $this->updateRevisionOn( $dbw, $revision->getId(), $revision->getText(), $prev ); + $ret = $this->updateRevisionOn( $dbw, $revision, $prev ); wfProfileOut( $fname ); return $ret; } @@ -846,7 +847,7 @@ class Article { $this->mTitle->resetArticleID( $newid ); # Update the page record with revision data - $this->updateRevisionOn( $dbw, $revisionId, $text, 0 ); + $this->updateRevisionOn( $dbw, $revision, 0 ); Article::onArticleCreate( $this->mTitle ); RecentChange::notifyNew( $now, $this->mTitle, $isminor, $wgUser, $summary ); @@ -1044,7 +1045,7 @@ class Article { $revisionId = $revision->insertOn( $dbw ); # Update page - $ok = $this->updateRevisionOn( $dbw, $revisionId, $text, $lastRevision ); + $ok = $this->updateRevisionOn( $dbw, $revision, $lastRevision ); if( !$ok ) { /* Belated edit conflict! Run away!! */ @@ -1991,7 +1992,7 @@ class Article { 'minor_edit' => $minor ? 1 : 0, ) ); $revisionId = $revision->insertOn( $dbw ); - $this->updateRevisionOn( $dbw, $revisionId, $text ); + $this->updateRevisionOn( $dbw, $revision ); $dbw->commit(); wfProfileOut( $fname ); diff --git a/includes/SpecialUndelete.php b/includes/SpecialUndelete.php index 6b4833d870..91b3273556 100644 --- a/includes/SpecialUndelete.php +++ b/includes/SpecialUndelete.php @@ -217,8 +217,7 @@ class PageArchive { # FIXME: Update latest if newer as well... if( $newid ) { # FIXME: update article count if changed... - $article->updateRevisionOn( $dbw, $revision->getId(), - $revision->getText(), $previousRevId ); + $article->updateRevisionOn( $dbw, $revision, $previousRevId ); # Finally, clean up the link tables $wgLinkCache = new LinkCache(); diff --git a/includes/Title.php b/includes/Title.php index 3767b32fea..0de9cd1e5e 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1494,7 +1494,7 @@ class Title { 'comment' => $comment, 'text' => $redirectText ) ); $revid = $redirectRevision->insertOn( $dbw ); - $redirectArticle->updateRevisionOn( $dbw, $revid, $redirectText, 0 ); + $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); $wgLinkCache->clearLink( $this->getPrefixedDBkey() ); # Record in RC @@ -1603,12 +1603,9 @@ class Title { 'comment' => $comment, 'text' => $redirectText ) ); $revid = $redirectRevision->insertOn( $dbw ); - $redirectArticle->updateRevisionOn( $dbw, $revid, $redirectText, 0 ); + $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 ); $wgLinkCache->clearLink( $this->getPrefixedDBkey() ); - // attach revision to the new page - $dbw->update( 'revision', array('rev_page' => $newid), array('rev_id' => $revid), $fname); - # Record in RC // Replaced by a log entry // RecentChange::notifyMoveToNew( $now, $this, $nt, $wgUser, $comment ); diff --git a/maintenance/orphans.php b/maintenance/orphans.php index fa5877373a..219926c863 100755 --- a/maintenance/orphans.php +++ b/maintenance/orphans.php @@ -182,7 +182,7 @@ function checkSeparation( $fix ) { $maxRev = Revision::newFromId( $maxId ); $title = Title::makeTitle( $row->page_namespace, $row->page_title ); $article = new Article( $title ); - $article->updateRevisionOn( $dbw, $maxId, $maxRev->getText() ); + $article->updateRevisionOn( $dbw, $maxRev ); } } } else {