r102309 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102308‎ | r102309 | r102310 >
Date:19:22, 7 November 2011
Author:khorn
Status:ok
Tags:fundraising 
Comment:
Changes the way the currency code is pulled from the source data, to prevent confusion over 'currency' and 'currency_code'.
This is an early step in removing 'currency' as a key entirely. After that gets done, it no longer has to be set in setCurrencyCode.
related to r102307
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php
@@ -57,7 +57,9 @@
5858 'card_type' => $wgRequest->getText( 'card_type' ),
5959 'expiration' => $wgRequest->getText( 'mos' ) . substr( $wgRequest->getText( 'year' ), 2, 2 ),
6060 'cvv' => $wgRequest->getText( 'cvv' ),
61 - 'currency' => $wgRequest->getVal( 'currency_code' ),
 61+ //Leave both of these here.
 62+ 'currency' => $wgRequest->getVal( 'currency' ),
 63+ 'currency_code' => $wgRequest->getVal( 'currency_code' ),
6264 'payment_method' => $wgRequest->getText( 'payment_method', 'cc' ),
6365 'payment_submethod' => $wgRequest->getText( 'payment_submethod', null ), // Used by GlobalCollect for payment types
6466 'issuer_id' => $wgRequest->getText( 'issuer_id' ),
@@ -312,12 +314,27 @@
313315 */
314316 function setCurrencyCode() {
315317 global $wgRequest;
316 - if ( !$this->isSomething('currency') ){
317 - $code = $wgRequest->getVal('currency', null);
318 - if (!is_null($code)){
319 - $this->setVal('currency', $code);
320 - }
 318+
 319+ //at this point, we can have either currency, or currency_code.
 320+ //-->>currency_code has the authority!<<--
 321+ $currency = false;
 322+
 323+ if ( $this->isSomething( 'currency_code' ) ) {
 324+ $currency = $this->getVal( 'currency_code' );
 325+ } elseif ( $this->isSomething( 'currency' ) ) {
 326+ $currency = $this->getVal( 'currency' );
321327 }
 328+
 329+ if ( $currency ){
 330+ //set them both.
 331+ $this->setVal( 'currency_code', $currency );
 332+ $this->setVal( 'currency', $currency );
 333+ } else {
 334+ //we want these unset if neither of them was anything, so things
 335+ //using this data know to use their own defaults.
 336+ $this->expunge( 'currency_code' );
 337+ $this->expunge( 'currency' );
 338+ }
322339 }
323340
324341 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r102311MFT r102307, r102308, r102309awjrichards19:28, 7 November 2011
r102318Removes all unnecessary references to 'currency', in favor of referencing 'cu...khorn20:06, 7 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102307using currency_code instead of currency since this is what DonationData is ex...kaldari18:58, 7 November 2011

Status & tagging log