jenkins-bot has submitted this change and it was merged.

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(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  Mobrovac: Looks good to me, but someone else must approve
  Hashar: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/EventBus.hooks.php b/EventBus.hooks.php
index b733b7a..de5ad46 100644
--- a/EventBus.hooks.php
+++ b/EventBus.hooks.php
@@ -91,12 +91,19 @@
                $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
+               // parent revision (i.e. page creation).
+               $parentId = $revision->getParentId();
+               if ( !is_null( $parentId ) ) {
+                       $attrs['parent_revision_id'] = $parentId;
+               }
+
                $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: merged
Gerrit-Change-Id: I65d699c7f6d141cb7b890d5e9ed567fe27843a80
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/EventBus
Gerrit-Branch: master
Gerrit-Owner: Eevans <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Eevans <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Mobrovac <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to