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

Change subject: Store title as a job parameter
......................................................................


Store title as a job parameter

In some cases, a namespace on a target site will be an
interwiki prefix on the submission site. This, along with
bug 58524 will cause the namespace to be dropped, so the
job would use the wrong title.

We work around this by storing the real title as text in the job's
parameters. When the job is pulled from the queue on the target
site, the full title, as the user intended, will be evaluated in
the context of the target site.

Bug: 57464
Change-Id: Ie3ecb22001b4f9bc8d9b891cd096061da5151505
---
M MassMessageJob.php
M MassMessageSubmitJob.php
M tests/MassMessageTest.php
3 files changed, 12 insertions(+), 9 deletions(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/MassMessageJob.php b/MassMessageJob.php
index 670bfac..dcc8736 100644
--- a/MassMessageJob.php
+++ b/MassMessageJob.php
@@ -12,15 +12,15 @@
  */
 class MassMessageJob extends Job {
        public function __construct( Title $title, array $params, $id = 0 ) {
-               parent::__construct( 'MassMessageJob', $title, $params, $id );
-               // More debug logging for bug 57464
-               wfDebugLog( 'MassMessage', "Before re-normalizing, title is 
\"{$this->title->getPrefixedText()}\", "
-                       . "interwiki is \"{$this->title->getInterwiki()}\", ns 
is \"{$this->title->getNamespace()}\"" );
                // Create a fresh Title object so namespaces are evaluated
-               // in the context of the target site. Bug 57464
-               $this->title = Title::newFromText( 
$this->title->getPrefixedText() );
-               wfDebugLog( 'MassMessage', "After re-normalizing, title is 
\"{$this->title->getPrefixedText()}\", "
-                       . "interwiki is \"{$this->title->getInterwiki()}\", ns 
is \"{$this->title->getNamespace()}\"" );
+               // in the context of the target site. See bug 57464.
+               // Note that jobs created previously might not have a
+               // title param, so check for that.
+               if ( isset( $params['title'] ) ) {
+                       $title = Title::newFromText( $params['title'] );
+               }
+
+               parent::__construct( 'MassMessageJob', $title, $params, $id );
        }
 
        /**
diff --git a/MassMessageSubmitJob.php b/MassMessageSubmitJob.php
index ca25805..0032d06 100644
--- a/MassMessageSubmitJob.php
+++ b/MassMessageSubmitJob.php
@@ -25,6 +25,9 @@
 
                foreach ( $pages as $page ) {
                        $title = Title::newFromText( $page['title'] );
+                       // Store the title as plain text to avoid 
namespace/interwiki prefix
+                       // collisions, see bug 57464 and 58524
+                       $data['title'] = $page['title'];
                        $jobsByTarget[$page['wiki']][] = new MassMessageJob( 
$title, $data );
                }
 
diff --git a/tests/MassMessageTest.php b/tests/MassMessageTest.php
index 13250eb..14c100d 100644
--- a/tests/MassMessageTest.php
+++ b/tests/MassMessageTest.php
@@ -67,7 +67,7 @@
         */
        public static function simulateJob( $title ) {
                $subject = md5( MWCryptRand::generateHex( 15 ) );
-               $params = array( 'subject' => $subject, 'message' => 'This is a 
message.', );
+               $params = array( 'subject' => $subject, 'message' => 'This is a 
message.', 'title' => $title->getFullText() );
                $params['comment'] = array( User::newFromName('Admin'), 
'metawiki', 'http://meta.wikimedia.org/w/index.php?title=Spamlist&oldid=5' );
                $job = new MassMessageJob( $title, $params );
                $job->run();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3ecb22001b4f9bc8d9b891cd096061da5151505
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MZMcBride <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to