jenkins-bot has submitted this change and it was merged.
Change subject: Use GatewayType hints for everything in extras
......................................................................
Use GatewayType hints for everything in extras
Add functions to GatewayType interface as needed, move PHPDoc
comments there from abstract adapter class.
Also declare two implicitly defined fields.
Change-Id: I71461f9cd979252702fb679954833d9087095efd
---
M extras/banner_history/BannerHistoryLogIdProcessor.php
M extras/conversion_log/conversion_log.body.php
M extras/custom_filters/custom_filters.body.php
M extras/custom_filters/filters/functions/functions.body.php
M extras/custom_filters/filters/ip_velocity/ip_velocity.body.php
M extras/custom_filters/filters/minfraud/minfraud.body.php
M extras/custom_filters/filters/referrer/referrer.body.php
M extras/custom_filters/filters/source/source.body.php
M extras/extras.body.php
M extras/session_velocity/session_velocity.body.php
M gateway_common/GatewayType.php
M gateway_common/gateway.adapter.php
12 files changed, 133 insertions(+), 83 deletions(-)
Approvals:
Awight: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extras/banner_history/BannerHistoryLogIdProcessor.php
b/extras/banner_history/BannerHistoryLogIdProcessor.php
index 3761bb5..9f620c9 100644
--- a/extras/banner_history/BannerHistoryLogIdProcessor.php
+++ b/extras/banner_history/BannerHistoryLogIdProcessor.php
@@ -18,7 +18,7 @@
protected $logger;
/**
- * @var GatewayAdapter
+ * @var GatewayType
*/
protected $gatewayAdapter;
@@ -79,7 +79,7 @@
/**
* Handler for the GatewayReady hook. This is the class's entry point.
*
- * @param GatewayAdapter $gatewayAdapter
+ * @param GatewayType $gatewayAdapter
* @param DonationData $donationData
*/
public static function onGatewayReady( $gatewayAdapter ) {
@@ -89,4 +89,4 @@
return true;
}
-}
\ No newline at end of file
+}
diff --git a/extras/conversion_log/conversion_log.body.php
b/extras/conversion_log/conversion_log.body.php
index 2ec09c7..a41fdf8 100644
--- a/extras/conversion_log/conversion_log.body.php
+++ b/extras/conversion_log/conversion_log.body.php
@@ -16,8 +16,9 @@
return true;
}
+ $response = $this->gateway_adapter->getTransactionResponse();
// make sure the response property has been set (signifying a
transaction has been made)
- if ( !$this->gateway_adapter->getTransactionResponse() ) {
+ if ( !$response ) {
return false;
}
@@ -26,13 +27,13 @@
'contribution_tracking_id'
),
"Gateway response: " . addslashes(
-
$this->gateway_adapter->getTransactionMessage()
- ), '"' . addslashes( json_encode(
$this->gateway_adapter->getTransactionData() ) ) . '"'
+ $response->getTxnMessage()
+ ), '"' . addslashes( json_encode( $response->getData()
) ) . '"'
);
return true;
}
- static function onPostProcess( &$gateway_adapter ) {
+ static function onPostProcess( GatewayType &$gateway_adapter ) {
if ( !$gateway_adapter->getGlobal( 'EnableConversionLog' ) ) {
return true;
}
@@ -40,7 +41,7 @@
return self::singleton( $gateway_adapter )->post_process();
}
- static function singleton( &$gateway_adapter ) {
+ static function singleton( GatewayType &$gateway_adapter ) {
if ( !self::$instance ) {
self::$instance = new self( $gateway_adapter );
}
diff --git a/extras/custom_filters/custom_filters.body.php
b/extras/custom_filters/custom_filters.body.php
index c424c9e..6ee5f71 100644
--- a/extras/custom_filters/custom_filters.body.php
+++ b/extras/custom_filters/custom_filters.body.php
@@ -33,7 +33,7 @@
*/
protected $fraud_logger;
- public function __construct( &$gateway_adapter ) {
+ public function __construct( GatewayType &$gateway_adapter ) {
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' );
diff --git a/extras/custom_filters/filters/functions/functions.body.php
b/extras/custom_filters/filters/functions/functions.body.php
index 77f94e3..ba80abd 100644
--- a/extras/custom_filters/filters/functions/functions.body.php
+++ b/extras/custom_filters/filters/functions/functions.body.php
@@ -14,7 +14,7 @@
*/
public $cfo;
- public function __construct( &$gateway_adapter, &$custom_filter_object
) {
+ public function __construct( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
parent::__construct( $gateway_adapter );
$this->cfo = & $custom_filter_object;
}
@@ -47,7 +47,7 @@
return TRUE;
}
- static function onFilter( &$gateway_adapter, &$custom_filter_object ) {
+ static function onFilter( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
if ( !$gateway_adapter->getGlobal( 'EnableFunctionsFilter' ) ||
!count( $gateway_adapter->getGlobal(
'CustomFiltersFunctions' ) ) ){
return true;
@@ -56,7 +56,7 @@
return self::singleton( $gateway_adapter, $custom_filter_object
)->filter();
}
- static function singleton( &$gateway_adapter, &$custom_filter_object ) {
+ static function singleton( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
if ( !self::$instance || $gateway_adapter->isBatchProcessor() )
{
self::$instance = new self( $gateway_adapter,
$custom_filter_object );
}
diff --git a/extras/custom_filters/filters/ip_velocity/ip_velocity.body.php
b/extras/custom_filters/filters/ip_velocity/ip_velocity.body.php
index da59ffa..a65de70 100644
--- a/extras/custom_filters/filters/ip_velocity/ip_velocity.body.php
+++ b/extras/custom_filters/filters/ip_velocity/ip_velocity.body.php
@@ -14,7 +14,13 @@
*/
public $cfo;
- public function __construct( &$gateway_adapter, &$custom_filter_object
= null ) {
+ /**
+ * Memcached instance we use to store and retrieve scores
+ * @var Memcached
+ */
+ protected $cache_obj;
+
+ public function __construct( GatewayType &$gateway_adapter,
&$custom_filter_object = null ) {
parent::__construct( $gateway_adapter );
$this->cfo = & $custom_filter_object;
}
@@ -154,7 +160,7 @@
return self::singleton( $gateway_adapter, $custom_filter_object
)->filter();
}
- static function onPostProcess( &$gateway_adapter ) {
+ static function onPostProcess( GatewayType &$gateway_adapter ) {
if ( !$gateway_adapter->getGlobal( 'EnableIPVelocityFilter' ) ){
return true;
}
@@ -163,7 +169,7 @@
return self::singleton( $gateway_adapter, $dummy
)->postProcess();
}
- static function singleton( &$gateway_adapter, &$custom_filter_object ) {
+ static function singleton( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
if ( !self::$instance || $gateway_adapter->isBatchProcessor() )
{
self::$instance = new self( $gateway_adapter,
$custom_filter_object );
}
@@ -175,7 +181,7 @@
* called outside of the usual filter callbacks so we record nasty
attempts
* even when the filters aren't called.
*/
- public static function penalize( &$gateway ) {
+ public static function penalize( GatewayType &$gateway ) {
$logger = DonationLoggerFactory::getLogger( $gateway );
$logger->info( 'IPVelocityFilter penalizing IP address '
. $gateway->getData_Unstaged_Escaped( 'user_ip' )
diff --git a/extras/custom_filters/filters/minfraud/minfraud.body.php
b/extras/custom_filters/filters/minfraud/minfraud.body.php
index 8fe9d74..f3307a3 100644
--- a/extras/custom_filters/filters/minfraud/minfraud.body.php
+++ b/extras/custom_filters/filters/minfraud/minfraud.body.php
@@ -85,14 +85,20 @@
protected $fraud_logger;
/**
+ * Determines which action to take for a given score
+ * @var array @see $wgDonationInterfaceMinFraudActionRanges
+ */
+ protected $action_ranges;
+
+ /**
* Constructor
*
- * @param GatewayAdapter $gateway_adapter Gateway adapter instance
+ * @param GatewayType $gateway_adapter Gateway adapter instance
* @param Gateway_Extras_CustomFilters $custom_filter_object
Instance of Custom filter object
* @param string $license_key The license key. May
also be set in $wgMinFraudLicenseKey
* @throws RuntimeException
*/
- public function __construct( &$gateway_adapter, &$custom_filter_object,
$license_key = NULL ) {
+ public function __construct( GatewayType &$gateway_adapter,
&$custom_filter_object, $license_key = NULL ) {
parent::__construct( $gateway_adapter );
$this->fraud_logger = DonationLoggerFactory::getLogger(
$gateway_adapter, '_fraud' );
@@ -324,14 +330,14 @@
}
/**
- * Get an instance of Gateway_Extras_CustomFilters_MinFraud
+ * Run the Minfraud filter if it is enabled
*
- * @param GlobalCollectAdapter $gateway_adapter
+ * @param GatewayType $gateway_adapter
* @param Gateway_Extras_CustomFilters $custom_filter_object
*
* @return true
*/
- public static function onFilter( &$gateway_adapter,
&$custom_filter_object ) {
+ public static function onFilter( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
if ( !$gateway_adapter->getGlobal( 'EnableMinfraud' ) ){
return true;
@@ -364,12 +370,12 @@
/**
* Get an instance of Gateway_Extras_CustomFilters_MinFraud
*
- * @param GlobalCollectAdapter $gateway_adapter
+ * @param GatewayType $gateway_adapter
* @param Gateway_Extras_CustomFilters $custom_filter_object
*
* @return Gateway_Extras_CustomFilters_MinFraud
*/
- public static function singleton( &$gateway_adapter,
&$custom_filter_object ) {
+ public static function singleton( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
if ( !self::$instance || $gateway_adapter->isBatchProcessor() )
{
self::$instance = new self( $gateway_adapter,
$custom_filter_object );
}
diff --git a/extras/custom_filters/filters/referrer/referrer.body.php
b/extras/custom_filters/filters/referrer/referrer.body.php
index 8d87499..48f804b 100644
--- a/extras/custom_filters/filters/referrer/referrer.body.php
+++ b/extras/custom_filters/filters/referrer/referrer.body.php
@@ -14,7 +14,7 @@
*/
public $cfo;
- public function __construct( &$gateway_adapter, &$custom_filter_object
) {
+ public function __construct( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
parent::__construct( $gateway_adapter );
$this->cfo = & $custom_filter_object;
}
@@ -47,7 +47,7 @@
return TRUE;
}
- static function onFilter( &$gateway_adapter, &$custom_filter_object ) {
+ static function onFilter( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
if ( !$gateway_adapter->getGlobal( 'EnableReferrerFilter' ) ||
!count( $gateway_adapter->getGlobal(
'CustomFiltersRefRules' ) ) ){
return true;
@@ -56,7 +56,7 @@
return self::singleton( $gateway_adapter, $custom_filter_object
)->filter();
}
- static function singleton( &$gateway_adapter, &$custom_filter_object ) {
+ static function singleton( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
if ( !self::$instance || $gateway_adapter->isBatchProcessor() )
{
self::$instance = new self( $gateway_adapter,
$custom_filter_object );
}
diff --git a/extras/custom_filters/filters/source/source.body.php
b/extras/custom_filters/filters/source/source.body.php
index dccd539..7567e5e 100644
--- a/extras/custom_filters/filters/source/source.body.php
+++ b/extras/custom_filters/filters/source/source.body.php
@@ -14,7 +14,7 @@
*/
public $cfo;
- public function __construct( &$gateway_adapter, &$custom_filter_object
) {
+ public function __construct( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
parent::__construct( $gateway_adapter );
$this->cfo = & $custom_filter_object;
}
@@ -46,7 +46,7 @@
return TRUE;
}
- static function onFilter( &$gateway_adapter, &$custom_filter_object ) {
+ static function onFilter( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
if ( !$gateway_adapter->getGlobal( 'EnableSourceFilter' ) ||
!count( $gateway_adapter->getGlobal(
'CustomFiltersSrcRules' ) ) ){
return true;
@@ -55,7 +55,7 @@
return self::singleton( $gateway_adapter, $custom_filter_object
)->filter();
}
- static function singleton( &$gateway_adapter, &$custom_filter_object ) {
+ static function singleton( GatewayType &$gateway_adapter,
&$custom_filter_object ) {
if ( !self::$instance || $gateway_adapter->isBatchProcessor() )
{
self::$instance = new self( $gateway_adapter,
$custom_filter_object );
}
diff --git a/extras/extras.body.php b/extras/extras.body.php
index 639f051..4ae9f17 100644
--- a/extras/extras.body.php
+++ b/extras/extras.body.php
@@ -7,7 +7,7 @@
abstract class Gateway_Extras {
/**
- * @var GatewayAdapter
+ * @var GatewayType
*/
public $gateway_adapter;
@@ -23,7 +23,7 @@
*/
protected $gateway_logger;
- public function __construct( &$gateway_adapter ) {
+ public function __construct( GatewayType &$gateway_adapter ) {
$this->gateway_adapter = &$gateway_adapter;
$this->transaction_logger = DonationLoggerFactory::getLogger(
$this->gateway_adapter, '_trxn' );
$this->gateway_logger = DonationLoggerFactory::getLogger(
$this->gateway_adapter );
@@ -54,7 +54,7 @@
/**
* Generate a hash of some data
- * @param string the data to hash
+ * @param string $data the data to hash
* @return string The hash of the data
*/
public function generate_hash( $data ) {
diff --git a/extras/session_velocity/session_velocity.body.php
b/extras/session_velocity/session_velocity.body.php
index 29c9124..ca288ad 100644
--- a/extras/session_velocity/session_velocity.body.php
+++ b/extras/session_velocity/session_velocity.body.php
@@ -36,11 +36,11 @@
/**
* @static Construct the singleton instance of this class.
*
- * @param $gateway_adapter
+ * @param GatewayType $gateway_adapter
*
* @return Gateway_Extras_SessionVelocityFilter
*/
- private static function singleton( &$gateway_adapter ) {
+ private static function singleton( GatewayType &$gateway_adapter ) {
if ( !self::$instance || $gateway_adapter->isBatchProcessor() )
{
self::$instance = new self( $gateway_adapter );
}
@@ -50,12 +50,12 @@
/**
* @static Filter hook chain gateway function
*
- * @param $gateway_adapter The adapter context to log under
+ * @param GatewayType $gateway_adapter The adapter context to log under
*
* @return bool Filter chain termination on FALSE. Also indicates that
the cURL transaction
* should not be performed.
*/
- public static function onCurlInit( &$gateway_adapter ) {
+ public static function onCurlInit( GatewayType &$gateway_adapter ) {
if ( !$gateway_adapter->getGlobal(
'EnableSessionVelocityFilter' ) ){
return true;
}
@@ -66,8 +66,6 @@
/**
* Although this function actually does the filtering, as this is a
singleton pattern
* we only want one instance actually using it.
- *
- * @param $gateway_adapter A reference to the current gateway adapter
*
* @return bool Hook return, false stops processing of the hook chain
*/
diff --git a/gateway_common/GatewayType.php b/gateway_common/GatewayType.php
index 93e33dd..0a8679a 100644
--- a/gateway_common/GatewayType.php
+++ b/gateway_common/GatewayType.php
@@ -14,6 +14,12 @@
public static function getGatewayName();
/**
+ * Get a general purpose identifier for this processor, e.g. paypal
+ * @return string
+ */
+ public static function getIdentifier();
+
+ /**
* Get a tag to use to identify this adapter in logs, e.g.
amazon_gateway
* @return string
*/
@@ -242,4 +248,82 @@
*/
public function getPaymentSubmethodMeta( $payment_submethod = null );
+ /**
+ * Add the given amount to our fraud score
+ *
+ * @param float $score
+ */
+ public function addRiskScore( $score );
+
+ /**
+ * Get the current HTTP request
+ *
+ * @return WebRequest
+ */
+ public function getRequest();
+
+ /**
+ * Returns the current validation action.
+ * This will typically get set and altered by the various enabled
process hooks.
+ *
+ * @return string the current process action.
+ */
+ public function getValidationAction();
+
+ /**
+ * Returns the response object with the details of the latest
+ * transaction, or null if the adapter has not yet performed one.
+ *
+ * @return PaymentTransactionResponse|null
+ */
+ public function getTransactionResponse();
+
+ /**
+ * Sets the current validation action. This is meant to be used by the
+ * process hooks, and as such, by default, only worse news than was
already
+ * being stored will be retained for the final result.
+ * @param string $action the value you want to set as the action.
+ * @param bool $reset set to true to do a hard set on the action value.
+ * Otherwise, the status will only change if it fails harder than it
already
+ * was.
+ * @throws UnexpectedValueException
+ */
+ public function setValidationAction( $action, $reset = false );
+
+ /**
+ * Lets the outside world (particularly hooks that accumulate points
scores)
+ * know if we are a batch processor.
+ * @return bool
+ */
+ public function isBatchProcessor();
+
+ /**
+ * Set a value used to determine whether data has changed
+ * @param string $hashval
+ */
+ public function setHash( $hashval );
+
+ /**
+ * Clear the data hash value
+ */
+ public function unsetHash();
+
+ /**
+ * session_ensure
+ * Ensure that we have a session set for the current user.
+ * If we do not have a session set for the current user,
+ * start the session.
+ */
+ public function session_ensure();
+
+ /**
+ * Gets the currently set transaction name. This value should only ever
be
+ * set with setCurrentTransaction: A function that ensures the current
+ * transaction maps to a first-level key that is known to exist in the
+ * $transactions array, defined in the child gateway.
+ * @return string|false The name of the properly set transaction, or
false if none
+ * has been set.
+ */
+ public function getCurrentTransaction();
+
}
diff --git a/gateway_common/gateway.adapter.php
b/gateway_common/gateway.adapter.php
index 47bd36b..e57cc4f 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -281,10 +281,6 @@
return $this->context;
}
- /**
- * Get the current HTTP request
- * @return WebRequest
- */
public function getRequest() {
return $this->request;
}
@@ -1107,14 +1103,6 @@
}
- /**
- * Gets the currently set transaction name. This value should only ever
be
- * set with setCurrentTransaction: A function that ensures the current
- * transaction maps to a first-level key that is known to exist in the
- * $transactions array, defined in the child gateway.
- * @return mixed The name of the properly set transaction, or false if
none
- * has been set.
- */
public function getCurrentTransaction() {
if ( is_null( $this->current_transaction ) ) {
return false;
@@ -1884,10 +1872,6 @@
return $queryparams;
}
- /**
- * Public accessor to the $transaction_response variable
- * @return PaymentTransactionResponse
- */
public function getTransactionResponse() {
return $this->transaction_response;
}
@@ -2319,23 +2303,10 @@
}
}
- /**
- * Allows us to send an initial fraud score offset with api calls
- */
public function addRiskScore( $score ) {
$this->risk_score += $score;
}
- /**
- * Sets the current validation action. This is meant to be used by the
- * process hooks, and as such, by default, only worse news than was
already
- * being stored will be retained for the final result.
- * @param string $action the value you want to set as the action.
- * @param bool $reset set to true to do a hard set on the action value.
- * Otherwise, the status will only change if it fails harder than it
already
- * was.
- * @throws UnexpectedValueException
- */
public function setValidationAction( $action, $reset = false ) {
//our choices are:
$actions = array(
@@ -2358,11 +2329,6 @@
}
}
- /**
- * Returns the current validation action.
- * This will typically get set and altered by the various enabled
process hooks.
- * @return string the current process action.
- */
public function getValidationAction() {
if ( !isset( $this->action ) ) {
$this->action = 'process';
@@ -2370,11 +2336,6 @@
return $this->action;
}
- /**
- * Lets the outside world (particularly hooks that accumulate points
scores)
- * know if we are a batch processor.
- * @return type
- */
public function isBatchProcessor() {
return $this->batch;
}
@@ -2780,12 +2741,6 @@
return $this->account_config[ 'MerchantID' ];
}
- /**
- * session_ensure
- * Ensure that we have a session set for the current user.
- * If we do not have a session set for the current user,
- * start the session.
- */
public function session_ensure() {
WmfFramework::setupSession();
}
--
To view, visit https://gerrit.wikimedia.org/r/277676
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I71461f9cd979252702fb679954833d9087095efd
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: AndyRussG <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Cdentinger <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: XenoRyet <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits