Ppchelko has uploaded a new change for review.

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

Change subject: Replace wfUrlEncode with rawurlencode
......................................................................

Replace wfUrlEncode with rawurlencode

wfUrlEncode doesn't encode slashes, but change-prop
expects slashes to be encoded, so replace it with
standard php rawurlencode function.

Change-Id: Ic1db69fc051adfe73453f26fca3927d8b00bee82
---
M EventBus.hooks.php
M extension.json
2 files changed, 20 insertions(+), 13 deletions(-)


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

diff --git a/EventBus.hooks.php b/EventBus.hooks.php
index 60455c1..341deb6 100644
--- a/EventBus.hooks.php
+++ b/EventBus.hooks.php
@@ -61,6 +61,22 @@
        }
 
        /**
+        * Creates a full article path
+        *
+        * @param Title $title article title object
+        * @return string
+        */
+       private static function getArticleURL( $title ) {
+               global $wgCanonicalServer, $wgArticlePath;
+               // can't use wfUrlencode, because it doesn't encode slashes. 
RESTBase
+               // and services expect slashes to be encoded, so encode the 
whole title
+               // right away to avoid reencoding it in change-propagation
+               $titleURL = rawurlencode( $title->getPrefixedDBkey() );
+               // The $wgArticlePath contains '$1' string where the article 
title should appear.
+               return $wgCanonicalServer . str_replace( '$1', $titleURL, 
$wgArticlePath );
+       }
+
+       /**
         * Occurs after a revision is inserted into the DB
         *
         * @see 
https://www.mediawiki.org/wiki/Manual:Hooks/RevisionInsertComplete
@@ -238,12 +254,7 @@
         * @param WikiPage $wikiPage
         */
        public static function onArticlePurge( $wikiPage ) {
-               global $wgCanonicalServer, $wgArticlePath;
-               // The $wgArticlePath contains '$1' string where the article 
title should appear.
-               $title = $wikiPage->getTitle()->getPrefixedURL();
-               $uri = $wgCanonicalServer . str_replace( '$1', $title, 
$wgArticlePath );
-
-               $event = self::createEvent( $uri, 'resource_change', [
+               $event = self::createEvent( self::getArticleURL( 
$wikiPage->getTitle() ), 'resource_change', [
                        'tags' => [ 'purge' ]
                ] );
 
@@ -275,14 +286,10 @@
        public static function onPageContentSaveComplete( $article, $user, 
$content, $summary, $isMinor,
                                $isWatch, $section, $flags, $revision, $status, 
$baseRevId
        ) {
-               global $wgCanonicalServer, $wgArticlePath;
-
                // 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.
-                       $title = $article->getTitle()->getPrefixedURL();
-                       $uri = $wgCanonicalServer . str_replace( '$1', $title, 
$wgArticlePath );
-                       $event = self::createEvent( $uri, 'resource_change', [
+
+                       $event = self::createEvent( self::getArticleURL( 
$article->getTitle() ), 'resource_change', [
                                'tags' => [ 'null_edit' ]
                        ] );
 
diff --git a/extension.json b/extension.json
index be89bd7..2c8427f 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "EventBus",
-       "version": "0.2.6",
+       "version": "0.2.8",
        "author": [
                "Eric Evans"
        ],

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic1db69fc051adfe73453f26fca3927d8b00bee82
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