Ejegg has uploaded a new change for review.

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

Change subject: Remove deprecated parameters
......................................................................

Remove deprecated parameters

Bug: T130939
Change-Id: I0b704e8020dbefc0993ecdbcd0b5c602043cd737
---
M gateway_common/DonationData.php
M gateway_common/gateway.adapter.php
M special/GatewayFormChooser.php
3 files changed, 13 insertions(+), 57 deletions(-)


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

diff --git a/gateway_common/DonationData.php b/gateway_common/DonationData.php
index da1160b..b426952 100644
--- a/gateway_common/DonationData.php
+++ b/gateway_common/DonationData.php
@@ -91,8 +91,6 @@
                                'currency_code',
                                'payment_method',
                                'payment_submethod',
-                               'paymentmethod', //used by the FormChooser (and 
the newest banners) for some reason.
-                               'submethod', //same as above. Ideally, the 
newer banners would stop using these vars and go back to the old ones...
                                'issuer_id',
                                'order_id',
                                'subscr_id',
@@ -596,39 +594,10 @@
                // payment_method and payment_submethod are currently preferred 
within DonationInterface
                if ( $this->isSomething( 'payment_method' ) ) {
                        $method = $this->getVal( 'payment_method' );
-
-                       //but they can come in a little funny.
-                       $exploded = explode( '.', $method );
-                       if ( count( $exploded ) > 1 ) {
-                               $method = $exploded[0];
-                               $submethod = $exploded[1];
-                       }
                }
 
                if ( $this->isSomething( 'payment_submethod' ) ) {
-                       if ( $submethod != '' ) {
-                               //squak a little if they don't match, and pick 
one.
-                               if ( $submethod != $this->getVal( 
'payment_submethod' ) ) {
-                                       $message = "Submethod normalization 
conflict!: ";
-                                       $message .= 'payment_submethod = ' . 
$this->getVal( 'payment_submethod' );
-                                       $message .= ", and exploded 
payment_method = '$submethod'. Going with the first option.";
-                                       $this->logger->debug( $message );
-                               }
-                       }
                        $submethod = $this->getVal( 'payment_submethod' );
-               }
-
-               if ( $this->isSomething( 'paymentmethod' ) ) { //gross. Why did 
we do this?
-                       //...okay. So, if we have this value, we've likely just 
come in from the form chooser,
-                       //which has just used *this* value to choose a form 
with.
-                       //so, go ahead and prefer this version, and then 
immediately nuke it.
-                       $method = $this->getVal( 'paymentmethod' );
-                       $this->expunge( 'paymentmethod' );
-               }
-
-               if ( $this->isSomething( 'submethod' ) ) { //same deal
-                       $submethod = $this->getVal( 'submethod' );
-                       $this->expunge( 'submethod' );
                }
 
                $this->setVal( 'payment_method', $method );
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index ecef421..8871b24 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -2866,13 +2866,7 @@
                // Now compare session with current request parameters
                // Reset submethod when method changes to avoid form mismatch 
errors
                if ( !empty( $oldData['payment_method'] ) && !empty( 
$oldData['payment_submethod'] ) ) {
-                       // Cut down version of the normalization from 
DonationData
-                       $newMethod = null;
-                       foreach( array( 'payment_method', 'paymentmethod' ) as 
$key ) {
-                               if ( $this->request->getVal( $key ) ) {
-                                       $newMethod = $this->request->getVal( 
$key );
-                               }
-                       }
+                       $newMethod = $this->request->getVal( 'payment_method' );
                        if ( $newMethod ) {
                                $parts = explode( '.', $newMethod );
                                $newMethod = $parts[0];
diff --git a/special/GatewayFormChooser.php b/special/GatewayFormChooser.php
index 5512412..0834c9f 100644
--- a/special/GatewayFormChooser.php
+++ b/special/GatewayFormChooser.php
@@ -38,27 +38,20 @@
                }
 
                $request = $this->getRequest();
-               // Check multiple query string parameters, return the value of 
the
-               // first we find, or null if none have a value.
-               $getValForParams = function( $params ) use ( $request ) {
-                       $params = ( array ) $params;
-                       $val = null;
-                       do {
-                               $val = $request->getVal( array_shift( $params 
), null );
-                               if ( $val === '' ) {
-                                       $val = null;
-                               }
-                       } while ( $val === null && !empty( $params ) );
+               // Get a query string parameter or null if blank
+               $getValOrNull = function( $paramName ) use ( $request ) {
+                       $val = $request->getVal( $paramName, null );
+                       if ( $val === '' ) {
+                               $val = null;
+                       }
                        return $val;
                };
 
-               $country = $getValForParams( 'country' );
-               // Many banner links use non-standard names for the next three
-               // parameters. Prefer the standard names, but allow the old 
ones.
-               $currency = $getValForParams( array( 'currency_code', 
'currency' ) );
-               $paymentMethod = $getValForParams( array( 'payment_method', 
'paymentmethod' ) );
-               $paymentSubMethod = $getValForParams( array( 
'payment_submethod', 'submethod' ) );
-               $gateway = $getValForParams( 'gateway' );
+               $country = $getValOrNull( 'country' );
+               $currency = $getValOrNull( 'currency_code' );
+               $paymentMethod = $getValOrNull( 'payment_method' );
+               $paymentSubMethod = $getValOrNull( 'payment_submethod' );
+               $gateway = $getValOrNull( 'gateway' );
                $recurring = $this->getRequest()->getVal( 'recurring', false );
 
                // FIXME: This is clearly going to go away before we deploy 
this bizniss.
@@ -90,7 +83,7 @@
 
                // Pass any other params that are set. We do not skip ffname or 
form_name because
                // we wish to retain the query string override.
-               $excludeKeys = array( 'paymentmethod', 'submethod', 'title', 
'recurring' );
+               $excludeKeys = array( 'title', 'recurring' );
                foreach ( $this->getRequest()->getValues() as $key => $value ) {
                        // Skip the required variables
                        if ( !in_array( $key, $excludeKeys ) ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b704e8020dbefc0993ecdbcd0b5c602043cd737
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to