r105938 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105937‎ | r105938 | r105939 >
Date:22:12, 12 December 2011
Author:khorn
Status:deferred
Tags:fundraising 
Comment:
Data handling cleanup in DonationInterface, part 1 of [some].
in GatewayAdapter:
Renamed getData_Raw to getData_Unstaged_Escaped
Renamed the $raw_data member to $unstaged_data

in DonationData:
Created public functions getDataEscaped, getDataUnescaped, and getVal_Escaped
Changed normalizeAndSanitize() so it will only normalize (with a name change to just "normalize") and moved the call to htmlspecialchars to a new public getDataEscaped function. (More visibility there)
Because of the changes in the escaping, getVal now returns the unescaped value, and is protected for internal use only.
Protected many functions intended only to be used by their containing object.

Renamed all references to renamed functions and data members accordingly.
Cleaned up some logging we don't have to do anymore, and added some we do.
Modified paths:
  • /trunk/extensions/DonationInterface/extras/conversion_log/conversion_log.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/extras/minfraud/minfraud.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/extras/recaptcha/recaptcha.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/GatewayForm.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/donation.api.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_forms/Form.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/api_payflowpro_gateway.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/tests/DonationDataTestCase.php (modified) (history)
  • /trunk/extensions/DonationInterface/tests/DonationInterfaceTestCase.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/tests/DonationDataTestCase.php
@@ -94,7 +94,7 @@
9595 */
9696 public function testConstruct(){
9797 $ddObj = new DonationData(''); //as if we were posted.
98 - $returned = $ddObj->getData();
 98+ $returned = $ddObj->getDataEscaped();
9999 $expected = array( 'posted' => '',
100100 'amount' => '0.00',
101101 'email' => '',
@@ -150,7 +150,7 @@
151151 */
152152 public function testConstructAsTest(){
153153 $ddObj = new DonationData('', true); //test mode from the start, no data
154 - $returned = $ddObj->getData();
 154+ $returned = $ddObj->getDataEscaped();
155155 $expected = array(
156156 'amount' => '35',
157157 'email' => 'test@example.com',
@@ -213,7 +213,7 @@
214214
215215 $ddObj = new DonationData('');
216216 $ddObj->populateData(true, $expected); //change to test mode with explicit test data
217 - $returned = $ddObj->getData();
 217+ $returned = $ddObj->getDataEscaped();
218218 //unset these, because they're always new
219219 unset($returned['order_id']);
220220 unset($expected['order_id']);
@@ -251,7 +251,7 @@
252252 $data['amountGiven'] = 42.50;
253253 //unset($data['zip']);
254254 $ddObj = new DonationData('', true, $data);
255 - $returned = $ddObj->getData();
 255+ $returned = $ddObj->getDataEscaped();
256256 $this->assertEquals($returned['amount'], '42.50', "Amount was not properly reset");
257257 $this->assertTrue(!(array_key_exists('amountGiven', $returned)), "amountGiven should have been removed from the data");
258258 }
@@ -265,7 +265,7 @@
266266 $data['amountGiven'] = 42.50;
267267 //unset($data['zip']);
268268 $ddObj = new DonationData('', true, $data);
269 - $returned = $ddObj->getData();
 269+ $returned = $ddObj->getDataEscaped();
270270 $this->assertEquals($returned['amount'], 88.15, "Amount was not properly reset");
271271 $this->assertTrue(!(array_key_exists('amountGiven', $returned)), "amountGiven should have been removed from the data");
272272 }
@@ -279,7 +279,7 @@
280280 $data['amountOther'] = 3.25;
281281 //unset($data['zip']);
282282 $ddObj = new DonationData('', true, $data);
283 - $returned = $ddObj->getData();
 283+ $returned = $ddObj->getDataEscaped();
284284 $this->assertEquals($returned['amount'], 3.25, "Amount was not properly reset");
285285 $this->assertTrue(!(array_key_exists('amountOther', $returned)), "amountOther should have been removed from the data");
286286 }
@@ -294,7 +294,7 @@
295295 $data['amountOther'] = 'macedonia';
296296 //unset($data['zip']);
297297 $ddObj = new DonationData('', true, $data);
298 - $returned = $ddObj->getData();
 298+ $returned = $ddObj->getDataEscaped();
299299 $this->assertEquals($returned['amount'], 0.00, "Amount was not properly reset");
300300 $this->assertTrue(!(array_key_exists('amountOther', $returned)), "amountOther should have been removed from the data");
301301 $this->assertTrue(!(array_key_exists('amountGiven', $returned)), "amountGiven should have been removed from the data");
Index: trunk/extensions/DonationInterface/tests/DonationInterfaceTestCase.php
@@ -274,7 +274,7 @@
275275 */
276276 public function getExpectedXmlRequestForGlobalCollect( $optionsForTestData, $options = array() ) {
277277
278 - $orderId = $this->gatewayAdapter->getData_Raw( 'order_id' );
 278+ $orderId = $this->gatewayAdapter->getData_Unstaged_Escaped( 'order_id' );
279279
280280 $expected = '<?xml version="1.0"?>' . "\n";
281281 $expected .= '<XML>';
Index: trunk/extensions/DonationInterface/payflowpro_gateway/api_payflowpro_gateway.php
@@ -156,7 +156,7 @@
157157 //instantiate a new DonationData that behaves like it's owned by the correct gateway.
158158 $donationDataObj = new DonationData( $gateway_class, false, $tracking_data );
159159 // fetch the order_id
160 - $order_id = $donationDataObj->getVal( 'order_id' );
 160+ $order_id = $donationDataObj->getVal_Escaped( 'order_id' );
161161
162162 // fetch the CSRF prevention token and set it if it's not already set
163163 $token = $donationDataObj->token_getSaltedSessionToken();
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -83,7 +83,7 @@
8484 }
8585 }
8686
87 - $data = $this->adapter->getData_Raw();
 87+ $data = $this->adapter->getData_Unstaged_Escaped();
8888 $msgPrefix = $data['order_id'] . ' ' . $data['i_order_id'] . ' ';
8989
9090 // if approved, display results and send transaction to the queue
Index: trunk/extensions/DonationInterface/extras/custom_filters/custom_filters.body.php
@@ -59,7 +59,7 @@
6060 $this->gateway_adapter->setValidationAction( $localAction );
6161
6262 $log_msg = '"' . $localAction . "\"\t\"" . $this->risk_score . "\"";
63 - $this->log( $this->gateway_adapter->getData_Raw( 'contribution_tracking_id' ), 'Filtered', $log_msg );
 63+ $this->log( $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), 'Filtered', $log_msg );
6464 return TRUE;
6565 }
6666
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/source/source.body.php
@@ -21,7 +21,7 @@
2222
2323 public function filter() {
2424 // pull out the source from the filter object
25 - $source = $this->gateway_adapter->getData_Raw( 'utm_source' );
 25+ $source = $this->gateway_adapter->getData_Unstaged_Escaped( 'utm_source' );
2626
2727 // a very complex filtering algorithm for sources
2828 $srcRules = $this->gateway_adapter->getGlobal( 'CustomFiltersSrcRules' );
@@ -38,7 +38,7 @@
3939 $log_msg .= "\t\"" . addslashes( $regex ) . "\"";
4040 $log_msg .= "\t\"" . $this->cfo->risk_score . "\"";
4141 $this->log(
42 - $this->gateway_adapter->getData_Raw( 'contribution_tracking_id' ), 'Filter: Source', $log_msg
 42+ $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), 'Filter: Source', $log_msg
4343 );
4444 }
4545 }
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php
@@ -17,7 +17,7 @@
1818 return TRUE;
1919 }
2020
21 - $minfraud_query = $this->build_query( $this->gateway_adapter->getData_Raw() );
 21+ $minfraud_query = $this->build_query( $this->gateway_adapter->getData_Unstaged_Escaped() );
2222 $this->query_minfraud( $minfraud_query );
2323
2424
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.body.php
@@ -21,7 +21,7 @@
2222
2323 public function filter() {
2424 // pull out the referrer from the gateway_adapter
25 - $referrer = $this->gateway_adapter->getData_Raw( 'referrer' );
 25+ $referrer = $this->gateway_adapter->getData_Unstaged_Escaped( 'referrer' );
2626
2727 // a very complex filtering algorithm for referrers
2828 $refRules = $this->gateway_adapter->getGlobal( 'CustomFiltersRefRules' );
@@ -38,7 +38,7 @@
3939 $log_msg .= "\t\"" . addslashes( $regex ) . "\"";
4040 $log_msg .= "\t\"" . $this->cfo->risk_score . "\"";
4141 $this->log(
42 - $this->gateway_adapter->getData_Raw( 'contribution_tracking_id' ), 'Filter: Referrer', $log_msg
 42+ $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), 'Filter: Referrer', $log_msg
4343 );
4444 }
4545 }
Index: trunk/extensions/DonationInterface/extras/minfraud/minfraud.body.php
@@ -68,7 +68,7 @@
6969 return TRUE;
7070 }
7171
72 - $minfraud_query = $this->build_query( $this->gateway_adapter->getData_Raw() );
 72+ $minfraud_query = $this->build_query( $this->gateway_adapter->getData_Unstaged_Escaped() );
7373 $this->query_minfraud( $minfraud_query );
7474 $localAction = $this->determine_action( $this->minfraud_response['riskScore'] );
7575 $this->gateway_adapter->setValidationAction( $localAction );
@@ -76,7 +76,7 @@
7777 // reset the data hash
7878 $this->gateway_adapter->unsetHash();
7979 $this->gateway_adapter->setActionHash( $this->generate_hash( $localAction ) );
80 - $this->gateway_adapter->setHash( $this->generate_hash( $this->gateway_adapter->getData_Raw() ) );
 80+ $this->gateway_adapter->setHash( $this->generate_hash( $this->gateway_adapter->getData_Unstaged_Escaped() ) );
8181
8282 // Write the query/response to the log
8383 $this->log_query( $minfraud_query, $localAction );
@@ -88,13 +88,13 @@
8989 */
9090 public function log_query( $minfraud_query, $action ) {
9191 if ( $this->log_fh ) {
92 - $log_message = '"' . addslashes( $this->gateway_adapter->getData_Raw( 'comment' ) ) . '"';
93 - $log_message .= "\t" . '"' . addslashes( $this->gateway_adapter->getData_Raw( 'amount' ) . ' ' . $this->gateway_adapter->getData_Raw( 'currency_code' ) ) . '"';
 92+ $log_message = '"' . addslashes( $this->gateway_adapter->getData_Unstaged_Escaped( 'comment' ) ) . '"';
 93+ $log_message .= "\t" . '"' . addslashes( $this->gateway_adapter->getData_Unstaged_Escaped( 'amount' ) . ' ' . $this->gateway_adapter->getData_Unstaged_Escaped( 'currency_code' ) ) . '"';
9494 $log_message .= "\t" . '"' . addslashes( json_encode( $minfraud_query ) ) . '"';
9595 $log_message .= "\t" . '"' . addslashes( json_encode( $this->minfraud_response ) ) . '"';
9696 $log_message .= "\t" . '"' . addslashes( $action ) . '"';
97 - $log_message .= "\t" . '"' . addslashes( $this->gateway_adapter->getData_Raw( 'referrer' ) ) . '"';
98 - $this->log( $this->gateway_adapter->getData_Raw( 'contribution_tracking_id' ), 'minFraud query', $log_message );
 97+ $log_message .= "\t" . '"' . addslashes( $this->gateway_adapter->getData_Unstaged_Escaped( 'referrer' ) ) . '"';
 98+ $this->log( $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), 'minFraud query', $log_message );
9999 }
100100 }
101101
@@ -111,7 +111,7 @@
112112 */
113113 public function can_bypass_minfraud() {
114114 // if the data bits data_hash and action are not set, we need to hit minFraud
115 - $localdata = $this->gateway_adapter->getData_Raw();
 115+ $localdata = $this->gateway_adapter->getData_Unstaged_Escaped();
116116 if ( !isset($localdata['data_hash']) || !strlen( $localdata['data_hash'] ) || !isset($localdata['action']) || !strlen( $localdata['action'] ) ) {
117117 return FALSE;
118118 }
@@ -123,7 +123,7 @@
124124 // compare the data hash to make sure it's legit
125125 if ( $this->compare_hash( $data_hash, serialize( $localdata ) ) ) {
126126
127 - $this->gateway_adapter->setHash( $this->generate_hash( $this->gateway_adapter->getData_Raw() ) ); // hash the data array
 127+ $this->gateway_adapter->setHash( $this->generate_hash( $this->gateway_adapter->getData_Unstaged_Escaped() ) ); // hash the data array
128128 // check to see if we have a valid action set for us to bypass minfraud
129129 $actions = array( 'process', 'challenge', 'review', 'reject' );
130130 $action_hash = $localdata['action']; // a hash of the action to take passed in by the form submission
Index: trunk/extensions/DonationInterface/extras/conversion_log/conversion_log.body.php
@@ -11,7 +11,7 @@
1212 // if the trxn has been outright rejected, log it
1313 if ( $this->gateway_adapter->getValidationAction() == 'reject' ) {
1414 $this->log(
15 - $this->gateway_adapter->getData_Raw( 'contribution_tracking_id' ), 'Rejected'
 15+ $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), 'Rejected'
1616 );
1717 return TRUE;
1818 }
@@ -21,7 +21,7 @@
2222 return FALSE;
2323
2424 $this->log(
25 - $this->gateway_adapter->getData_Raw( 'contribution_tracking_id' ), "Gateway response: " . addslashes( $this->gateway_adapter->getTransactionMessage() ), '"' . addslashes( json_encode( $this->gateway_adapter->getTransactionData() ) ) . '"'
 25+ $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), "Gateway response: " . addslashes( $this->gateway_adapter->getTransactionMessage() ), '"' . addslashes( json_encode( $this->gateway_adapter->getTransactionData() ) ) . '"'
2626 );
2727 return TRUE;
2828 }
Index: trunk/extensions/DonationInterface/extras/recaptcha/recaptcha.body.php
@@ -42,12 +42,12 @@
4343 $captcha_resp = $this->check_captcha();
4444 if ( $captcha_resp->is_valid ) {
4545 // if validated, update the action and move on
46 - $this->log( $this->gateway_adapter->getData_Raw( 'contribution_tracking_id' ), 'Captcha passed' );
 46+ $this->log( $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), 'Captcha passed' );
4747 $this->gateway_adapter->setValidationAction( 'process' );
4848 return TRUE;
4949 } else {
5050 $this->recap_err = $captcha_resp->error;
51 - $this->log( $this->gateway_adapter->getData_Raw( 'contribution_tracking_id' ), 'Captcha failed' );
 51+ $this->log( $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), 'Captcha failed' );
5252 }
5353 }
5454 // display captcha
@@ -64,7 +64,7 @@
6565 $useSSL = $this->gateway_adapter->getGlobal( 'RecaptchaUseSSL' );
6666
6767 // log that a captcha's been triggered
68 - $this->log( $this->gateway_adapter->getData_Raw( 'contribution_tracking_id' ), 'Captcha triggered' );
 68+ $this->log( $this->gateway_adapter->getData_Unstaged_Escaped( 'contribution_tracking_id' ), 'Captcha triggered' );
6969
7070 // construct the HTML used to display the captcha
7171 $captcha_html = Xml::openElement( 'div', array( 'id' => 'mw-donate-captcha' ) );
@@ -76,7 +76,7 @@
7777
7878 //TODO: use setValidationErrors and getValidationErrors everywhere, and
7979 //refactor all the form constructors one more time. Eventually.
80 - $data = $this->gateway_adapter->getData_Raw();
 80+ $data = $this->gateway_adapter->getData_Unstaged_Escaped();
8181 $errors = $this->gateway_adapter->getValidationErrors();
8282 $form_obj = new $form_class( $this->gateway_adapter, $errors );
8383
Index: trunk/extensions/DonationInterface/gateway_forms/Form.php
@@ -84,7 +84,7 @@
8585
8686 $this->gateway = & $gateway;
8787 $this->test = $this->gateway->getGlobal( "Test" );
88 - $this->form_data = $this->gateway->getData_Raw();
 88+ $this->form_data = $this->gateway->getData_Unstaged_Escaped();
8989 $this->form_errors = & $error;
9090
9191 /**
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php
@@ -89,7 +89,7 @@
9090 $this->setHeaders();
9191
9292 if ( $forbidden ){
93 - $this->adapter->log( "Resultswitcher: Request forbidden. " . $f_message . " Querystring Order ID: $qs_oid Adapter Order ID: " . $this->adapter->getData_Raw( 'order_id' ) );
 93+ $this->adapter->log( "Resultswitcher: Request forbidden. " . $f_message . " Querystring Order ID: $qs_oid Adapter Order ID: " . $this->adapter->getData_Unstaged_Escaped( 'order_id' ) );
9494 return;
9595 } else {
9696 $this->adapter->log( "Resultswitcher: OK to process Order ID: " . $qs_oid );
@@ -101,7 +101,7 @@
102102 $oid = $wgRequest->getText( 'order_id' );
103103
104104 //this next block is for credit card coming back from GC. Only that. Nothing else, ever.
105 - if ( $this->adapter->getData_Raw( 'payment_method') === 'cc' ) {
 105+ if ( $this->adapter->getData_Unstaged_Escaped( 'payment_method') === 'cc' ) {
106106 if ( !array_key_exists( 'order_status', $_SESSION ) || !array_key_exists( $oid, $_SESSION['order_status'] ) || !is_array( $_SESSION['order_status'][$oid] ) ) {
107107 $_SESSION['order_status'][$oid] = $this->adapter->do_transaction( 'Confirm_CreditCard' );
108108 $_SESSION['order_status'][$oid]['data']['count'] = 0;
@@ -148,7 +148,7 @@
149149 function getDeclinedResultPage() {
150150 global $wgOut;
151151
152 - $displayData = $this->adapter->getData_Raw();
 152+ $displayData = $this->adapter->getData_Unstaged_Escaped();
153153 $failpage = $this->adapter->getFailPage();
154154
155155 if ( $failpage ) {
Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php
@@ -109,7 +109,7 @@
110110 $final .= " Status $status = $count\n";
111111 }
112112 }
113 -
 113+ $this->adapter->log($final);
114114 echo $final;
115115 }
116116
Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php
@@ -36,7 +36,7 @@
3737 //re-init all these arrays, because this is a batch thing.
3838 $this->hard_data = array( );
3939 $this->transaction_results = array( );
40 - $this->raw_data = array( );
 40+ $this->unstaged_data = array( );
4141 $this->staged_data = array( );
4242
4343 $this->hard_data['order_id'] = $data['order_id'];
@@ -44,7 +44,7 @@
4545
4646 $this->dataObj = new DonationData( get_called_class(), false, $data );
4747
48 - $this->raw_data = $this->dataObj->getData();
 48+ $this->unstaged_data = $this->dataObj->getDataEscaped();
4949
5050 if ( $useDB ){
5151 $this->hard_data = array_merge( $this->hard_data, $this->getUTMInfoFromDB() );
@@ -61,7 +61,7 @@
6262 }
6363 $this->reAddHardData();
6464
65 - $this->staged_data = $this->raw_data;
 65+ $this->staged_data = $this->unstaged_data;
6666
6767 $this->setPostDefaults();
6868 $this->defineTransactions();
@@ -86,7 +86,7 @@
8787 //anywhere else, and this would constitute abuse of the system.
8888 //so don't do it.
8989 foreach ( $this->hard_data as $key => $val ) {
90 - $this->raw_data[$key] = $val;
 90+ $this->unstaged_data[$key] = $val;
9191 $this->staged_data[$key] = $val;
9292 }
9393 }
@@ -95,7 +95,7 @@
9696 switch ( $transaction ) {
9797 case 'SET_PAYMENT':
9898 case 'CANCEL_PAYMENT':
99 - self::log( $this->getData_Raw( 'contribution_tracking_id' ) . ": CVV: " . $this->getData_Raw( 'cvv_result' ) . ": AVS: " . $this->getData_Raw( 'avs_result' ) );
 99+ self::log( $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . ": CVV: " . $this->getData_Unstaged_Escaped( 'cvv_result' ) . ": AVS: " . $this->getData_Unstaged_Escaped( 'avs_result' ) );
100100 //and then go on, unless you're testing, in which case:
101101 // return "NOPE";
102102 // break;
@@ -130,7 +130,7 @@
131131 return null;
132132 }
133133
134 - $ctid = $this->getData_Raw( 'contribution_tracking_id' );
 134+ $ctid = $this->getData_Unstaged_Escaped( 'contribution_tracking_id' );
135135
136136 $data = array( );
137137
@@ -191,11 +191,11 @@
192192 return;
193193 }
194194
195 - if ( !is_null( $this->getData_Raw( 'date' ) ) ) {
196 - $timestamp = $this->getData_Raw( 'date' );
 195+ if ( !is_null( $this->getData_Unstaged_Escaped( 'date' ) ) ) {
 196+ $timestamp = $this->getData_Unstaged_Escaped( 'date' );
197197 } else {
198 - if ( !is_null( $this->getData_Raw( 'ts' ) ) ) {
199 - $timestamp = strtotime( $this->getData_Raw( 'ts' ) ); //I hate that this works.
 198+ if ( !is_null( $this->getData_Unstaged_Escaped( 'ts' ) ) ) {
 199+ $timestamp = strtotime( $this->getData_Unstaged_Escaped( 'ts' ) ); //I hate that this works.
200200 } else {
201201 $timestamp = time();
202202 }
@@ -208,7 +208,7 @@
209209 'gateway_txn_id' => $this->getTransactionGatewayTxnID(),
210210 //'language' => '',
211211 );
212 - $transaction += $this->getData_Raw();
 212+ $transaction += $this->getData_Unstaged_Escaped();
213213
214214 try {
215215 wfRunHooks( $hook, array( $transaction ) );
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php
@@ -190,7 +190,7 @@
191191
192192 //TODO: Get rid of $data out here completely, by putting this logic inside the adapter somewhere.
193193 //All we seem to be doing with it now, is internal adapter logic outside of the adapter.
194 - $data = $this->adapter->getData_Raw();
 194+ $data = $this->adapter->getData_Unstaged_Escaped();
195195
196196 // If the result of the previous transaction was failure, set the retry message.
197197 if ( $data && array_key_exists( 'response', $data ) && $data['response'] == 'failure' ) {
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -1093,9 +1093,9 @@
10941094 $is_orphan = false;
10951095 if ( count( $addme ) ){ //nothing unusual here.
10961096 $this->addData( $addme );
1097 - $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': ';
1098 - $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' );
1099 - $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' );
 1097+ $logmsg = $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . ': ';
 1098+ $logmsg .= 'CVV Result: ' . $this->getData_Unstaged_Escaped( 'cvv_result' );
 1099+ $logmsg .= ', AVS Result: ' . $this->getData_Unstaged_Escaped( 'avs_result' );
11001100 self::log( $logmsg );
11011101 } else { //this is an orphan transaction.
11021102 $this->staged_data['order_id'] = $this->staged_data['i_order_id'];
@@ -1128,9 +1128,9 @@
11291129 $gotCVV = true;
11301130 $this->addData( $addme );
11311131 $this->staged_data['order_id'] = $this->staged_data['i_order_id'];
1132 - $logmsg = $this->getData_Raw( 'contribution_tracking_id' ) . ': ';
1133 - $logmsg .= 'CVV Result: ' . $this->getData_Raw( 'cvv_result' );
1134 - $logmsg .= ', AVS Result: ' . $this->getData_Raw( 'avs_result' );
 1132+ $logmsg = $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . ': ';
 1133+ $logmsg .= 'CVV Result: ' . $this->getData_Unstaged_Escaped( 'cvv_result' );
 1134+ $logmsg .= ', AVS Result: ' . $this->getData_Unstaged_Escaped( 'avs_result' );
11351135 self::log( $logmsg );
11361136 $this->runPreProcessHooks();
11371137 $status_result['action'] = $this->getValidationAction();
@@ -1241,7 +1241,7 @@
12421242
12431243 if ( $problemflag ){
12441244 //we have probably had a communication problem that could mean stranded payments.
1245 - $problemmessage = $this->getData_Raw( 'contribution_tracking_id' ) . ':' . $this->getData_Raw( 'order_id' ) . ' ' . $problemmessage;
 1245+ $problemmessage = $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . ':' . $this->getData_Unstaged_Escaped( 'order_id' ) . ' ' . $problemmessage;
12461246 self::log( $problemmessage );
12471247 //hurm. It would be swell if we had a message that told the user we had some kind of internal error.
12481248 $ret = array(
@@ -1271,7 +1271,7 @@
12721272 $xmlString = $this->stripXMLResponseHeaders( $rawResponse );
12731273 $displayXML = $this->formatXmlString( $xmlString );
12741274 $realXML = new DomDocument( '1.0' );
1275 - self::log( $this->getData_Raw( 'contribution_tracking_id' ) . ": Raw XML Response:\n" . $displayXML ); //I am apparently a huge fibber.
 1275+ self::log( $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . ": Raw XML Response:\n" . $displayXML ); //I am apparently a huge fibber.
12761276 $realXML->loadXML( trim( $xmlString ) );
12771277 return $realXML;
12781278 }
@@ -1665,7 +1665,7 @@
16661666 //set the transaction result message
16671667 $responseStatus = isset( $response['STATUSID'] ) ? $response['STATUSID'] : '';
16681668 $this->setTransactionResult( "Response Status: " . $responseStatus, 'txn_message' ); //TODO: Translate for GC.
1669 - $this->setTransactionResult( $this->getData_Raw( 'order_id' ), 'gateway_txn_id' );
 1669+ $this->setTransactionResult( $this->getData_Unstaged_Escaped( 'order_id' ), 'gateway_txn_id' );
16701670 }
16711671
16721672 /**
@@ -2042,7 +2042,7 @@
20432043 // Get the default returnto
20442044 $returnto = $this->getData_Staged( 'returnto' );
20452045
2046 - if ( $this->getData_Raw( 'payment_method' ) === 'cc' ){
 2046+ if ( $this->getData_Unstaged_Escaped( 'payment_method' ) === 'cc' ){
20472047
20482048 // Add order ID to the returnto URL, only if it's not already there.
20492049 //TODO: This needs to be more robust (like actually pulling the
@@ -2063,7 +2063,7 @@
20642064
20652065 protected function pre_process_insert_orderwithpayment(){
20662066 $this->incrementNumAttempt();
2067 - if ( $this->getData_Raw( 'payment_method' ) === 'cc' ){
 2067+ if ( $this->getData_Unstaged_Escaped( 'payment_method' ) === 'cc' ){
20682068 $this->addDonorDataToSession();
20692069 }
20702070 }
@@ -2084,7 +2084,7 @@
20852085 }
20862086
20872087 protected function pre_process_get_orderstatus(){
2088 - if ( $this->getData_Raw( 'payment_method' ) === 'cc' ){
 2088+ if ( $this->getData_Unstaged_Escaped( 'payment_method' ) === 'cc' ){
20892089 $this->runPreProcessHooks();
20902090 }
20912091 }
@@ -2094,13 +2094,13 @@
20952095 * determine if we want to fail the transaction ourselves or not.
20962096 */
20972097 public function getCVVResult(){
2098 - if ( is_null( $this->getData_Raw( 'cvv_result' ) ) ){
 2098+ if ( is_null( $this->getData_Unstaged_Escaped( 'cvv_result' ) ) ){
20992099 return null;
21002100 }
21012101
21022102 $cvv_map = $this->getGlobal( 'CvvMap' );
21032103
2104 - $result = $cvv_map[$this->getData_Raw( 'cvv_result' )];
 2104+ $result = $cvv_map[$this->getData_Unstaged_Escaped( 'cvv_result' )];
21052105 return $result;
21062106
21072107 }
@@ -2110,7 +2110,7 @@
21112111 * determine if we want to fail the transaction ourselves or not.
21122112 */
21132113 public function getAVSResult(){
2114 - if ( is_null( $this->getData_Raw( 'avs_result' ) ) ){
 2114+ if ( is_null( $this->getData_Unstaged_Escaped( 'avs_result' ) ) ){
21152115 return null;
21162116 }
21172117 //Best guess here:
@@ -2118,7 +2118,7 @@
21192119
21202120 $avs_map = $this->getGlobal( 'AvsMap' );
21212121
2122 - $result = $avs_map[$this->getData_Raw( 'avs_result' )];
 2122+ $result = $avs_map[$this->getData_Unstaged_Escaped( 'avs_result' )];
21232123 return $result;
21242124 }
21252125
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -163,7 +163,7 @@
164164 protected $staged_vars = array();
165165 protected $return_value_map;
166166 protected $staged_data;
167 - protected $raw_data;
 167+ protected $unstaged_data;
168168 protected $postdatadefaults;
169169 protected $xmlDoc;
170170 protected $dataObj;
@@ -221,8 +221,8 @@
222222
223223 $this->dataObj = new DonationData( get_called_class(), self::getGlobal( 'Test' ), $external_data );
224224
225 - $this->raw_data = $this->dataObj->getData();
226 - $this->staged_data = $this->raw_data;
 225+ $this->unstaged_data = $this->dataObj->getDataEscaped();
 226+ $this->staged_data = $this->unstaged_data;
227227
228228 $this->posted = ( $this->dataObj->wasPosted() && ( !is_null( $wgRequest->getVal( 'numAttempt', null ) ) ) );
229229
@@ -284,7 +284,7 @@
285285 $page = self::getGlobal( "FailPage" );
286286 if ( $page ) {
287287
288 - $language = $this->getData_Raw( 'language' );
 288+ $language = $this->getData_Unstaged_Escaped( 'language' );
289289
290290 $page .= '?uselang=' . $language;
291291 }
@@ -300,7 +300,7 @@
301301 * @return string A URL
302302 */
303303 protected function appendLanguageAndMakeURL( $url ){
304 - $language = $this->getData_Raw( 'language' );
 304+ $language = $this->getData_Unstaged_Escaped( 'language' );
305305 //make sure we don't already have the language in there...
306306 $dirs = explode('/', $url);
307307 if ( !is_array($dirs) || !in_array( $language, $dirs ) ){
@@ -387,20 +387,17 @@
388388 /**
389389 * This is the ONLY getData type function anything should be using
390390 * outside the adapter.
391 - * Please note that in this case, raw means it's been normalized and
392 - * sanitized by DonationData. Mostly, we qualify it as "raw" because it's
393 - * not been staged for this adapter.
394391 * @param string $val The specific key you're looking for (if any)
395392 * @return mixed An array of all the raw, unstaged (but normalized and
396393 * sanitized) data sent to the adapter, or if $val was set, either the
397394 * specific value held for $val, or null if none exists.
398395 */
399 - public function getData_Raw( $val = '' ) {
 396+ public function getData_Unstaged_Escaped( $val = '' ) {
400397 if ( $val === '' ) {
401 - return $this->raw_data;
 398+ return $this->unstaged_data;
402399 } else {
403 - if ( array_key_exists( $val, $this->raw_data ) ) {
404 - return $this->raw_data[$val];
 400+ if ( array_key_exists( $val, $this->unstaged_data ) ) {
 401+ return $this->unstaged_data[$val];
405402 } else {
406403 return null;
407404 }
@@ -798,9 +795,7 @@
799796 //reset, in case this isn't our first time.
800797 $this->transaction_results = array();
801798 $this->setValidationAction('process', true);
802 -
803 - $this->log( 'ReferrerHeaderTest (' . $this->getData_Raw( 'contribution_tracking_id' ) . "): Value @ do_transaction = " . $this->getData_Raw( 'referrer' ) );
804 -
 799+
805800 try {
806801 $this->setCurrentTransaction( $transaction );
807802
@@ -948,7 +943,7 @@
949944 }
950945
951946 // log that the transaction is essentially complete
952 - self::log( $this->getData_Raw( 'contribution_tracking_id' ) . " Transaction complete." );
 947+ self::log( $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . " Transaction complete." );
953948
954949 $this->debugarray[] = 'numAttempt = ' . $this->getData_Staged('numAttempt');
955950
@@ -1031,7 +1026,7 @@
10321027 */
10331028 public function getPaymentMethod() {
10341029
1035 - return $this->getData_Raw('payment_method');
 1030+ return $this->getData_Unstaged_Escaped('payment_method');
10361031 }
10371032
10381033 /**
@@ -1066,7 +1061,7 @@
10671062 */
10681063 public function getPaymentSubmethod() {
10691064
1070 - return $this->getData_Raw('payment_submethod');
 1065+ return $this->getData_Unstaged_Escaped('payment_submethod');
10711066 }
10721067
10731068 /**
@@ -1131,15 +1126,15 @@
11321127 $results = array();
11331128
11341129 while ( $i++ <= 3 ) {
1135 - self::log( $this->getData_Raw( 'contribution_tracking_id' ) . ' Preparing to send transaction to ' . self::getGatewayName() );
 1130+ self::log( $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . ' Preparing to send transaction to ' . self::getGatewayName() );
11361131 $results['result'] = curl_exec( $ch );
11371132 $results['headers'] = curl_getinfo( $ch );
11381133
11391134 if ( $results['headers']['http_code'] != 200 && $results['headers']['http_code'] != 403 ) {
1140 - self::log( $this->getData_Raw( 'contribution_tracking_id' ) . ' Failed sending transaction to ' . self::getGatewayName() . ', retrying' );
 1135+ self::log( $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . ' Failed sending transaction to ' . self::getGatewayName() . ', retrying' );
11411136 sleep( 1 );
11421137 } elseif ( $results['headers']['http_code'] == 200 || $results['headers']['http_code'] == 403 ) {
1143 - self::log( $this->getData_Raw( 'contribution_tracking_id' ) . ' Finished sending transaction to ' . self::getGatewayName() );
 1138+ self::log( $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . ' Finished sending transaction to ' . self::getGatewayName() );
11441139 break;
11451140 }
11461141 }
@@ -1151,7 +1146,7 @@
11521147 //TODO: i18n here!
11531148 //TODO: But also, fire off some kind of "No response from the gateway" thing to somebody so we know right away.
11541149 $results['message'] = 'No response from ' . self::getGatewayName() . '. Please try again later!';
1155 - self::log( $this->getData_Raw( 'contribution_tracking_id' ) . ' No response from ' . self::getGatewayName() . ': ' . curl_error( $ch ) );
 1150+ self::log( $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . ' No response from ' . self::getGatewayName() . ': ' . curl_error( $ch ) );
11561151 curl_close( $ch );
11571152 return false;
11581153 }
@@ -1315,7 +1310,7 @@
13161311 }
13171312
13181313 $params = array(
1319 - 'contribution_id' => $this->dataObj->getVal( 'contribution_tracking_id' ),
 1314+ 'contribution_id' => $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ),
13201315 'duration' => $this->getStopwatch( $function ),
13211316 'gateway' => self::getGatewayName(),
13221317 'function' => $function,
@@ -1510,7 +1505,7 @@
15111506 'gateway_txn_id' => $this->getTransactionGatewayTxnID(),
15121507 //'language' => '',
15131508 );
1514 - $transaction += $this->getData_Raw();
 1509+ $transaction += $this->getData_Unstaged_Escaped();
15151510
15161511 try {
15171512 wfRunHooks( $hook, array( $transaction ) );
@@ -1532,7 +1527,7 @@
15331528 return;
15341529 }
15351530
1536 - if ($this->getData_Raw( 'payment_method' ) === 'cc'){
 1531+ if ($this->getData_Unstaged_Escaped( 'payment_method' ) === 'cc'){
15371532 global $wgCCLimboStompQueueName;
15381533 if ( !isset( $wgCCLimboStompQueueName ) || $wgCCLimboStompQueueName === false ){
15391534 return;
@@ -1554,7 +1549,7 @@
15551550 'date' => time(),
15561551 'gateway_txn_id' => $this->getTransactionGatewayTxnID(),
15571552 'correlation-id' => $this->getCorrelationID(),
1558 - 'payment_method' => $this->getData_Raw( 'payment_method' ),
 1553+ 'payment_method' => $this->getData_Unstaged_Escaped( 'payment_method' ),
15591554 'antimessage' => 'true'
15601555 );
15611556 } else {
@@ -1563,14 +1558,14 @@
15641559 'date' => time(),
15651560 'gateway_txn_id' => $this->getTransactionGatewayTxnID(),
15661561 'correlation-id' => $this->getCorrelationID(),
1567 - 'payment_method' => $this->getData_Raw( 'payment_method' ),
 1562+ 'payment_method' => $this->getData_Unstaged_Escaped( 'payment_method' ),
15681563 );
15691564
1570 - $raw_data = array();
 1565+ $unstaged_local = array();
15711566 foreach ( $stomp_fields as $field ){
1572 - $raw_data[$field] = $this->getData_Raw( $field );
 1567+ $unstaged_local[$field] = $this->getData_Unstaged_Escaped( $field );
15731568 }
1574 - $transaction = array_merge( $raw_data, $transaction );
 1569+ $transaction = array_merge( $unstaged_local, $transaction );
15751570 }
15761571
15771572 try {
@@ -1581,7 +1576,7 @@
15821577 }
15831578
15841579 protected function getCorrelationID(){
1585 - return $this->getIdentifier() . '-' . $this->getData_Raw('order_id');
 1580+ return $this->getIdentifier() . '-' . $this->getData_Unstaged_Escaped('order_id');
15861581 }
15871582
15881583 function smooshVarsForStaging() {
@@ -1670,7 +1665,7 @@
16711666 }
16721667
16731668 function getPaypalRedirectURL() {
1674 - $currency = $this->getData_Raw( 'currency_code' );
 1669+ $currency = $this->getData_Unstaged_Escaped( 'currency_code' );
16751670
16761671 // update the utm source to set the payment instrument to pp rather than cc
16771672 $data['payment_method'] = 'pp';
@@ -1720,9 +1715,9 @@
17211716 );
17221717 $ret = array();
17231718 foreach ( $paypalkeys as $key ){
1724 - $val = $this->getData_Raw( $key );
 1719+ $val = $this->getData_Unstaged_Escaped( $key );
17251720 if (!is_null( $val )){
1726 - $ret[$key] = $this->getData_Raw( $key );
 1721+ $ret[$key] = $this->getData_Unstaged_Escaped( $key );
17271722 }
17281723 }
17291724 return $ret;
@@ -1932,9 +1927,9 @@
19331928 */
19341929 function runPreProcessHooks() {
19351930 // allow any external validators to have their way with the data
1936 - self::log( $this->getData_Raw( 'contribution_tracking_id' ) . " Preparing to query MaxMind" );
 1931+ self::log( $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . " Preparing to query MaxMind" );
19371932 wfRunHooks( 'GatewayValidate', array( &$this ) );
1938 - self::log( $this->getData_Raw( 'contribution_tracking_id' ) . ' Finished querying Maxmind' );
 1933+ self::log( $this->getData_Unstaged_Escaped( 'contribution_tracking_id' ) . ' Finished querying Maxmind' );
19391934
19401935 //DO NOT set some variable as getValidationAction() here, and keep
19411936 //checking that. getValidationAction could change with each one of these
@@ -2004,7 +1999,7 @@
20052000 /**
20062001 * Instead of pulling all the DonationData back through to update one local
20072002 * value, use this. It updates both staged_data (which is intended to be
2008 - * staged and used _just_ by the gateway) and raw_data, which is actually
 2003+ * staged and used _just_ by the gateway) and unstaged_data, which is actually
20092004 * just normalized and sanitized form data as entered by the user.
20102005 *
20112006 * TODO: handle the cases where $val is listed in the gateway adapter's
@@ -2016,13 +2011,13 @@
20172012 * our DonationData object.
20182013 */
20192014 function refreshGatewayValueFromSource( $val ) {
2020 - $refreshed = $this->dataObj->getVal( $val );
 2015+ $refreshed = $this->dataObj->getVal_Escaped( $val );
20212016 if ( !is_null($refreshed) ){
20222017 $this->staged_data[$val] = $refreshed;
2023 - $this->raw_data[$val] = $refreshed;
 2018+ $this->unstaged_data[$val] = $refreshed;
20242019 } else {
20252020 unset( $this->staged_data[$val] );
2026 - unset( $this->raw_data[$val] );
 2021+ unset( $this->unstaged_data[$val] );
20272022 }
20282023 }
20292024
Index: trunk/extensions/DonationInterface/gateway_common/donation.api.php
@@ -44,7 +44,7 @@
4545 $this->dieUsage( "Invalid gateway <<<$gateway>>> passed to Donation API.", 'unknown_gateway' );
4646 }
4747
48 - //$normalizedData = $gatewayObj->getData_Raw();
 48+ //$normalizedData = $gatewayObj->getData_Unstaged_Escaped();
4949 $outputResult = array();
5050 $outputResult['message'] = $result['message'];
5151 $outputResult['status'] = $result['status'];
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php
@@ -18,7 +18,7 @@
1919 $this->populateData( $test, $data );
2020 }
2121
22 - function populateData( $test = false, $external_data = false ) {
 22+ protected function populateData( $test = false, $external_data = false ) {
2323 global $wgRequest;
2424 $this->normalized = array( );
2525 if ( is_array( $external_data ) ){
@@ -107,25 +107,12 @@
108108 }
109109 }
110110
111 - $posted_referrer = $wgRequest->getVal( 'referrer' );
112 - $tries = array(
113 - 'referer',
114 - 'referrer',
115 - 'Referer',
116 - 'Referrer'
117 - );
118 - foreach ($tries as $trythis){
119 - $header[$trythis] = $wgRequest->getHeader( $trythis );
120 - }
121 -
122 - $this->log( 'ReferrerHeaderTest (' . $this->getVal( 'contribution_tracking_id' ) . "): Posted = $posted_referrer, Header Tries = " . print_r($header, true) . ', Final = ' . $this->getVal('referrer') );
123 -
124111 //if we have saved any donation data to the session, pull them in as well.
125112 $this->integrateDataFromSession();
126113
127114 $this->doCacheStuff();
128115
129 - $this->normalizeAndSanitize();
 116+ $this->normalize();
130117
131118 }
132119
@@ -134,7 +121,7 @@
135122 * If donor session data has been set, pull the fields in the session that
136123 * are populated, and merge that with the data set we already have.
137124 */
138 - function integrateDataFromSession(){
 125+ protected function integrateDataFromSession(){
139126 if ( self::sessionExists() && array_key_exists( 'Donor', $_SESSION ) ) {
140127 //if the thing coming in from the session isn't already something,
141128 //replace it.
@@ -153,14 +140,27 @@
154141 }
155142 }
156143 }
157 - $this->log( 'ReferrerHeaderTest (' . $this->getVal( 'contribution_tracking_id' ) . "): Final After Session Integration = " . $this->getVal('referrer') );
158144 }
159145
160 - function getData() {
 146+ /**
 147+ * Returns an array of normalized and escaped donation data
 148+ * @return array
 149+ */
 150+ public function getDataEscaped() {
 151+ $escaped = $this->normalized;
 152+ array_walk( $escaped, array( $this, 'sanitizeInput' ) );
 153+ return $escaped;
 154+ }
 155+
 156+ /**
 157+ * Returns an array of normalized (but unescaped) donation data
 158+ * @return array
 159+ */
 160+ public function getDataUnescaped() {
161161 return $this->normalized;
162162 }
163163
164 - function populateData_Test( $testdata = false ) {
 164+ protected function populateData_Test( $testdata = false ) {
165165 // define arrays of cc's and cc #s for random selection
166166 $cards = array( 'american' );
167167 $card_nums = array(
@@ -234,7 +234,7 @@
235235 * @param string $key The field you would like to determine if it exists or not.
236236 * @return boolean true if the field is something. False if it is null, or an empty string.
237237 */
238 - function isSomething( $key ) {
 238+ public function isSomething( $key ) {
239239 if ( array_key_exists( $key, $this->normalized ) ) {
240240 if ( is_null($this->normalized[$key]) || $this->normalized[$key] === '' ) {
241241 return false;
@@ -245,8 +245,27 @@
246246 }
247247 }
248248
249 - function getVal( $key ) {
 249+ /**
 250+ * getVal_Escaped
 251+ * @param string $key The data field you would like to retrieve.
 252+ * @return mixed The normalized and escaped value of that $key.
 253+ */
 254+ public function getVal_Escaped( $key ) {
250255 if ( $this->isSomething( $key ) ) {
 256+ return $this->sanitizeInput( $this->normalized[$key] );
 257+ } else {
 258+ return null;
 259+ }
 260+ }
 261+
 262+ /**
 263+ * getVal
 264+ * For Internal Use Only! External objects should use getVal_Escaped.
 265+ * @param string $key The data field you would like to retrieve.
 266+ * @return mixed The normalized value of that $key.
 267+ */
 268+ protected function getVal( $key ) {
 269+ if ( $this->isSomething( $key ) ) {
251270 return $this->normalized[$key];
252271 } else {
253272 return null;
@@ -270,7 +289,7 @@
271290
272291 /**
273292 * Returns an array of all the fields that get re-calculated during a
274 - * normalizeAndSanitize.
 293+ * normalize.
275294 * This will most likely be used on the outside when in the process of
276295 * adding data.
277296 * @return array An array of values matching all recauculated fields.
@@ -293,10 +312,10 @@
294313 }
295314
296315 /**
297 - * Normalizes and Sanitizes the current set of data, just after it's been
 316+ * Normalizes the current set of data, just after it's been
298317 * pulled (or re-pulled) from a source.
299318 */
300 - function normalizeAndSanitize() {
 319+ function normalize() {
301320 if ( !empty( $this->normalized ) ) {
302321 $this->setUtmSource();
303322 $this->setNormalizedAmount();
@@ -307,12 +326,11 @@
308327 $this->setCountry();
309328 $this->handleContributionTrackingID();
310329 $this->setCurrencyCode();
311 - array_walk( $this->normalized, array( $this, 'sanitizeInput' ) );
312330 }
313331 }
314332
315333 /**
316 - * normalizeAndSanitize helper function
 334+ * normalize helper function
317335 * Setting the country correctly.
318336 */
319337 function setCountry() {
@@ -331,7 +349,7 @@
332350 }
333351
334352 /**
335 - * normalizeAndSanitize helper function
 353+ * normalize helper function
336354 * Setting the currency code correctly.
337355 */
338356 function setCurrencyCode() {
@@ -358,7 +376,7 @@
359377 }
360378
361379 /**
362 - * normalizeAndSanitize helper function.
 380+ * normalize helper function.
363381 * Assures that if no contribution_tracking_id is present, a row is created
364382 * in the Contribution tracking table, and that row is assigned to the
365383 * current contribution we're tracking.
@@ -403,7 +421,7 @@
404422 }
405423
406424 /**
407 - * normalizeAndSanitize helper function.
 425+ * normalize helper function.
408426 * Takes all possible sources for the intended donation amount, and
409427 * normalizes them into the 'amount' field.
410428 */
@@ -420,7 +438,7 @@
421439 }
422440
423441 /**
424 - * normalizeAndSanitize helper function.
 442+ * normalize helper function.
425443 * Ensures that order_id and i_order_id are ready to go, depending on what
426444 * comes in populated or not, and where it came from.
427445 * @return null
@@ -459,22 +477,21 @@
460478 * Intended to be used with something like array_walk.
461479 *
462480 * @param $value The value of the array
463 - * @param $key The key of the array
464481 * @param $flags The flag constant for htmlspecialchars
465482 * @param $double_encode Whether or not to double-encode strings
466483 */
467 - public function sanitizeInput( &$value, $key, $flags=ENT_COMPAT, $double_encode=false ) {
 484+ protected function sanitizeInput( &$value, $flags=ENT_COMPAT, $double_encode=false ) {
468485 $value = htmlspecialchars( $value, $flags, 'UTF-8', $double_encode );
469486 }
470487
471 - function log( $message, $log_level=LOG_INFO ) {
 488+ protected function log( $message, $log_level=LOG_INFO ) {
472489 $c = $this->getAdapterClass();
473490 if ( $c && is_callable( array( $c, 'log' ) )){
474491 $c::log( $message, $log_level );
475492 }
476493 }
477494
478 - function getGatewayIdentifier() {
 495+ protected function getGatewayIdentifier() {
479496 $c = $this->getAdapterClass();
480497 if ( $c && is_callable( array( $c, 'getIdentifier' ) ) ){
481498 return $c::getIdentifier();
@@ -483,7 +500,7 @@
484501 }
485502 }
486503
487 - function getGatewayGlobal( $varname ) {
 504+ protected function getGatewayGlobal( $varname ) {
488505 $c = $this->getAdapterClass();
489506 if ( $c && is_callable( array( $c, 'getGlobal' ) ) ){
490507 return $c::getGlobal( $varname );
@@ -493,24 +510,24 @@
494511 }
495512
496513 /**
497 - * normalizeAndSanitize helper function.
 514+ * normalize helper function.
498515 * Sets the gateway to be the gateway that called this class in the first
499516 * place.
500517 */
501 - function setGateway() {
 518+ protected function setGateway() {
502519 //TODO: Hum. If we have some other gateway in the form data, should we go crazy here? (Probably)
503520 $gateway = $this->gatewayID;
504521 $this->setVal( 'gateway', $gateway );
505522 }
506523
507524 /**
508 - * normalizeAndSanitize helper function.
 525+ * normalize helper function.
509526 * If the language has not yet been set or is not valid, pulls the language code
510527 * from the current global language object.
511528 * Also sets the premium_language as the calculated language if it's not
512529 * already set coming in (had been defaulting to english).
513530 */
514 - function setLanguage() {
 531+ protected function setLanguage() {
515532 global $wgLang;
516533 $language = false;
517534
@@ -545,7 +562,7 @@
546563 * @global bool $wgUseSquid
547564 * @global type $wgOut
548565 */
549 - function doCacheStuff() {
 566+ protected function doCacheStuff() {
550567 //TODO: Wow, name.
551568 // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax
552569 if ( $this->isCaching() ) {
@@ -563,7 +580,7 @@
564581 }
565582 }
566583
567 - function getAnnoyingOrderIDLogLinePrefix() {
 584+ protected function getAnnoyingOrderIDLogLinePrefix() {
568585 //TODO: ...aww. But it's so descriptive.
569586 return $this->getVal( 'order_id' ) . ' ' . $this->getVal( 'i_order_id' ) . ': ';
570587 }
@@ -577,6 +594,8 @@
578595 * a security risk for non-authenticated users. Until this is
579596 * resolved in $wgUser, we'll use our own methods for token
580597 * handling.
 598+ *
 599+ * Public so the api can get to it.
581600 *
582601 * @return string
583602 */
@@ -602,7 +621,7 @@
603622 * In the case where we have an expired session (token mismatch), we go
604623 * ahead and fix it for 'em for their next post.
605624 */
606 - function token_refreshAllTokenEverything(){
 625+ protected function token_refreshAllTokenEverything(){
607626 $unsalted = self::token_generateToken();
608627 $gateway_ident = $this->gatewayID;
609628 self::ensureSession();
@@ -611,7 +630,7 @@
612631 $this->setVal( 'token', $salted );
613632 }
614633
615 - function token_applyMD5AndSalt( $clear_token ){
 634+ protected function token_applyMD5AndSalt( $clear_token ){
616635 $salt = $this->getGatewayGlobal( 'Salt' );
617636
618637 if ( is_array( $salt ) ) {
@@ -640,7 +659,7 @@
641660 * @var string $val
642661 * @return bool
643662 */
644 - function token_matchEditToken( $val ) {
 663+ protected function token_matchEditToken( $val ) {
645664 // fetch a salted version of the session token
646665 $sessionSaltedToken = $this->token_getSaltedSessionToken();
647666 if ( $val != $sessionSaltedToken ) {
@@ -657,7 +676,7 @@
658677 * If we do not have a session set for the current user,
659678 * start the session.
660679 */
661 - public static function ensureSession() {
 680+ protected static function ensureSession() {
662681 // if the session is already started, do nothing
663682 if ( self::sessionExists() )
664683 return;
@@ -670,7 +689,7 @@
671690 * Checks to see if the session exists without actually creating one.
672691 * @return bool true if we have a session, otherwise false.
673692 */
674 - public static function sessionExists() {
 693+ protected static function sessionExists() {
675694 if ( session_id() )
676695 return true;
677696 return false;
@@ -711,7 +730,7 @@
712731 }
713732
714733 /**
715 - * normalizeAndSanitize helper function.
 734+ * normalize helper function.
716735 *
717736 * Checks to see if the utm_source is set properly for the credit card
718737 * form including any cc form variants (identified by utm_source_id). If
@@ -768,7 +787,7 @@
769788 * NOTE: If you prune here, and there is a paypal redirect, you will have
770789 * problems with the email-opt/optout and comment-option/anonymous.
771790 */
772 - function setNormalizedOptOuts( $prune = false ) {
 791+ protected function setNormalizedOptOuts( $prune = false ) {
773792 $optout['optout'] = ( $this->isSomething( 'email-opt' ) && $this->getVal( 'email-opt' ) == "1" ) ? '0' : '1';
774793 $optout['anonymous'] = ( $this->isSomething( 'comment-option' ) && $this->getVal( 'comment-option' ) == "1" ) ? '0' : '1';
775794 foreach ( $optout as $thing => $stuff ) {
@@ -969,7 +988,7 @@
970989 }
971990 }
972991 }
973 - $this->normalizeAndSanitize();
 992+ $this->normalize();
974993 }
975994
976995 public function incrementNumAttempt() {
@@ -984,7 +1003,7 @@
9851004 }
9861005 }
9871006
988 - function getAdapterClass(){
 1007+ protected function getAdapterClass(){
9891008 if ( class_exists( $this->boss ) ) {
9901009 return $this->boss;
9911010 } else {
@@ -1000,7 +1019,7 @@
10011020 * /extensions/DonationData/activemq_stomp/activemq_stomp.php
10021021 * to somewhere in DonationData. *
10031022 */
1004 - function getStompMessageFields(){
 1023+ public function getStompMessageFields(){
10051024 $stomp_fields = array(
10061025 'contribution_tracking_id',
10071026 'optout',
Index: trunk/extensions/DonationInterface/gateway_common/GatewayForm.php
@@ -77,7 +77,7 @@
7878 */
7979 public function validateForm( &$error, $options = array() ) {
8080
81 - $data = $this->adapter->getData_Raw();
 81+ $data = $this->adapter->getData_Unstaged_Escaped();
8282
8383 extract( $options );
8484

Follow-up revisions

RevisionCommit summaryAuthorDate
r105941followup r105938...khorn22:22, 12 December 2011
r105953followup r105938...khorn23:07, 12 December 2011
r112287MFT r101785, r105938, r105941, r105953, r106109, r106158, r106259, r106366, r...khorn01:29, 24 February 2012

Status & tagging log