X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fpage%2FWikiPage.php;h=d30f589e74dae9f71da9e75af6a669e0789e6978;hb=eca35903a2390bf7eb503fa0ede6a76ce556dc55;hp=8373dc01b14602609bda1032ce29b0735a81f3e3;hpb=29790fbc0492428db6fcc3c3b9db09ea14ecabb6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 8373dc01b1..d30f589e74 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -2029,7 +2029,8 @@ class WikiPage implements Page, IDBAccessObject { * Returns a stdClass with source, pst and output members * * @param Content $content - * @param int|null $revid + * @param Revision|int|null $revision Revision object. For backwards compatibility, a + * revision ID is also accepted, but this is deprecated. * @param User|null $user * @param string|null $serialFormat * @param bool $useCache Check shared prepared edit cache @@ -2039,10 +2040,23 @@ class WikiPage implements Page, IDBAccessObject { * @since 1.21 */ public function prepareContentForEdit( - Content $content, $revid = null, User $user = null, $serialFormat = null, $useCache = true + Content $content, $revision = null, User $user = null, $serialFormat = null, $useCache = true ) { global $wgContLang, $wgUser, $wgAjaxEditStash; + if ( is_object( $revision ) ) { + $revid = $revision->getId(); + } else { + $revid = $revision; + // This code path is deprecated, and nothing is known to + // use it, so performance here shouldn't be a worry. + if ( $revid !== null ) { + $revision = Revision::newFromId( $revid, Revision::READ_LATEST ); + } else { + $revision = null; + } + } + $user = is_null( $user ) ? $wgUser : $user; //XXX: check $user->getId() here??? @@ -2092,6 +2106,25 @@ class WikiPage implements Page, IDBAccessObject { if ( $cachedEdit ) { $edit->output = $cachedEdit->output; } else { + if ( $revision ) { + // We get here if vary-revision is set. This means that this page references + // itself (such as via self-transclusion). In this case, we need to make sure + // that any such self-references refer to the newly-saved revision, and not + // to the previous one, which could otherwise happen due to slave lag. + $oldCallback = $edit->popts->setCurrentRevisionCallback( + function ( $title, $parser = false ) use ( $revision, &$oldCallback ) { + if ( $title->equals( $revision->getTitle() ) ) { + return $revision; + } else { + return call_user_func( + $oldCallback, + $title, + $parser + ); + } + } + ); + } $edit->output = $edit->pstContent ? $edit->pstContent->getParserOutput( $this->mTitle, $revid, $edit->popts ) : null; @@ -2121,10 +2154,12 @@ class WikiPage implements Page, IDBAccessObject { * - changed: boolean, whether the revision changed the content (default true) * - created: boolean, whether the revision created the page (default false) * - moved: boolean, whether the page was moved (default false) - * - oldcountable: boolean or null (default null): + * - oldcountable: boolean, null, or string 'no-change' (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 + * - null: if created is false, don't update the article count; if created + * is true, do update the article count + * - 'no-change': don't update the article count, ever */ public function doEditUpdates( Revision $revision, User $user, array $options = array() ) { global $wgEnableParserCache; @@ -2142,7 +2177,7 @@ class WikiPage implements Page, IDBAccessObject { // already pre-save transformed once. if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) { wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" ); - $editInfo = $this->prepareContentForEdit( $content, $revision->getId(), $user ); + $editInfo = $this->prepareContentForEdit( $content, $revision, $user ); } else { wfDebug( __METHOD__ . ": No vary-revision, using prepared edit...\n" ); $editInfo = $this->mPreparedEdit; @@ -2167,11 +2202,8 @@ class WikiPage implements Page, IDBAccessObject { Hooks::run( 'ArticleEditUpdates', array( &$this, &$editInfo, $options['changed'] ) ); if ( Hooks::run( 'ArticleEditUpdatesDeleteFromRecentchanges', array( &$this ) ) ) { - if ( 0 == mt_rand( 0, 99 ) ) { - // Flush old entries from the `recentchanges` table; we do this on - // random requests so as to avoid an increase in writes for no good reason - RecentChange::purgeExpiredChanges(); - } + // Flush old entries from the `recentchanges` table + JobQueueGroup::singleton()->push( RecentChangesUpdateJob::newPurgeJob() ); } if ( !$this->exists() ) { @@ -2182,7 +2214,9 @@ class WikiPage implements Page, IDBAccessObject { $title = $this->mTitle->getPrefixedDBkey(); $shortTitle = $this->mTitle->getDBkey(); - if ( !$options['changed'] && !$options['moved'] ) { + if ( $options['oldcountable'] === 'no-change' || + ( !$options['changed'] && !$options['moved'] ) + ) { $good = 0; } elseif ( $options['created'] ) { $good = (int)$this->isCountable( $editInfo ); @@ -2983,8 +3017,8 @@ class WikiPage implements Page, IDBAccessObject { // Get the last edit not by this guy... // Note: these may not be public values - $user = intval( $current->getRawUser() ); - $user_text = $dbw->addQuotes( $current->getRawUserText() ); + $user = intval( $current->getUser( Revision::RAW ) ); + $user_text = $dbw->addQuotes( $current->getUserText( Revision::RAW ) ); $s = $dbw->selectRow( 'revision', array( 'rev_id', 'rev_timestamp', 'rev_deleted' ), array( 'rev_page' => $current->getPage(),