Ppchelko has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/290906

Change subject: Use getPrefixedURL and getPrefixedDBkey instead of getText
......................................................................

Use getPrefixedURL and getPrefixedDBkey instead of getText

The getText() method of a Title strips out the namespace prefix.
If we want to use the titles in change-prop, the easiest way is
to use titles in the prefixed db-key format. In that case we will
be able to 'just use' the field without additional processing.

Also, the titles which are used in the URIs for resource_change
event should be uri-encoded.

Change-Id: I132d0b7e70e1a992f0204361a71b715c2cd1655f
---
M EventBus.hooks.php
M extension.json
2 files changed, 11 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventBus 
refs/changes/06/290906/1

diff --git a/EventBus.hooks.php b/EventBus.hooks.php
index 5849c14..60455c1 100644
--- a/EventBus.hooks.php
+++ b/EventBus.hooks.php
@@ -71,7 +71,7 @@
         */
        public static function onRevisionInsertComplete( $revision, $data, 
$flags ) {
                $attrs = [];
-               $attrs['page_title'] = $revision->getTitle()->getText();
+               $attrs['page_title'] = 
$revision->getTitle()->getPrefixedDBkey();
                $attrs['page_id'] = $revision->getPage();
                $attrs['page_namespace'] = 
$revision->getTitle()->getNamespace();
                $attrs['rev_id'] = $revision->getId();
@@ -111,7 +111,7 @@
                        $logEntry
        ) {
                $attrs = [];
-               $attrs['title'] = $article->getTitle()->getText();
+               $attrs['title'] = $article->getTitle()->getPrefixedDBkey();
                $attrs['page_id'] = $id;
                $attrs['user_id'] = $user->getId();
                $attrs['user_text'] = $user->getName();
@@ -136,7 +136,7 @@
         */
        public static function onArticleUndelete( Title $title, $create, 
$comment, $oldPageId ) {
                $attrs = [];
-               $attrs['title'] = $title->getText();
+               $attrs['title'] = $title->getPrefixedDBkey();
                $attrs['new_page_id'] = $title->getArticleID();
                if ( !is_null( $oldPageId ) && $oldPageId !== 0 ) {
                    $attrs['old_page_id'] = $oldPageId;
@@ -172,8 +172,8 @@
                        $newid, $reason, Revision $newRevision
        ) {
                $attrs = [];
-               $attrs['new_title'] = $newtitle->getText();
-               $attrs['old_title'] = $title->getText();
+               $attrs['new_title'] = $newtitle->getPrefixedDBkey();
+               $attrs['old_title'] = $title->getPrefixedDBkey();
                $attrs['page_id'] = $oldid;
                $attrs['new_revision_id'] = $newRevision->getId();
                $attrs['old_revision_id'] = $newRevision->getParentId();
@@ -240,7 +240,9 @@
        public static function onArticlePurge( $wikiPage ) {
                global $wgCanonicalServer, $wgArticlePath;
                // The $wgArticlePath contains '$1' string where the article 
title should appear.
-               $uri = $wgCanonicalServer . str_replace( '$1', 
$wikiPage->getTitle()->getText(), $wgArticlePath );
+               $title = $wikiPage->getTitle()->getPrefixedURL();
+               $uri = $wgCanonicalServer . str_replace( '$1', $title, 
$wgArticlePath );
+
                $event = self::createEvent( $uri, 'resource_change', [
                        'tags' => [ 'purge' ]
                ] );
@@ -278,7 +280,8 @@
                // In case of a null edit the status revision value will be null
                if ( is_null( $status->getValue()['revision'] ) ) {
                        // The $wgArticlePath contains '$1' string where the 
article title should appear.
-                       $uri = $wgCanonicalServer . str_replace( '$1', 
$article->getTitle()->getText(), $wgArticlePath );
+                       $title = $article->getTitle()->getPrefixedURL();
+                       $uri = $wgCanonicalServer . str_replace( '$1', $title, 
$wgArticlePath );
                        $event = self::createEvent( $uri, 'resource_change', [
                                'tags' => [ 'null_edit' ]
                        ] );
diff --git a/extension.json b/extension.json
index 7ca6de3..be89bd7 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "EventBus",
-       "version": "0.2.5",
+       "version": "0.2.6",
        "author": [
                "Eric Evans"
        ],

-- 
To view, visit https://gerrit.wikimedia.org/r/290906
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I132d0b7e70e1a992f0204361a71b715c2cd1655f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EventBus
Gerrit-Branch: wmf/1.28.0-wmf.3
Gerrit-Owner: Ppchelko <[email protected]>

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

Reply via email to