r100644 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100643‎ | r100644 | r100645 >
Date:20:28, 24 October 2011
Author:khorn
Status:ok (Comments)
Tags:fundraising 
Comment:
Moves the language defaulting process to DonationData's normalizeAndSanitize function: Now, if nothing is sent explicitly in the forms, it will pull the code from the current global language object, on construct.
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php
@@ -211,10 +211,16 @@
212212 $this->setNormalizedOrderIDs();
213213 $this->setGateway();
214214 $this->setNormalizedOptOuts();
 215+ $this->setLanguage();
215216 array_walk( $this->normalized, array( $this, 'sanitizeInput' ) );
216217 }
217218 }
218219
 220+ /**
 221+ * normalizeAndSanitize helper function
 222+ * Takes all possible sources for the intended donation amount, and
 223+ * normalizes them into the 'amount' field.
 224+ */
219225 function setNormalizedAmount() {
220226 if ( !($this->isSomething( 'amount' )) || !(preg_match( '/^\d+(\.(\d+)?)?$/', $this->getVal( 'amount' ) ) ) ) {
221227 if ( $this->isSomething( 'amountGiven' ) && preg_match( '/^\d+(\.(\d+)?)?$/', $this->getVal( 'amountGiven' ) ) ) {
@@ -234,6 +240,12 @@
235241 }
236242 }
237243
 244+ /**
 245+ * normalizeAndSanitize helper function
 246+ * Ensures that order_id and i_order_id are ready to go, depending on what
 247+ * comes in populated or not, and where it came from.
 248+ * @return null
 249+ */
238250 function setNormalizedOrderIDs() {
239251 //basically, we need a new order_id every time we come through here, but if there's an internal already there,
240252 //we want to use that one internally. So.
@@ -301,11 +313,28 @@
302314 }
303315 }
304316
 317+ /**
 318+ * normalizeAndSanitize helper function.
 319+ * Sets the gateway to be the gateway that called this class in the first
 320+ * place.
 321+ */
305322 function setGateway() {
306323 //TODO: Hum. If we have some other gateway in the form data, should we go crazy here? (Probably)
307324 $gateway = $this->gatewayID;
308325 $this->setVal( 'gateway', $gateway );
309326 }
 327+
 328+ /**
 329+ * normalizeAndSanitize helper function
 330+ * If the language has not yet been set, pulls the language code
 331+ * from the current global language object.
 332+ */
 333+ function setLanguage() {
 334+ global $wgLang;
 335+ if ( !$this->isSomething( 'language' ) ) {
 336+ $this->setVal( 'language', $wgLang->getCode() );
 337+ }
 338+ }
310339
311340 function doCacheStuff() {
312341 //TODO: Wow, name.
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -1055,7 +1055,7 @@
10561056 'response' => $this->getTransactionMessage(),
10571057 'date' => time(),
10581058 'gateway_txn_id' => $this->getTransactionGatewayTxnID(),
1059 - 'language' => '',
 1059+ //'language' => '',
10601060 );
10611061 $transaction += $this->getData();
10621062

Follow-up revisions

RevisionCommit summaryAuthorDate
r102732MFT r100644, r100785, r101785, r102120, r102318, r102332, r102341, r102342, r...awjrichards01:31, 11 November 2011

Comments

#Comment by Awjrichards (talk | contribs)   21:13, 24 October 2011

It looks like we still honor language= or uselang= from the query string, which is good - we only want to fall back on $wgLang->getCode() if we're otherwise clueless. Unless I'm mistaken about that, this looks fine!

Status & tagging log