Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/214101
Change subject: Use more appropriate RecentChange_save hook for tagging ...................................................................... Use more appropriate RecentChange_save hook for tagging * At this point the IDs are all known so there is no need to re-query what was written in the transaction * This works when recent change insertion is deferred * Also deferred tagging in ApiVisualEditorEdit to after the RC row is saved Bug: T100439 Change-Id: Ic4c7d8d89b8cfeee57eda867c0ff74fa9682ffc8 --- M ApiVisualEditorEdit.php M VisualEditor.hooks.php M VisualEditor.php 3 files changed, 11 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/01/214101/1 diff --git a/ApiVisualEditorEdit.php b/ApiVisualEditorEdit.php old mode 100644 new mode 100755 index 5e1385f..2be476a --- a/ApiVisualEditorEdit.php +++ b/ApiVisualEditorEdit.php @@ -163,7 +163,11 @@ if ( isset( $saveresult['edit']['newrevid'] ) ) { $newRevId = intval( $saveresult['edit']['newrevid'] ); if ( $this->veConfig->get( 'VisualEditorUseChangeTagging' ) ) { - ChangeTags::addTags( 'visualeditor', null, $newRevId, null ); + // Defer till after the RC row is inserted + // @TODO: doEditContent should let callers specify desired tags + DeferredUpdates::addCallableUpdate( function() use ( $newRevId ) { + ChangeTags::addTags( 'visualeditor', null, $newRevId, null ); + } ); } } else { $newRevId = $page->getLatestRevId(); diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php old mode 100644 new mode 100755 index 7a4b43d..954e02d --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -185,26 +185,14 @@ * Called when an edit is saved * Adds 'visualeditor-switched' tag to the edit if requested * - * @param $article WikiPage - * @param $user User - * @param $content Content - * @param $summary string - * @param $isMinor boolean - * @param $isWatch boolean - * @param $section int - * @param $flags int - * @param $revision Revision|null - * @param $status Status - * @param $baseRevId int|boolean + * @param RecentChange $rc * @return boolean true */ - public static function onPageContentSaveComplete( - $article, $user, $content, $summary, $isMinor, $isWatch, - $section, $flags, $revision, $status, $baseRevId - ) { + public static function onRecentChange_save( RecentChange $rc ) { $request = RequestContext::getMain()->getRequest(); - if ( $request->getBool( 'veswitched' ) && $revision ) { - ChangeTags::addTags( 'visualeditor-switched', null, $revision->getId() ); + if ( $request->getBool( 'veswitched' ) && $rc->mAttribs['rc_this_oldid'] ) { + ChangeTags::addTags( 'visualeditor-switched', + $rc->mAttribs['rc_id'], $rc->mAttribs['rc_this_oldid'] ); } return true; } diff --git a/VisualEditor.php b/VisualEditor.php old mode 100644 new mode 100755 index d333676..ba06924 --- a/VisualEditor.php +++ b/VisualEditor.php @@ -84,7 +84,7 @@ $wgHooks['SkinTemplateNavigation'][] = 'VisualEditorHooks::onSkinTemplateNavigation'; $wgHooks['ParserTestGlobals'][] = 'VisualEditorHooks::onParserTestGlobals'; $wgHooks['EditPage::showEditForm:fields'][] = 'VisualEditorHooks::onEditPageShowEditFormFields'; -$wgHooks['PageContentSaveComplete'][] = 'VisualEditorHooks::onPageContentSaveComplete'; +$wgHooks['RecentChange_save'][] = 'VisualEditorHooks::onRecentChange_save'; $wgHooks['BeforeInitialize'][] = 'VisualEditorHooks::onBeforeInitialize'; $wgExtensionFunctions[] = 'VisualEditorHooks::onSetup'; -- To view, visit https://gerrit.wikimedia.org/r/214101 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic4c7d8d89b8cfeee57eda867c0ff74fa9682ffc8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits