jenkins-bot has submitted this change and it was merged.
Change subject: Log the entire bounce email too before invalidating email
......................................................................
Log the entire bounce email too before invalidating email
Bug: T99767
Change-Id: I3f4fbcc61b50bcb4f41f09849af1326d9fa76b1d
---
M includes/BounceHandlerActions.php
M includes/ProcessBounceEmails.php
M includes/ProcessBounceWithRegex.php
M tests/UnSubscribeUserTest.php
4 files changed, 28 insertions(+), 14 deletions(-)
Approvals:
Reedy: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/BounceHandlerActions.php
b/includes/BounceHandlerActions.php
index defa56e..c90498b 100644
--- a/includes/BounceHandlerActions.php
+++ b/includes/BounceHandlerActions.php
@@ -32,13 +32,20 @@
protected $bounceHandlerUnconfirmUsers;
/**
+ * @var string
+ */
+ protected $emailRaw;
+
+ /**
* @param string $wikiId The database id of the failing recipient
* @param int $bounceRecordPeriod Time period for which bounce
activities are considered before un-subscribing
* @param int $bounceRecordLimit The number of bounce allowed in the
bounceRecordPeriod.
* @param bool $bounceHandlerUnconfirmUsers Enable/Disable user
un-subscribe action
+ * @param string $emailRaw The raw bounce Email
* @throws Exception
*/
- public function __construct( $wikiId, $bounceRecordPeriod,
$bounceRecordLimit, $bounceHandlerUnconfirmUsers ) {
+ public function __construct( $wikiId, $bounceRecordPeriod,
$bounceRecordLimit, $bounceHandlerUnconfirmUsers, $emailRaw
+ ) {
if ( $wikiId !== wfWikiID() ) {
// We want to use the User class methods, which make no
sense on the wrong wiki
throw new Exception( "BounceHandlerActions constructed
for a foreign wiki." );
@@ -48,6 +55,7 @@
$this->bounceRecordPeriod = $bounceRecordPeriod;
$this->bounceRecordLimit = $bounceRecordLimit;
$this->bounceHandlerUnconfirmUsers =
$bounceHandlerUnconfirmUsers;
+ $this->emailRaw = $emailRaw;
}
/**
@@ -141,8 +149,8 @@
$caUser->saveSettings();
$this->notifyGlobalUser( $bounceUserId,
$originalEmail );
wfDebugLog( 'BounceHandler',
- "Un-subscribed global user
$originalEmail for exceeding Bounce Limit
$this->bounceRecordLimit.\nHeaders:\n" .
- $this->formatHeaders(
$emailHeaders )
+ "Un-subscribed global user
$originalEmail for exceeding Bounce Limit $this->bounceRecordLimit.\nProcessed
Headers:\n" .
+ $this->formatHeaders(
$emailHeaders ) . "\nBounced Email: \n$this->emailRaw"
);
RequestContext::getMain()->getStats()->increment( 'bouncehandler.unsub.global'
);
}
@@ -152,8 +160,8 @@
$user->saveSettings();
$this->createEchoNotification( $bounceUserId,
$originalEmail );
wfDebugLog( 'BounceHandler',
- "Un-subscribed $originalEmail for exceeding
Bounce limit $this->bounceRecordLimit.\nHeaders:\n" .
- $this->formatHeaders( $emailHeaders )
+ "Un-subscribed $originalEmail for exceeding
Bounce limit $this->bounceRecordLimit.\nProcessed Headers:\n" .
+ $this->formatHeaders( $emailHeaders ).
"\nBounced Email: \n$this->emailRaw"
);
RequestContext::getMain()->getStats()->increment(
'bouncehandler.unsub.local' );
}
diff --git a/includes/ProcessBounceEmails.php b/includes/ProcessBounceEmails.php
index 536ba80..1a37e1d 100644
--- a/includes/ProcessBounceEmails.php
+++ b/includes/ProcessBounceEmails.php
@@ -31,13 +31,15 @@
* Process bounce email
*
* @param array $emailHeaders
+ * @param string $emailRaw
+ *
* @return bool
*/
- public function processEmail( $emailHeaders ) {
+ public function processEmail( $emailHeaders, $emailRaw ) {
// The bounceHandler needs to respond only to permanent
failures.
$isPermanentFailure = $this->checkPermanentFailure(
$emailHeaders );
if ( $isPermanentFailure ) {
- return $this->processBounceHeaders( $emailHeaders );
+ return $this->processBounceHeaders( $emailHeaders,
$emailRaw );
}
return false;
@@ -47,9 +49,11 @@
* Process received bounce emails from Job Queue
*
* @param array $emailHeaders
+ * @param string $emailRaw
+ *
* @return bool
*/
- public function processBounceHeaders( $emailHeaders ) {
+ public function processBounceHeaders( $emailHeaders, $emailRaw ) {
global $wgBounceRecordPeriod, $wgBounceRecordLimit,
$wgBounceHandlerUnconfirmUsers, $wgBounceRecordMaxAge;
$to = $emailHeaders['to'];
$subject = $emailHeaders['subject'];
@@ -81,7 +85,8 @@
$wikiId,
$wgBounceRecordPeriod,
$wgBounceRecordLimit,
- $wgBounceHandlerUnconfirmUsers
+ $wgBounceHandlerUnconfirmUsers,
+ $emailRaw
);
$takeBounceActions->handleFailingRecipient(
$failedUser, $emailHeaders );
return true;
diff --git a/includes/ProcessBounceWithRegex.php
b/includes/ProcessBounceWithRegex.php
index 3573864..1f33319 100644
--- a/includes/ProcessBounceWithRegex.php
+++ b/includes/ProcessBounceWithRegex.php
@@ -19,7 +19,7 @@
$emailHeaders = $this->extractHeaders( $email );
$to = $emailHeaders['to'];
- $processEmail = $this->processEmail( $emailHeaders );
+ $processEmail = $this->processEmail( $emailHeaders, $email );
if ( !$processEmail ){
$this->handleUnrecognizedBounces( $email, $to );
}
diff --git a/tests/UnSubscribeUserTest.php b/tests/UnSubscribeUserTest.php
index da89511..da0dc22 100644
--- a/tests/UnSubscribeUserTest.php
+++ b/tests/UnSubscribeUserTest.php
@@ -46,15 +46,16 @@
$encodeVERP = new VerpAddressGenerator( $prefix, $algorithm,
$secretKey, $domain );
$encodedAddress = $encodeVERP->generateVERP( $uid );
+ $emailRaw = "This is a test email for logging purpose only";
$emailHeaders['to'] = $encodedAddress;
$emailHeaders['subject'] = 'Delivery Failed';
$emailHeaders['x-failed-recipients'] = $user->getEmail();
$decodeVERPwithRegex = new ProcessBounceWithRegex();
- $decodeVERPwithRegex->processBounceHeaders( $emailHeaders );
- $decodeVERPwithRegex->processBounceHeaders( $emailHeaders );
- $decodeVERPwithRegex->processBounceHeaders( $emailHeaders );
- $decodeVERPwithRegex->processBounceHeaders( $emailHeaders );
+ $decodeVERPwithRegex->processBounceHeaders( $emailHeaders,
$emailRaw );
+ $decodeVERPwithRegex->processBounceHeaders( $emailHeaders,
$emailRaw );
+ $decodeVERPwithRegex->processBounceHeaders( $emailHeaders,
$emailRaw );
+ $decodeVERPwithRegex->processBounceHeaders( $emailHeaders,
$emailRaw );
$newUser = User::newFromId( $uid );
$this->assertFalse( $newUser->isEmailConfirmed() );
--
To view, visit https://gerrit.wikimedia.org/r/253172
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3f4fbcc61b50bcb4f41f09849af1326d9fa76b1d
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/BounceHandler
Gerrit-Branch: master
Gerrit-Owner: 01tonythomas <[email protected]>
Gerrit-Reviewer: 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