X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_modifier.php?a=blobdiff_plain;f=includes%2Fpage%2FWikiPage.php;h=2e93cb5a0b4d54309419901c661c815ee3cd3e2c;hb=059fd9a2ae21482d823203421f6c5b8ac84ec310;hp=00ac127ea076ced69fc8e9f556949ab19a0f5d2b;hpb=6505e5f278aae664f78fb8f876c10902d2195231;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 00ac127ea0..2e93cb5a0b 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -687,18 +687,6 @@ class WikiPage implements Page, IDBAccessObject { return false; } - /** - * Get the text of the current revision. No side-effects... - * - * @return string|bool The text of the current revision. False on failure - * @deprecated since 1.21, getContent() should be used instead. - */ - public function getRawText() { - ContentHandler::deprecated( __METHOD__, '1.21' ); - - return $this->getText( Revision::RAW ); - } - /** * @return string MW timestamp of last article revision */ @@ -1158,6 +1146,7 @@ class WikiPage implements Page, IDBAccessObject { return true; } + /** * Insert a new empty page record for this article. * This *must* be followed up by creating a revision @@ -1166,13 +1155,16 @@ class WikiPage implements Page, IDBAccessObject { * Best if all done inside a transaction. * * @param IDatabase $dbw - * @return int|bool The newly created page_id key; false if the title already existed + * @param int|null $pageId Custom page ID that will be used for the insert statement + * + * @return bool|int The newly created page_id key; false if the title already existed */ - public function insertOn( $dbw ) { + public function insertOn( $dbw, $pageId = null ) { + $pageIdForInsert = $pageId ?: $dbw->nextSequenceValue( 'page_page_id_seq' ); $dbw->insert( 'page', array( - 'page_id' => $dbw->nextSequenceValue( 'page_page_id_seq' ), + 'page_id' => $pageIdForInsert, 'page_namespace' => $this->mTitle->getNamespace(), 'page_title' => $this->mTitle->getDBkey(), 'page_restrictions' => '', @@ -1188,7 +1180,7 @@ class WikiPage implements Page, IDBAccessObject { ); if ( $dbw->affectedRows() > 0 ) { - $newid = $dbw->insertId(); + $newid = $pageId ?: $dbw->insertId(); $this->mId = $newid; $this->mTitle->resetArticleID( $newid ); @@ -1831,7 +1823,7 @@ class WikiPage implements Page, IDBAccessObject { $revisionId = $revision->insertOn( $dbw ); // Update page_latest and friends to reflect the new revision if ( !$this->updateRevisionOn( $dbw, $revision, null, $meta['oldIsRedirect'] ) ) { - $dbw->rollback( __METHOD__ ); + $dbw->rollback( __METHOD__ ); // sanity; this should never happen throw new MWException( "Failed to update page row to use new revision." ); } @@ -1929,12 +1921,12 @@ class WikiPage implements Page, IDBAccessObject { } $dbw = wfGetDB( DB_MASTER ); - $dbw->begin( __METHOD__ ); + $dbw->startAtomic( __METHOD__ ); // Add the page record unless one already exists for the title $newid = $this->insertOn( $dbw ); if ( $newid === false ) { - $dbw->commit( __METHOD__ ); // nothing inserted + $dbw->endAtomic( __METHOD__ ); // nothing inserted $status->fatal( 'edit-already-exists' ); return $status; // nothing done @@ -1964,7 +1956,7 @@ class WikiPage implements Page, IDBAccessObject { $revisionId = $revision->insertOn( $dbw ); // Update the page record with revision data if ( !$this->updateRevisionOn( $dbw, $revision, 0 ) ) { - $dbw->rollback( __METHOD__ ); + $dbw->rollback( __METHOD__ ); // sanity; this should never happen throw new MWException( "Failed to update page row to use new revision." ); } @@ -1992,25 +1984,34 @@ class WikiPage implements Page, IDBAccessObject { $user->incEditCount(); - $dbw->commit( __METHOD__ ); + $dbw->endAtomic( __METHOD__ ); $this->mTimestamp = $now; - // Update links, etc. - $this->doEditUpdates( $revision, $user, array( 'created' => true ) ); - - $hook_args = array( &$this, &$user, $content, $summary, - $flags & EDIT_MINOR, null, null, &$flags, $revision ); - ContentHandler::runLegacyHooks( 'ArticleInsertComplete', $hook_args ); - Hooks::run( 'PageContentInsertComplete', $hook_args ); - // Return the new revision to the caller $status->value['revision'] = $revision; - // Trigger post-save hook - $hook_args = array( &$this, &$user, $content, $summary, - $flags & EDIT_MINOR, null, null, &$flags, $revision, &$status, $meta['baseRevId'] ); - ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $hook_args ); - Hooks::run( 'PageContentSaveComplete', $hook_args ); + // 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, array( 'created' => true ) ); + // Trigger post-create hook + $params = array( &$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, array( &$status, $meta['baseRevId'] ) ); + ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $params ); + Hooks::run( 'PageContentSaveComplete', $params ); + + } + ); return $status; } @@ -2199,7 +2200,7 @@ class WikiPage implements Page, IDBAccessObject { * - 'no-change': don't update the article count, ever */ public function doEditUpdates( Revision $revision, User $user, array $options = array() ) { - global $wgRCWatchCategoryMembership; + global $wgRCWatchCategoryMembership, $wgContLang; $options += array( 'changed' => true, @@ -2328,6 +2329,10 @@ class WikiPage implements Page, IDBAccessObject { } MessageCache::singleton()->replace( $shortTitle, $msgtext ); + + if ( $wgContLang->hasVariants() ) { + $wgContLang->updateConversionTable( $this->mTitle ); + } } if ( $options['created'] ) { @@ -3275,6 +3280,8 @@ class WikiPage implements Page, IDBAccessObject { * @param Title $title */ public static function onArticleDelete( Title $title ) { + global $wgContLang; + // Update existence markers on article/talk tabs... $other = $title->getOtherPage(); @@ -3290,6 +3297,10 @@ class WikiPage implements Page, IDBAccessObject { // Messages if ( $title->getNamespace() == NS_MEDIAWIKI ) { MessageCache::singleton()->replace( $title->getDBkey(), false ); + + if ( $wgContLang->hasVariants() ) { + $wgContLang->updateConversionTable( $title ); + } } // Images