jenkins-bot has submitted this change and it was merged.
Change subject: Only use wfWikiId() when submitting the job
......................................................................
Only use wfWikiId() when submitting the job
Internally it makes more sense to use the actual dbname,
this makes it easier to use wgConf. Since we only need to
use the database prefix once, we should just change it in
that instance rather than having an inconsistent internal
structure (some with prefix, some without).
This reverts commit d688e4862b04ec3ff678dee9de8bd7f446ecbe2a.
Change-Id: I16c37bc1e0034f14ef2611ef769821e1b600676c
---
M MassMessage.body.php
M MassMessage.hooks.php
M SpecialMassMessage.php
M tests/MassMessageTest.php
4 files changed, 17 insertions(+), 8 deletions(-)
Approvals:
Reedy: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MassMessage.body.php b/MassMessage.body.php
index 733761b..c3671c1 100644
--- a/MassMessage.body.php
+++ b/MassMessage.body.php
@@ -116,8 +116,10 @@
* @return array
*/
public static function normalizeTargets( $data ) {
+ global $wgDBname;
$targets = array();
foreach ( $data as $target ) {
+
if ( !isset( $target['dbname'] ) ) {
$dbname = self::getDBName( $target['site'] );
if ( $dbname == null ) {
@@ -127,7 +129,7 @@
$target['dbname'] = $dbname;
}
- if ( $target['dbname'] == wfWikiID() ) {
+ if ( $target['dbname'] == $wgDBname ) {
$title = Title::newFromText( $target['title'] );
if ( $title === null ) {
continue;
diff --git a/MassMessage.hooks.php b/MassMessage.hooks.php
index 8c76dbf..0c0d064 100644
--- a/MassMessage.hooks.php
+++ b/MassMessage.hooks.php
@@ -29,10 +29,10 @@
$data = array( 'site' => $site, 'title' => $page );
if ( trim( $site ) === '' ) {
// Assume it's a local delivery
- global $wgServer;
+ global $wgServer, $wgDBname;
$site = MassMessage::getBaseUrl( $wgServer );
$data['site'] = $site;
- $data['dbname'] = wfWikiID();
+ $data['dbname'] = $wgDBname;
}
// Use a message so wikis can customize the output
$msg = wfMessage( 'massmessage-target' )->params( $site,
$wgScript, $page )->plain();
diff --git a/SpecialMassMessage.php b/SpecialMassMessage.php
index a2e4fe7..5ab6732 100644
--- a/SpecialMassMessage.php
+++ b/SpecialMassMessage.php
@@ -301,7 +301,12 @@
foreach ( $pages as $page ) {
$title = Title::newFromText( $page['title'] );
$job = new MassMessageJob( $title, $data );
- JobQueueGroup::singleton( $page['dbname'] )->push( $job
);
+ if ( $page['dbname'] == $wgDBname ) {
+ $dbname = wfWikiID();
+ } else {
+ $dbname = $page['dbname'];
+ }
+ JobQueueGroup::singleton( $dbname )->push( $job );
$this->count += 1;
}
diff --git a/tests/MassMessageTest.php b/tests/MassMessageTest.php
index b7fd07f..093acb8 100644
--- a/tests/MassMessageTest.php
+++ b/tests/MassMessageTest.php
@@ -2,6 +2,8 @@
/**
* Tests for the MassMessage extension...
+ *
+ * @group Database
*/
class MassMessageTest extends MediaWikiTestCase {
@@ -79,16 +81,16 @@
* @return array
*/
public static function provideGetParserFunctionTargets() {
- global $wgContLang;
+ global $wgDBname, $wgContLang;
$proj = $wgContLang->getFormattedNsText( NS_PROJECT ); //
Output changes based on wikiname
return array(
// project page, no site provided
- array( '{{#target:Project:Example}}', array( 'title' =>
$proj . ':Example', 'dbname' => wfWikiID() ), ),
+ array( '{{#target:Project:Example}}', array( 'title' =>
$proj . ':Example', 'dbname' => $wgDBname ), ),
// user talk page, no site provided
- array( '{{#target:User talk:Example}}', array( 'dbname'
=> wfWikiID(), 'title' => 'User talk:Example' ), ),
+ array( '{{#target:User talk:Example}}', array( 'dbname'
=> $wgDBname, 'title' => 'User talk:Example' ), ),
// local redirect being followed
- array( '{{#target:User talk:Is a redirect}}', array(
'dbname' => wfWikiID(), 'title' => 'User talk:Redirect target' ) ),
+ array( '{{#target:User talk:Is a redirect}}', array(
'dbname' => $wgDBname, 'title' => 'User talk:Redirect target' ) ),
// invalid titles
array( '{{#target:User:<><}}', array(), ),
array( '{{#target:Project:!!!<><><><>', array(), ),
--
To view, visit https://gerrit.wikimedia.org/r/84734
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I16c37bc1e0034f14ef2611ef769821e1b600676c
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[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