Ejegg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/289804

Change subject: Persist risk score array in session
......................................................................

Persist risk score array in session

Allows combining scores from different custom filters that fire
on different requests.  For each custom filter, the latest score
is the one that contributes to the total.

Change-Id: Ie628b22d37dc602edf199c0750b4ce4f606899d3
---
M extras/custom_filters/custom_filters.body.php
M gateway_common/gateway.adapter.php
2 files changed, 6 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/04/289804/1

diff --git a/extras/custom_filters/custom_filters.body.php 
b/extras/custom_filters/custom_filters.body.php
index c584d61..e8ff1a1 100644
--- a/extras/custom_filters/custom_filters.body.php
+++ b/extras/custom_filters/custom_filters.body.php
@@ -31,6 +31,10 @@
                parent::__construct( $gateway_adapter ); //gateway_adapter is 
set in there. 
                // load user action ranges and risk score               
                $this->action_ranges = $this->gateway_adapter->getGlobal( 
'CustomFiltersActionRanges' );
+               $this->risk_score = 
$this->gateway_adapter->getRequest()->getSessionData( 'risk_scores' );
+               if ( !$this->risk_score ) {
+                       $this->risk_score = array();
+               }
                $this->risk_score['initial'] = 
$this->gateway_adapter->getGlobal( 'CustomFiltersRiskScore' );
        }
 
@@ -71,6 +75,7 @@
                $log_message = "\"$source added a score of $score\"";
                $this->fraud_logger->info( '"addRiskScore" ' . $log_message );
                $this->risk_score[$source] = $score;
+               $this->gateway_adapter->getRequest()->setSessionData( 
'risk_scores', $this->risk_score );
        }
        
 
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 9c431de..744ad04 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -2904,6 +2904,7 @@
                                'numAttempt',
                                'order_status', //for post-payment activities
                                'sequence',
+                               'risk_score',
                        );
                        $preservedData = array();
                        $msg = '';

-- 
To view, visit https://gerrit.wikimedia.org/r/289804
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie628b22d37dc602edf199c0750b4ce4f606899d3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <eeggles...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to