$oldtext = $this->getRawText(); // current revision
$oldsize = strlen( $oldtext );
+ $oldcountable = $this->isCountable();
# Provide autosummaries if one is not provided and autosummaries are enabled.
if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) {
$userAbort = ignore_user_abort( true );
}
+ $revision = new Revision( array(
+ 'page' => $this->getId(),
+ 'comment' => $summary,
+ 'minor_edit' => $isminor,
+ 'text' => $text,
+ 'parent_id' => $this->mLatest,
+ 'user' => $user->getId(),
+ 'user_text' => $user->getName(),
+ 'timestamp' => $now
+ ) );
+
$changed = ( strcmp( $text, $oldtext ) != 0 );
if ( $changed ) {
return $status;
}
- $revision = new Revision( array(
- 'page' => $this->getId(),
- 'comment' => $summary,
- 'minor_edit' => $isminor,
- 'text' => $text,
- 'parent_id' => $this->mLatest,
- 'user' => $user->getId(),
- 'user_text' => $user->getName(),
- 'timestamp' => $now
- ) );
-
$dbw->begin();
$revisionId = $revision->insertOn( $dbw );
$user->incEditCount();
$dbw->commit();
}
- } else {
- $status->warning( 'edit-no-change' );
- $revision = null;
- // Keep the same revision ID, but do some updates on it
- $revisionId = $this->getLatest();
- // Update page_touched, this is usually implicit in the page update
- // Other cache updates are done in onArticleEdit()
- $this->mTitle->invalidateCache();
}
if ( !$wgDBtransactions ) {
return $status;
}
- # Invalidate cache of this article and all pages using this article
- # as a template. Partly deferred.
- self::onArticleEdit( $this->mTitle );
# Update links tables, site stats, etc.
- $this->doEditUpdates( $text, $user, $summary, $isminor, $revisionId, $changed );
+ $this->doEditUpdates( $revision, $user, array( 'changed' => $changed,
+ 'oldcountable' => $oldcountable ) );
+
+ if ( !$changed ) {
+ $status->warning( 'edit-no-change' );
+ $revision = null;
+ // Keep the same revision ID, but do some updates on it
+ $revisionId = $this->getLatest();
+ // Update page_touched, this is usually implicit in the page update
+ // Other cache updates are done in onArticleEdit()
+ $this->mTitle->invalidateCache();
+ }
} else {
# Create new article
$status->value['new'] = true;
$dbw->commit();
# Update links, etc.
- $this->doEditUpdates( $text, $user, $summary, $isminor, $revisionId, true, true );
-
- # Clear caches
- self::onArticleCreate( $this->mTitle );
+ $this->doEditUpdates( $revision, $user, array( 'created' => true ) );
wfRunHooks( 'ArticleInsertComplete', array( &$this, &$user, $text, $summary,
$flags & EDIT_MINOR, null, null, &$flags, $revision ) );
* Every 100th edit, prune the recent changes table.
*
* @private
- * @param $text String: New text of the article
- * @param $user User object: User doing the edit
- * @param $summary String: Edit summary
- * @param $minoredit Boolean: Minor edit
- * @param $newid Integer: rev_id value of the new revision
- * @param $changed Boolean: Whether or not the content actually changed
- * @param $created Boolean: Whether the edit created the page
- */
- public function doEditUpdates(
- $text, $user, $summary, $minoredit, $newid, $changed = true, $created = false
- ) {
+ * @param $revision Revision object
+ * @param $user User object that did the revision
+ * @param $options Array of options, following indexes are used:
+ * - changed: boolean, whether the revision changed the content (default true)
+ * - created: boolean, whether the revision created the page (default false)
+ * - oldcountable: boolean or null (default null):
+ * - boolean: whether the page was counted as an article before that
+ * revision, only used in changed is true and created is false
+ * - null: don't change the article count
+ */
+ public function doEditUpdates( Revision $revision, User $user, array $options = array() ) {
global $wgDeferredUpdateList, $wgEnableParserCache;
wfProfileIn( __METHOD__ );
+ $options += array( 'changed' => true, 'created' => false, 'oldcountable' => null );
+ $text = $revision->getText();
+
# Parse the text
# Be careful not to double-PST: $text is usually already PST-ed once
if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" );
- $editInfo = $this->prepareTextForEdit( $text, $newid, $user );
+ $editInfo = $this->prepareTextForEdit( $text, $revision->getId(), $user );
} else {
wfDebug( __METHOD__ . ": No vary-revision, using prepared edit...\n" );
$editInfo = $this->mPreparedEdit;
$u = new LinksUpdate( $this->mTitle, $editInfo->output );
$u->doUpdate();
- wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $changed ) );
+ wfRunHooks( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) );
if ( wfRunHooks( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) {
if ( 0 == mt_rand( 0, 99 ) ) {
return;
}
- if ( !$changed ) {
+ if ( !$options['changed'] ) {
$good = 0;
$total = 0;
- } elseif ( $created ) {
+ } elseif ( $options['created'] ) {
$good = (int)$this->isCountable( $editInfo );
$total = 1;
+ } elseif ( $options['oldcountable'] !== null ) {
+ $good = (int)$this->isCountable( $editInfo ) - (int)$options['oldcountable'];
+ $total = 0;
} else {
- $good = (int)$this->isCountable( $editInfo ) - (int)$this->isCountable();
+ $good = 0;
$total = 0;
}
# load of user talk pages and piss people off, nor if it's a minor edit
# by a properly-flagged bot.
if ( $this->mTitle->getNamespace() == NS_USER_TALK && $shortTitle != $user->getTitleKey() && $changed
- && !( $minoredit && $user->isAllowed( 'nominornewtalk' ) )
+ && !( $revision->isMinor() && $user->isAllowed( 'nominornewtalk' ) )
) {
if ( wfRunHooks( 'ArticleEditUpdateNewTalk', array( &$this ) ) ) {
$other = User::newFromName( $shortTitle, false );
MessageCache::singleton()->replace( $shortTitle, $text );
}
+ if( $options['created'] ) {
+ self::onArticleCreate( $this->mTitle );
+ } else {
+ self::onArticleEdit( $this->mTitle );
+ }
+
wfProfileOut( __METHOD__ );
}
*/
public function createUpdates( $rev ) {
global $wgUser;
- $this->doEditUpdates( $rev->getText(), $wgUser, $rev->getComment(),
- $rev->isMinor(), $rev->getId(), true, true );
+ $this->doEditUpdates( $rev, $wgUser, array( 'created' => true ) );
}
/**
return $this->doQuickEdit( $text, $wgUser, $comment, $minor );
}
- /*
- * @deprecated since 1.19
- */
- public function editUpdates(
- $text, $summary, $minoredit, $timestamp_of_pagechange, $newid,
- $changed = true, User $user = null, $created = false
- ) {
- global $wgUser;
- return $this->doEditUpdates( $text, $wgUser, $summary, $minoredit, $newid, $changed, $created );
- }
-
/*
* @deprecated since 1.19
*/