Ppchelko has uploaded a new change for review.
https://gerrit.wikimedia.org/r/270871
Change subject: Implemented revision_create event and replaced page_edit event.
......................................................................
Implemented revision_create event and replaced page_edit event.
Bug: T126220
Change-Id: I9b42b22677773c7216af7745d25b2582359f9ba7
---
M .gitignore
M EventBus.hooks.php
M extension.json
3 files changed, 19 insertions(+), 34 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventBus
refs/changes/71/270871/1
diff --git a/.gitignore b/.gitignore
index 0edead7..87df129 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@
/composer.lock
/node_modules/
/vendor/
+.idea/
diff --git a/EventBus.hooks.php b/EventBus.hooks.php
index fcc714b..1cbe8ee 100644
--- a/EventBus.hooks.php
+++ b/EventBus.hooks.php
@@ -61,50 +61,34 @@
}
/**
- * Occurs after the save page request has been processed.
+ * Occurs after a revision is inserted into the DB
*
- * @see
https://www.mediawiki.org/wiki/Manual:Hooks/PageContentSaveComplete
+ * @see
https://www.mediawiki.org/wiki/Manual:Hooks/RevisionInsertComplete
*
- * @param WikiPage $article
- * @param User $user
- * @param Content $content
- * @param string $summary
- * @param boolean $isMinor
- * @param boolean $isWatch
- * @param $section Deprecated
+ * @param Revision $revision
+ * @param string $data
* @param integer $flags
- * @param {Revision|null} $revision
- * @param Status $status
- * @param integer $baseRevId
*/
- public static function onPageContentSaveComplete( $article, $user,
$content, $summary, $isMinor,
- $isWatch, $section, $flags, $revision, $status,
$baseRevId
- ) {
- // A null edit; Someone mashed 'Save', but no changes were
recorded (no
- // revision was created).
- if ( is_null( $revision ) ) {
- return;
- }
-
+ public static function onRevisionInsertComplete( $revision, $data,
$flags ) {
$attrs = array();
- $attrs['title'] = $article->getTitle()->getText();
- $attrs['page_id'] = $article->getId();
- $attrs['namespace'] = $article->getTitle()->getNamespace();
- $attrs['revision_id'] = $revision->getId();
- $attrs['save_dt'] = wfTimestamp( TS_ISO_8601,
$revision->getTimestamp() );
- $attrs['user_id'] = $user->getId();
- $attrs['user_text'] = $user->getName();
- $attrs['summary'] = $summary;
+ $attrs['page_title'] = $revision->getTitle()->getText();
+ $attrs['page_id'] = $revision->getPage();
+ $attrs['page_namespace'] =
$revision->getTitle()->getNamespace();
+ $attrs['rev_id'] = $revision->getId();
+ $attrs['rev_timestamp'] = wfTimestamp( TS_ISO_8601,
$revision->getTimestamp() );
+ $attrs['user_id'] = $revision->getUser();
+ $attrs['user_text'] = $revision->getUserText();
+ $attrs['comment'] = $revision->getComment();
// The parent_revision_id attribute is not required, but when
supplied
// must have a minimum value of 1, so omit it entirely when
there is no
// parent revision (i.e. page creation).
$parentId = $revision->getParentId();
if ( !is_null( $parentId ) ) {
- $attrs['parent_revision_id'] = $parentId;
+ $attrs['rev_parent_id'] = $parentId;
}
- $event = self::createEvent( '/edit/uri', 'mediawiki.page_edit',
$attrs );
+ $event = self::createEvent( '/edit/uri',
'mediawiki.revision_create', $attrs );
DeferredUpdates::addCallableUpdate( function() use ( $event ) {
EventBus::getInstance()->send( array( $event ) );
diff --git a/extension.json b/extension.json
index 13571b2..26380db 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
{
"name": "EventBus",
- "version": "0.1.0",
+ "version": "0.2.0",
"author": [
"Eric Evans"
],
@@ -21,8 +21,8 @@
]
},
"Hooks": {
- "PageContentSaveComplete": [
- "EventBusHooks::onPageContentSaveComplete"
+ "RevisionInsertComplete": [
+ "EventBusHooks::onRevisionInsertComplete"
],
"ArticleDeleteComplete": [
"EventBusHooks::onArticleDeleteComplete"
--
To view, visit https://gerrit.wikimedia.org/r/270871
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b42b22677773c7216af7745d25b2582359f9ba7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EventBus
Gerrit-Branch: master
Gerrit-Owner: Ppchelko <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits