Mobrovac has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/381010 )
Change subject: Emit the page-stable-revision-change event ...................................................................... Emit the page-stable-revision-change event Bug: T169116 Depends-On: I4e3dcc887a5c73fe8d842f02c061f6dcbd376d6a Depends-On: I23f86a291e0dba9e81c03997b236c7fddd7c376f Change-Id: Ib80b47ddc52fe1e677e3798b07bfe22a49d226e1 --- M EventBus.hooks.php M extension.json 2 files changed, 53 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventBus refs/changes/10/381010/1 diff --git a/EventBus.hooks.php b/EventBus.hooks.php index ae118d6..94b71a4 100644 --- a/EventBus.hooks.php +++ b/EventBus.hooks.php @@ -684,4 +684,54 @@ } ); } + + /** + * Sends a page-stable-revision-change event + * + * @param FlaggableWikiPage $article the article for which the stable rev has changed + * @param FlaggedRevision $newStableRev the new stable revision (can be null) + * @param FlaggedRevision $oldStableRev the old stable revision (can be null) + */ + public static function onFlaggedRevsStableRevisionUpdate( + $article, + $newStableRev, + $oldStableRev + ) { + + global $wgDBname; + $events = []; + $new_stable = $newStableRev ? $newStableRev->getRevision() : 0; + $old_stable = $oldStableRev ? $oldStableRev->getRevision() : 0; + $user = $newStableRev ? $newStableRev->getUser() : $oldStableRev->getUser(); + + // Create a mediawiki page stable revision change event. + $attrs = [ + // Common Mediawiki entity fields + 'database' => $wgDBname, + 'performer' => EventBus::createPerformerAttrs( $user ), + // page entity fields + 'page_id' => $article->getId(), + 'page_title' => $article->getTitle()->getPrefixedDBkey(), + 'page_namespace' => $article->getTitle()->getNamespace(), + 'page_is_redirect' => $article->isRedirect(), + 'rev_id' => $article->getTitle()->getLatestRevID(), + 'stable_rev_id' => $new_stable, + 'prior_state' => [ + 'stable_rev_id' => $old_stable + ] + ]; + + $events[] = EventBus::createEvent( + EventBus::getArticleURL( $article->getTitle() ), + 'mediawiki.page-stable-revision-change', + ); + + DeferredUpdates::addCallableUpdate( + function () use ( $events ) { + EventBus::getInstance()->send( $events ); + } + ); + + } + } diff --git a/extension.json b/extension.json index f887d04..32f0cb9 100644 --- a/extension.json +++ b/extension.json @@ -62,6 +62,9 @@ ], "ArticleProtectComplete": [ "EventBusHooks::onArticleProtectComplete" + ], + "FlaggedRevsStableRevisionUpdate": [ + "EventBusHooks::onFlaggedRevsStableRevisionUpdate" ] }, "manifest_version": 1 -- To view, visit https://gerrit.wikimedia.org/r/381010 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib80b47ddc52fe1e677e3798b07bfe22a49d226e1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/EventBus Gerrit-Branch: master Gerrit-Owner: Mobrovac <mobro...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits