jenkins-bot has submitted this change and it was merged. Change subject: Removed WMF configs from BounceHandler extension ......................................................................
Removed WMF configs from BounceHandler extension * Used $wgExtensionFunctions[] to load in values for extension globals * Made $wgUnrecognizedBounceNotify point to $wgNoReplyAddress Bug: 73043 Change-Id: I17050d5995a82bce89d79bbf3bfc06dc6c37e981 --- M BounceHandler.php M BounceHandlerHooks.php M includes/VerpAddressGenerator.php M tests/ApiBounceHandlerTest.php M tests/UnSubscribeUserTest.php M tests/VERPEncodeDecodeTest.php 6 files changed, 15 insertions(+), 23 deletions(-) Approvals: Hoo man: Looks good to me, but someone else must approve 01tonythomas: Looks good to me, approved jenkins-bot: Verified diff --git a/BounceHandler.php b/BounceHandler.php index 308cdf3..187f73e 100644 --- a/BounceHandler.php +++ b/BounceHandler.php @@ -57,10 +57,11 @@ * wgBounceHandlerUnconfirmUsers - Toggle the user un-subscribe action */ $wgVERPprefix = 'wiki'; -$wgVERPdomainPart = null; //set this only if you want the domain part of your email different from your wgServerName $wgVERPalgorithm = 'md5'; $wgVERPsecret = 'MediawikiVERP'; $wgBounceHandlerUnconfirmUsers = false; +$wgUnrecognizedBounceNotify = null; +$wgVERPdomainPart = null; // set this only if you want the domain part of your email different from your wgServerName $wgVERPAcceptTime = 259200; //3 days time $wgBounceRecordPeriod = 604800; // 60 * 60 * 24 * 7 - 7 days bounce activity are considered before un-subscribing $wgBounceRecordLimit = 10; // If there are more than 10 bounces in the $wgBounceRecordPeriod, the user is un-subscribed @@ -69,7 +70,11 @@ $wgBounceHandlerInternalIPs = array( '127.0.0.1', '::1' ); /* Admin email address which should be notified in the case of an unprocessed valid bounce */ -$wgUnrecognizedBounceNotify = array( '[email protected]' ); +$wgExtensionFunctions[] = function() { + global $wgNoReplyAddress, $wgServerName, $wgUnrecognizedBounceNotify, $wgVERPdomainPart; + $wgUnrecognizedBounceNotify = $wgUnrecognizedBounceNotify ? : array( $wgNoReplyAddress ); + $wgVERPdomainPart = $wgVERPdomainPart ? : $wgServerName; +}; # Alternative DB cluster to use for the bounce tables $wgBounceHandlerCluster = false; diff --git a/BounceHandlerHooks.php b/BounceHandlerHooks.php index 8139481..75edb7c 100644 --- a/BounceHandlerHooks.php +++ b/BounceHandlerHooks.php @@ -29,7 +29,7 @@ * @return bool true */ protected static function generateVerp( MailAddress $to, &$returnPath ) { - global $wgVERPprefix, $wgVERPalgorithm, $wgVERPsecret, $wgVERPdomainPart, $wgServerName; + global $wgVERPprefix, $wgVERPalgorithm, $wgVERPsecret, $wgVERPdomainPart; $user = User::newFromName( $to->name ); if ( !$user ) { return true; @@ -41,7 +41,7 @@ return true; } $verpAddress = new VerpAddressGenerator( $wgVERPprefix, - $wgVERPalgorithm, $wgVERPsecret, $wgVERPdomainPart, $wgServerName ); + $wgVERPalgorithm, $wgVERPsecret, $wgVERPdomainPart ); $returnPath = $verpAddress->generateVERP( $uid ); return true; diff --git a/includes/VerpAddressGenerator.php b/includes/VerpAddressGenerator.php index a7dbd7d..22aef1c 100644 --- a/includes/VerpAddressGenerator.php +++ b/includes/VerpAddressGenerator.php @@ -50,23 +50,16 @@ protected $domain; /** - * @var string - */ - protected $serverName; - - /** * @param string $prefix * @param string $algorithm * @param string $secretKey * @param string $domain - * @param string $serverName */ - public function __construct( $prefix, $algorithm, $secretKey, $domain, $serverName ) { + public function __construct( $prefix, $algorithm, $secretKey, $domain ) { $this->prefix = $prefix; $this->algorithm = $algorithm; $this->secretKey = $secretKey; $this->domain = $domain; - $this->serverName = $serverName; } /** @@ -85,7 +78,7 @@ public function generateVERP( $uid ) { // Get the time in Unix timestamp to compare with seconds $timeNow = wfTimestamp(); - $email_domain = $this->domain ? : $this->serverName; + $email_domain = $this->domain; // Creating the VERP address prefix as wikiId-base36( $UserID )-base36( $Timestamp ) // and the generated VERP return path is of the form : // wikiId-base36( $UserID )-base36( $Timestamp )-hash( $algorithm, $key, $prefix )@$email_domain diff --git a/tests/ApiBounceHandlerTest.php b/tests/ApiBounceHandlerTest.php index 7d1dbe4..94da074 100644 --- a/tests/ApiBounceHandlerTest.php +++ b/tests/ApiBounceHandlerTest.php @@ -37,7 +37,6 @@ $algorithm = 'md5'; $secretKey = 'mySecret'; $domain = 'testwiki.org'; - $serverName = 'testwiki.org'; $bounceRecordPeriod = 604800; $bounceRecordLimit = 3; @@ -47,7 +46,6 @@ 'wgVERPalgorithm' => $algorithm, 'wgVERPsecret' => $secretKey, 'wgVERPdomainPart' => $domain, - 'wgServerName' => $serverName, 'wgBounceHandlerUnconfirmUsers' => true, 'wgBounceRecordPeriod' => $bounceRecordPeriod, 'wgBounceRecordLimit' => $bounceRecordLimit, @@ -55,7 +53,7 @@ ) ); - $encodeVERP = new VerpAddressGenerator( $prefix, $algorithm, $secretKey, $domain, $serverName ); + $encodeVERP = new VerpAddressGenerator( $prefix, $algorithm, $secretKey, $domain ); $encodedAddress = $encodeVERP->generateVERP( $uid ); $replace = array( "{VERP_ADDRESS}" => $encodedAddress ); diff --git a/tests/UnSubscribeUserTest.php b/tests/UnSubscribeUserTest.php index b8d6835..143ecbe 100644 --- a/tests/UnSubscribeUserTest.php +++ b/tests/UnSubscribeUserTest.php @@ -23,7 +23,6 @@ $algorithm = 'md5'; $secretKey = 'mySecret'; $domain = 'testwiki.org'; - $serverName = 'testwiki.org'; $bounceRecordPeriod = 604800; $bounceRecordLimit = 3; @@ -33,7 +32,6 @@ 'wgVERPalgorithm' => $algorithm, 'wgVERPsecret' => $secretKey, 'wgVERPdomainPart' => $domain, - 'wgServerName' => $serverName, 'wgBounceHandlerUnconfirmUsers' => true, 'wgBounceRecordPeriod' => $bounceRecordPeriod, 'wgBounceRecordLimit' => $bounceRecordLimit @@ -42,7 +40,7 @@ $this->setMwGlobals( 'wgVERPAcceptTime', 259200 ); - $encodeVERP = new VerpAddressGenerator( $prefix, $algorithm, $secretKey, $domain, $serverName ); + $encodeVERP = new VerpAddressGenerator( $prefix, $algorithm, $secretKey, $domain ); $encodedAddress = $encodeVERP->generateVERP( $uid ); $emailHeaders['to'] = $encodedAddress; diff --git a/tests/VERPEncodeDecodeTest.php b/tests/VERPEncodeDecodeTest.php index f660ef0..7b07a15 100644 --- a/tests/VERPEncodeDecodeTest.php +++ b/tests/VERPEncodeDecodeTest.php @@ -22,20 +22,18 @@ $algorithm = 'md5'; $secretKey = 'mySecret'; $domain = 'testwiki.org'; - $serverName = 'testwiki.org'; $this->setMwGlobals( array( 'wgVERPprefix' => $prefix, 'wgVERPalgorithm' => $algorithm, 'wgVERPsecret' => $secretKey, - 'wgVERPdomainPart' => $domain, - 'wgServerName' => $serverName + 'wgVERPdomainPart' => $domain ) ); $this->setMwGlobals( 'wgVERPAcceptTime', 259200 ); - $encodeVERP = new VerpAddressGenerator( $prefix, $algorithm, $secretKey, $domain, $serverName ); + $encodeVERP = new VerpAddressGenerator( $prefix, $algorithm, $secretKey, $domain ); $encodedAddress = $encodeVERP->generateVERP( $uid ); $decodeVERPwithRegex = new ProcessBounceWithRegex(); -- To view, visit https://gerrit.wikimedia.org/r/172589 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I17050d5995a82bce89d79bbf3bfc06dc6c37e981 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/BounceHandler Gerrit-Branch: master Gerrit-Owner: 01tonythomas <[email protected]> Gerrit-Reviewer: 01tonythomas <[email protected]> Gerrit-Reviewer: Aaron Schulz <[email protected]> Gerrit-Reviewer: Hoo man <[email protected]> Gerrit-Reviewer: Jgreen <[email protected]> Gerrit-Reviewer: Legoktm <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
