Eileen has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/398777 )
Change subject: Top out risk score at 100 million.
......................................................................
Top out risk score at 100 million.
100 million is effectively 'infinite risk' & the DB breaks somewhere above that
point
Bug: T183102
Change-Id: I5529ff86abf082c41b9c5d075bdc9c164f762872
---
M sites/all/modules/queue2civicrm/fredge/wmf_fredge_qc.module
M sites/all/modules/queue2civicrm/tests/phpunit/AntifraudQueueTest.php
2 files changed, 29 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/wikimedia/fundraising/crm
refs/changes/77/398777/1
diff --git a/sites/all/modules/queue2civicrm/fredge/wmf_fredge_qc.module
b/sites/all/modules/queue2civicrm/fredge/wmf_fredge_qc.module
index 4dd223d..79f697a 100644
--- a/sites/all/modules/queue2civicrm/fredge/wmf_fredge_qc.module
+++ b/sites/all/modules/queue2civicrm/fredge/wmf_fredge_qc.module
@@ -136,6 +136,12 @@
if (array_key_exists('mysql_type', $definition) &&
$definition['mysql_type'] === 'DATETIME') {
$msg[$field] = wmf_common_date_unix_to_sql($msg[$field]);
}
+ if (stristr($msg['risk_score'], 'E')) {
+ // e.g. 3.5848273556811E+38 breaks the db - use 100 mill as
'infinitely dubious'
+ if ($msg['risk_score'] > 100000000) {
+ $msg['risk_score'] = 100000000;
+ }
+ }
$data[$field] = $msg[$field];
}
}
diff --git
a/sites/all/modules/queue2civicrm/tests/phpunit/AntifraudQueueTest.php
b/sites/all/modules/queue2civicrm/tests/phpunit/AntifraudQueueTest.php
index ea63274..feffc91 100644
--- a/sites/all/modules/queue2civicrm/tests/phpunit/AntifraudQueueTest.php
+++ b/sites/all/modules/queue2civicrm/tests/phpunit/AntifraudQueueTest.php
@@ -32,7 +32,29 @@
$this->compareMessageWithDb( $message,
$message['score_breakdown'] );
}
- /**
+ /**
+ * If the risk score is more than 100 million it should be set to 100 mil.
+ *
+ * This is effectively 'infinite risk' and our db can't cope with
+ * real value! '3.5848273556811E+38'
+ */
+ public function testFraudMessageWithOutOfRangeScore() {
+ $message = json_decode(
+ file_get_contents(__DIR__ . '/../data/payments-antifraud-high.json'),
+ TRUE
+ );
+ $ctId = mt_rand();
+ $oId = $ctId . '.0';
+ $message['contribution_tracking_id'] = $ctId;
+ $message['order_id'] = $oId;
+ $this->consumer->processMessage($message);
+
+ $message['risk_score'] = 100000000;
+
+ $this->compareMessageWithDb($message, $message['score_breakdown']);
+ }
+
+ /**
* The first message for a ct_id / order_id pair needs to be complete
*
* @expectedException FredgeDataValidationException
--
To view, visit https://gerrit.wikimedia.org/r/398777
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5529ff86abf082c41b9c5d075bdc9c164f762872
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm
Gerrit-Branch: master
Gerrit-Owner: Eileen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits