Eevans has uploaded a new change for review.
https://gerrit.wikimedia.org/r/258475
Change subject: handle parent_revision_id on page creation
......................................................................
handle parent_revision_id on page creation
When a new page is created, the hook is called with a `$baseRevId` value of
FALSE (to indicate there is none). In such cases, we should omit the
`parent_revision_id` attribute of events entirely, as it is a) not required,
but b) must have a value greater than 1 if supplied.
Bug: T116786
Change-Id: I65d699c7f6d141cb7b890d5e9ed567fe27843a80
---
M EventBus.hooks.php
1 file changed, 8 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventBus
refs/changes/75/258475/1
diff --git a/EventBus.hooks.php b/EventBus.hooks.php
index b152f4d..b20d4fc 100644
--- a/EventBus.hooks.php
+++ b/EventBus.hooks.php
@@ -25,6 +25,7 @@
/** Event object stub */
private static function createEvent( $uri, $topic, $attrs ) {
+ global $wgServerName;
$event = array(
'meta' => array(
'uri' => $uri,
@@ -84,12 +85,18 @@
$attrs['page_id'] = $article->getId();
$attrs['namespace'] = $article->getTitle()->getNamespace();
$attrs['revision_id'] = $revision->getId();
- $attrs['parent_revision_id'] = $baseRevId ? $baseRevId :
$revision->getParentId();
$attrs['save_dt'] = wfTimestamp( TS_ISO_8601,
$revision->getTimestamp() );
$attrs['user_id'] = $user->getId();
$attrs['user_text'] = $user->getName();
$attrs['summary'] = $summary;
+ // 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
+ // base revision.
+ if ( $baseRevId ) {
+ $attrs['parent_revision_id'] = $baseRevId;
+ }
+
$event = self::createEvent( '/edit/uri', 'mediawiki.page_edit',
$attrs );
EventBus::getInstance()->send( array( $event ) );
--
To view, visit https://gerrit.wikimedia.org/r/258475
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I65d699c7f6d141cb7b890d5e9ed567fe27843a80
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EventBus
Gerrit-Branch: master
Gerrit-Owner: Eevans <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits