X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fpage%2FWikiPage.php;h=c17fe1eb683ba5a542c144d9a7d9c6d315d09496;hb=add1ebe2ab7cbbaf27f8f60a2d0b05769dff71a2;hp=b06b51967a545d6816b2c0fa6dbd68cb620644ab;hpb=04d89c3f2aa45d96f490a4f6961721e4fce6bfdd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index b06b51967a..c17fe1eb68 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -1043,14 +1043,16 @@ class WikiPage implements Page, IDBAccessObject { * * @since 1.19 * @param ParserOptions $parserOptions ParserOptions to use for the parse operation - * @param null|int $oldid Revision ID to get the text from, passing null or 0 will - * get the current revision (default value) - * - * @return ParserOutput|bool ParserOutput or false if the revision was not found + * @param null|int $oldid Revision ID to get the text from, passing null or 0 will + * get the current revision (default value) + * @param bool $forceParse Force reindexing, regardless of cache settings + * @return bool|ParserOutput ParserOutput or false if the revision was not found */ - public function getParserOutput( ParserOptions $parserOptions, $oldid = null ) { + public function getParserOutput( ParserOptions $parserOptions, $oldid = null, + $forceParse = false ) { - $useParserCache = $this->shouldCheckParserCache( $parserOptions, $oldid ); + $useParserCache = + ( !$forceParse ) && $this->shouldCheckParserCache( $parserOptions, $oldid ); wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); if ( $parserOptions->getStubThreshold() ) { @@ -1103,15 +1105,10 @@ class WikiPage implements Page, IDBAccessObject { return false; } - $title = $this->mTitle; - wfGetDB( DB_MASTER )->onTransactionIdle( function() use ( $title ) { - // Invalidate the cache in auto-commit mode - $title->invalidateCache(); - } ); - + $this->mTitle->invalidateCache(); // Send purge after above page_touched update was committed DeferredUpdates::addUpdate( - new CdnCacheUpdate( $title->getCdnUrls() ), + new CdnCacheUpdate( $this->mTitle->getCdnUrls() ), DeferredUpdates::PRESEND ); @@ -1815,30 +1812,31 @@ class WikiPage implements Page, IDBAccessObject { } // Do secondary updates once the main changes have been committed... - $that = $this; - $dbw->onTransactionIdle( - function () use ( - $dbw, &$that, $revision, &$user, $content, $summary, &$flags, - $changed, $meta, &$status - ) { - // Do per-page updates in a transaction - $dbw->setFlag( DBO_TRX ); - // Update links tables, site stats, etc. - $that->doEditUpdates( - $revision, - $user, - [ - 'changed' => $changed, - 'oldcountable' => $meta['oldCountable'], - 'oldrevision' => $meta['oldRevision'] - ] - ); - // Trigger post-save hook - $params = [ &$that, &$user, $content, $summary, $flags & EDIT_MINOR, - null, null, &$flags, $revision, &$status, $meta['baseRevId'] ]; - ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params ); - Hooks::run( 'PageContentSaveComplete', $params ); - } + DeferredUpdates::addUpdate( + new AtomicSectionUpdate( + $dbw, + __METHOD__, + function () use ( + $revision, &$user, $content, $summary, &$flags, + $changed, $meta, &$status + ) { + // Update links tables, site stats, etc. + $this->doEditUpdates( + $revision, + $user, + [ + 'changed' => $changed, + 'oldcountable' => $meta['oldCountable'], + 'oldrevision' => $meta['oldRevision'] + ] + ); + // Trigger post-save hook + $params = [ &$this, &$user, $content, $summary, $flags & EDIT_MINOR, + null, null, &$flags, $revision, &$status, $meta['baseRevId'] ]; + ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params ); + Hooks::run( 'PageContentSaveComplete', $params ); + } + ) ); return $status; @@ -1943,26 +1941,27 @@ class WikiPage implements Page, IDBAccessObject { $status->value['revision'] = $revision; // Do secondary updates once the main changes have been committed... - $that = $this; - $dbw->onTransactionIdle( - function () use ( - &$that, $dbw, $revision, &$user, $content, $summary, &$flags, $meta, &$status - ) { - // Do per-page updates in a transaction - $dbw->setFlag( DBO_TRX ); - // Update links, etc. - $that->doEditUpdates( $revision, $user, [ 'created' => true ] ); - // Trigger post-create hook - $params = [ &$that, &$user, $content, $summary, - $flags & EDIT_MINOR, null, null, &$flags, $revision ]; - ContentHandler::runLegacyHooks( 'ArticleInsertComplete', $params ); - Hooks::run( 'PageContentInsertComplete', $params ); - // Trigger post-save hook - $params = array_merge( $params, [ &$status, $meta['baseRevId'] ] ); - ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params ); - Hooks::run( 'PageContentSaveComplete', $params ); + DeferredUpdates::addUpdate( + new AtomicSectionUpdate( + $dbw, + __METHOD__, + function () use ( + $revision, &$user, $content, $summary, &$flags, $meta, &$status + ) { + // Update links, etc. + $this->doEditUpdates( $revision, $user, [ 'created' => true ] ); + // Trigger post-create hook + $params = [ &$this, &$user, $content, $summary, + $flags & EDIT_MINOR, null, null, &$flags, $revision ]; + ContentHandler::runLegacyHooks( 'ArticleInsertComplete', $params ); + Hooks::run( 'PageContentInsertComplete', $params ); + // Trigger post-save hook + $params = array_merge( $params, [ &$status, $meta['baseRevId'] ] ); + ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params ); + Hooks::run( 'PageContentSaveComplete', $params ); - } + } + ) ); return $status; @@ -3279,6 +3278,14 @@ class WikiPage implements Page, IDBAccessObject { $title->touchLinks(); $title->purgeSquid(); $title->deleteTitleProtection(); + + if ( $title->getNamespace() == NS_CATEGORY ) { + // Load the Category object, which will schedule a job to create + // the category table row if necessary. Checking a slave is ok + // here, in the worst case it'll run an unnecessary recount job on + // a category that probably doesn't have many members. + Category::newFromTitle( $title )->getID(); + } } /** @@ -3525,6 +3532,22 @@ class WikiPage implements Page, IDBAccessObject { $cat = Category::newFromName( $catName ); Hooks::run( 'CategoryAfterPageRemoved', [ $cat, $this, $id ] ); } + + // Refresh counts on categories that should be empty now, to + // trigger possible deletion. Check master for the most + // up-to-date cat_pages. + if ( count( $deleted ) ) { + $rows = $dbw->select( + 'category', + [ 'cat_id', 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files' ], + [ 'cat_title' => $deleted, 'cat_pages <= 0' ], + $method + ); + foreach ( $rows as $row ) { + $cat = Category::newFromRow( $row ); + $cat->refreshCounts(); + } + } } ); }