Legoktm has submitted this change and it was merged.
Change subject: If the spamlist is a redirect, follow it. If it's an interwiki
redirect, throw an error.
......................................................................
If the spamlist is a redirect, follow it. If it's an interwiki redirect, throw
an error.
Change-Id: Iee96ccd1598ce7202b6467cd2e8e66d86dd44985
---
M MassMessage.body.php
M SpecialMassMessage.php
2 files changed, 29 insertions(+), 1 deletion(-)
Approvals:
Yuvipanda: Looks good to me, approved
Legoktm: Verified; Looks good to me, approved
diff --git a/MassMessage.body.php b/MassMessage.body.php
index be3404e..22ad33e 100644
--- a/MassMessage.body.php
+++ b/MassMessage.body.php
@@ -13,6 +13,26 @@
class MassMessage {
+ /*
+ * Function to follow redirects
+ *
+ * @param $title Title
+ * @return Title|null null if the page is an interwiki redirect
+ */
+ public static function followRedirect( $title ) {
+ if ( !$title->isRedirect() ) {
+ return $title;
+ }
+ $wikipage = WikiPage::factory( $title );
+
+ $target = $wikipage->followRedirect();
+ if ( $target instanceof Title ) {
+ return $target;
+ } else {
+ return null; // Interwiki redirect
+ }
+ }
+
/*
* Sets up the messenger account for our use if it hasn't been already.
diff --git a/SpecialMassMessage.php b/SpecialMassMessage.php
index 513921a..f25f7b9 100644
--- a/SpecialMassMessage.php
+++ b/SpecialMassMessage.php
@@ -138,10 +138,18 @@
$global = isset( $data['global'] ) && $data['global']; // If
the message delivery is global
$status = new Status();
$errors = array();
- if ( $spamlist === null || $spamlist->getArticleID() == 0 ) {
+ if ( $spamlist === null || !$spamlist->exists() ) {
$status->fatal( 'massmessage-spamlist-doesnotexist' );
}
+ // Follow a redirect if possible
+ $target = MassMessage::followRedirect( $spamlist );
+ if ( $target === null || !$target->exists() ) {
+ $status->fatal( 'massmessage-spamlist-doesnotexist' );
// Interwiki redirect or non-existent page.
+ } else {
+ $spamlist = $target;
+ }
+
// Check that our account hasn't been blocked.
$user = MassMessage::getMessengerUser();
if ( !$global && $user->isBlocked() ) {
--
To view, visit https://gerrit.wikimedia.org/r/75073
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iee96ccd1598ce7202b6467cd2e8e66d86dd44985
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/MassMessage
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MZMcBride <[email protected]>
Gerrit-Reviewer: Yuvipanda <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits