jenkins-bot has submitted this change and it was merged.
Change subject: Various DB query cleanups - Critical update
......................................................................
Various DB query cleanups - Critical update
* Fixed timestamp escaping in handleFailingRecipient() and
processBounceHeaders()
* Use selectRowCount() to avoid scanning more rows than needed
* Only do the query in handleFailingRecipient() if there is a bouncer trigger
threshold
* Fixed the Unsubscribe action
* Made BounceHandler use MW Timestamp instead of unix timestamps
Bug: 73083
Change-Id: I103e97621b1b84faf5105d30453cc71f536d227b
---
M includes/BounceHandlerActions.php
M includes/ProcessBounceEmails.php
2 files changed, 22 insertions(+), 20 deletions(-)
Approvals:
Aaron Schulz: Looks good to me, but someone else must approve
01tonythomas: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/BounceHandlerActions.php
b/includes/BounceHandlerActions.php
index f4cd92c..34234e9 100644
--- a/includes/BounceHandlerActions.php
+++ b/includes/BounceHandlerActions.php
@@ -44,23 +44,25 @@
* @return bool
*/
public function handleFailingRecipient( array $failedUser ) {
- $originalEmail = $failedUser['rawEmail'];
- $currentTime = wfTimestamp();
- $bounceValidPeriod = wfTimestamp( $currentTime -
$this->bounceRecordPeriod );
- $dbr = ProcessBounceEmails::getBounceRecordDB( DB_SLAVE,
$this->wikiId );
- $res = $dbr->selectRow( 'bounce_records',
- array( 'total_count' => 'COUNT(*)' ),
- array(
- 'br_user_email' => $originalEmail,
- 'br_timestamp >= ' . $dbr->addQuotes(
wfTimestamp( $bounceValidPeriod ) )
- ),
- __METHOD__
- );
+ if ( $this->bounceHandlerUnconfirmUsers ) {
+ $originalEmail = $failedUser['rawEmail'];
+ $bounceValidPeriod = time() -
$this->bounceRecordPeriod; // Unix
- if( $res !== false && ( $res->total_count >=
$this->bounceRecordLimit ) && $this->bounceHandlerUnconfirmUsers ) {
- $this->unSubscribeUser( $failedUser );
- } else {
- wfDebugLog( 'BounceHandler',"Error fetching the count
of past bounces for user $originalEmail" );
+ $dbr = ProcessBounceEmails::getBounceRecordDB(
DB_SLAVE, $this->wikiId );
+
+ $totalBounces = $dbr->selectRowCount( 'bounce_records',
+ array( '*' ),
+ array(
+ 'br_user_email' => $originalEmail,
+ 'br_timestamp >= ' . $dbr->addQuotes(
$dbr->timestamp( $bounceValidPeriod ) )
+ ),
+ __METHOD__,
+ array( 'LIMIT' => $this->bounceRecordLimit )
+ );
+
+ if ( $totalBounces >= $this->bounceRecordLimit ) {
+ $this->unSubscribeUser( $failedUser );
+ }
}
return true;
diff --git a/includes/ProcessBounceEmails.php b/includes/ProcessBounceEmails.php
index daa58d3..3538466 100644
--- a/includes/ProcessBounceEmails.php
+++ b/includes/ProcessBounceEmails.php
@@ -60,13 +60,13 @@
$rowData = array(
'br_user_email' => $originalEmail,
- 'br_timestamp' => $bounceTimestamp,
+ 'br_timestamp' => $dbw->timestamp(
$bounceTimestamp ),
'br_reason' => $subject
);
$dbw->insert( 'bounce_records', $rowData, __METHOD__ );
- $takeBounceActions = new BounceHandlerActions( $wikiId,
$wgBounceRecordPeriod, $wgBounceRecordLimit,
- $wgBounceHandlerUnconfirmUsers );
+ $takeBounceActions = new BounceHandlerActions( $wikiId,
+ $wgBounceRecordPeriod, $wgBounceRecordLimit,
$wgBounceHandlerUnconfirmUsers );
$takeBounceActions->handleFailingRecipient( $failedUser
);
return true;
} else {
@@ -98,7 +98,7 @@
$failedUser['rawUserId'] = base_convert(
$hashedVERPPart[2], 36, 10 );
$failedEmail = self::getOriginalEmail( $failedUser );
$failedUser['rawEmail'] = $failedEmail ? : null;
- $failedUser['bounceTime'] = $bounceTime;
+ $failedUser['bounceTime'] = wfTimestamp( TS_MW,
$bounceTime );
} else {
wfDebugLog( 'BounceHandler',
"Error: Hash validation failed. Expected hash
of $hashedData, got $hashedVERPPart[3]."
--
To view, visit https://gerrit.wikimedia.org/r/171457
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I103e97621b1b84faf5105d30453cc71f536d227b
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/BounceHandler
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: 01tonythomas <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Jgreen <[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