Sbisson has uploaded a new change for review. https://gerrit.wikimedia.org/r/312277
Change subject: Adding data needed by ERI ...................................................................... Adding data needed by ERI user_edit_count user_registration rev_bytes_changes page_edit_protection page_is_disambiguation Bug: T145164 Change-Id: Ib6c53375d47301e8169a305f75bd319577806b93 Depends-On: I05172ae9587a3c6ab6ff0f47a4ed7c5cb367379d --- M EventBus.hooks.php 1 file changed, 40 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventBus refs/changes/77/312277/1 diff --git a/EventBus.hooks.php b/EventBus.hooks.php index e40a791..bf5f6ef 100644 --- a/EventBus.hooks.php +++ b/EventBus.hooks.php @@ -43,8 +43,10 @@ * Given a User $user, returns an array suitable for * use as the performer JSON object in various Mediawiki * entity schemas. + * @param User $user + * @return array */ - public static function createPerformerAttrs( $user ) { + public static function createPerformerAttrs( User $user ) { $performerAttrs = [ 'user_text' => $user->getName(), 'user_groups' => $user->getEffectiveGroups(), @@ -52,6 +54,8 @@ ]; if ( $user->getId() ) { $performerAttrs['user_id'] = $user->getId(); + $performerAttrs['user_edit_count'] = $user->getEditCount(); + $performerAttrs['user_registration'] = wfTimestamp( TS_ISO_8601, $user->getRegistration() ); } return $performerAttrs; } @@ -131,16 +135,17 @@ 'comment' => $revision->getComment(), // revision entity fields - 'page_id' => $revision->getPage(), - 'page_title' => $revision->getTitle()->getPrefixedDBkey(), - 'page_namespace' => $revision->getTitle()->getNamespace(), - 'rev_id' => $revision->getId(), - 'rev_timestamp' => wfTimestamp( TS_ISO_8601, $revision->getTimestamp() ), - 'rev_sha1' => $revision->getSha1(), - 'rev_len' => $revision->getSize(), - 'rev_minor_edit' => $revision->isMinor(), - 'rev_content_model' => $revision->getContentModel(), - 'rev_content_format' => $revision->getContentModel(), + 'page_id' => $revision->getPage(), + 'page_title' => $revision->getTitle()->getPrefixedDBkey(), + 'page_namespace' => $revision->getTitle()->getNamespace(), + 'page_is_disambiguation' => self::isDisambiguation( $revision->getTitle() ), + 'rev_id' => $revision->getId(), + 'rev_timestamp' => wfTimestamp( TS_ISO_8601, $revision->getTimestamp() ), + 'rev_sha1' => $revision->getSha1(), + 'rev_len' => $revision->getSize(), + 'rev_minor_edit' => $revision->isMinor(), + 'rev_content_model' => $revision->getContentModel(), + 'rev_content_format' => $revision->getContentModel(), ]; // It is possible that the $revision object does not have any content @@ -158,8 +163,17 @@ // must have a minimum value of 1, so omit it entirely when there is no // parent revision (i.e. page creation). $parentId = $revision->getParentId(); + $previousSize = 0; if ( !is_null( $parentId ) && $parentId !== 0 ) { $attrs['rev_parent_id'] = $parentId; + $previousSize = $revision->getPrevious()->getSize(); + } + + $attrs['rev_bytes_changed'] = $attrs['rev_len'] - $previousSize; + + $editProtection = $revision->getTitle()->getRestrictions( 'edit' ); + if ( $editProtection ) { + $attrs['page_edit_protection'] = reset( $editProtection ); } $events[] = self::createEvent( @@ -617,4 +631,19 @@ } ); } + + /** + * Determine if a title is a disambiguation page by looking for the + * page property maintained by the Disambiguator extension. + * + * False negatives will happen if the Disambiguator extension is not used + * on a wiki or if a disambiguation page does not contain the proper + * template of magic word. + * + * @param Title $title + * @return bool + */ + private static function isDisambiguation( Title $title ) { + return (bool)PageProps::getInstance()->getProperties( $title, 'disambiguation' ); + } } -- To view, visit https://gerrit.wikimedia.org/r/312277 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib6c53375d47301e8169a305f75bd319577806b93 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/EventBus Gerrit-Branch: master Gerrit-Owner: Sbisson <sbis...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits