r100666 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100665‎ | r100666 | r100667 >
Date:23:59, 24 October 2011
Author:khorn
Status:resolved (Comments)
Tags:fundraising 
Comment:
A bare-minimum fix to get GC credit card forms back off the ground, with a slight update for the validateForm class: Now passing nothing in the optional options array, will default to using all available options.
r100648
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/GatewayForm.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -40,14 +40,14 @@
4141 //TODO: This is short-circuiting what I really want to do here.
4242 //so stop it.
4343 $data = $this->adapter->getDisplayData();
44 -
 44+
4545 // dispatch forms/handling
4646 if ( $this->adapter->checkTokens() ) {
4747 if ( $this->adapter->posted) {
4848 // The form was submitted and the payment method has been set
4949 $this->adapter->log( "Form posted and payment method set." );
5050 // Check form for errors
51 - $form_errors = $this->validateForm( $data, $this->errors, array( 'address', 'amount', 'creditCard', 'email', 'name' ) );
 51+ $form_errors = $this->validateForm( $data, $this->errors );
5252 // If there were errors, redisplay form, otherwise proceed to next step
5353 if ( $form_errors ) {
5454 $this->displayForm( $data, $this->errors );
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -127,7 +127,6 @@
128128 'values' => array(
129129 'ACTION' => 'INSERT_ORDERWITHPAYMENT',
130130 'HOSTEDINDICATOR' => '1',
131 - //'PAYMENTPRODUCTID' => '11',
132131 ),
133132 'do_validation' => true,
134133 'addDonorDataToSession' => true,
@@ -229,7 +228,7 @@
230229 'paymentproductid' => 0,
231230 'label' => 'Any',
232231 'group' => 'cc',
233 - 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ),
 232+ 'validation' => array( 'address' => true, 'amount' => true, 'email' => true, 'name' => true, ),
234233 );
235234
236235 /*
@@ -241,7 +240,7 @@
242241 'paymentproductid' => 1,
243242 'label' => 'Visa',
244243 'group' => 'cc',
245 - 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ),
 244+ 'validation' => array( 'address' => true, 'amount' => true, 'email' => true, 'name' => true, ),
246245 );
247246
248247 // MasterCard
@@ -249,7 +248,7 @@
250249 'paymentproductid' => 3,
251250 'label' => 'MasterCard',
252251 'group' => 'cc',
253 - 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ),
 252+ 'validation' => array( 'address' => true, 'amount' => true, 'email' => true, 'name' => true, ),
254253 );
255254
256255 // American Express
@@ -257,7 +256,7 @@
258257 'paymentproductid' => 2,
259258 'label' => 'American Express',
260259 'group' => 'cc',
261 - 'validation' => array( 'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true, ),
 260+ 'validation' => array( 'address' => true, 'amount' => true, 'email' => true, 'name' => true, ),
262261 );
263262
264263 // Maestro
Index: trunk/extensions/DonationInterface/gateway_common/GatewayForm.php
@@ -94,39 +94,36 @@
9595 *
9696 * @see GatewayForm::fnValidateForm()
9797 */
98 - public function validateForm( &$data, &$error, $options = array( ) ) {
 98+ public function validateForm( &$data, &$error, $options = false ) {
9999
100 - //TODO: Should parts of this fail closed? Probably. Right now, with no
101 - //options sent, nothing will validate.
 100+ $validateAll = false;
 101+ if ($options === false){
 102+ $validateAll = true;
 103+ }
 104+
 105+ if ( is_array( $options ) ){
 106+ extract( $options );
 107+ }
102108
103 - extract( $options );
104 -
105 - // Set which items will be validated
106 - $address = isset( $address ) ? ( boolean ) $address : true;
107 - $amount = isset( $amount ) ? ( boolean ) $amount : true;
108 - $creditCard = isset( $creditCard ) ? ( boolean ) $creditCard : false;
109 - $email = isset( $email ) ? ( boolean ) $email : true;
110 - $name = isset( $name ) ? ( boolean ) $name : true;
111 -
112109 // These are set in the order they will most likely appear on the form.
113 -
114 - if ( $name ) {
 110+
 111+ if ( $validateAll || isset( $name ) ) {
115112 $this->validateName( $data, $error );
116113 }
117114
118 - if ( $address ) {
 115+ if ( $validateAll || isset( $address ) ) {
119116 $this->validateAddress( $data, $error );
120117 }
121118
122 - if ( $amount ) {
 119+ if ( $validateAll || isset( $amount ) ) {
123120 $this->validateAmount( $data, $error );
124121 }
125122
126 - if ( $email ) {
 123+ if ( $validateAll || isset( $email ) ) {
127124 $this->validateEmail( $data, $error );
128125 }
129126
130 - if ( $creditCard ) {
 127+ if ( $validateAll || isset( $creditCard ) ) {
131128 $this->validateCreditCard( $data, $error );
132129 }
133130

Follow-up revisions

RevisionCommit summaryAuthorDate
r100670Changed validateForm() to how it was prior to r100666.jpostlethwaite00:27, 25 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r100648Fixed the issues with credit cards for r100643.jpostlethwaite21:32, 24 October 2011

Comments

#Comment by Jpostlethwaite (talk | contribs)   00:05, 25 October 2011

This breaks the validation method.

The boolean parameters no longer matter because you are only checking isset.

'address' => true, 'amount' => true, 'creditCard' => true, 'email' => true, 'name' => true,

By default, it was validate all, except for credit card.

#Comment by Khorn (WMF) (talk | contribs)   16:26, 25 October 2011

Looks like this was re-fixed by you in 100670. You (or whoever) can mark it as reverted (I can't).

Status & tagging log