r101847 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101846‎ | r101847 | r101848 >
Date:18:44, 3 November 2011
Author:awjrichards
Status:deferred
Tags:
Comment:
Modified paths:
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/interface.i18n.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/tests (modified) (history)
  • /branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/tests/DonationDataTestCase.php (modified) (history)

Diff [purge]

Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/tests/DonationDataTestCase.php
@@ -303,7 +303,6 @@
304304 /**
305305 * TODO: Make sure ALL these functions in DonationData are tested, either directly or through a calling function.
306306 * I know that's more regression-ish, but I stand by it. :p
307 - function isCache(){
308307 function setNormalizedOrderIDs(){
309308 function generateOrderId() {
310309 public function sanitizeInput( &$value, $key, $flags=ENT_COMPAT, $double_encode=false ) {
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/tests
___________________________________________________________________
Modified: svn:mergeinfo
311310 Merged /trunk/extensions/DonationInterface/tests:r101786
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -65,7 +65,7 @@
6666 $this->displayForm( $this->errors );
6767 }
6868 } else {
69 - if ( !$this->adapter->isCache() ) {
 69+ if ( !$this->adapter->isCaching() ) {
7070 // if we're not caching, there's a token mismatch
7171 $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' );
7272 }
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/payflowpro_gateway
___________________________________________________________________
Modified: svn:mergeinfo
7373 Merged /trunk/extensions/DonationInterface/payflowpro_gateway:r101786
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect_resultswitcher.body.php
@@ -90,7 +90,7 @@
9191 $wgOut->redirect( $go );
9292 }
9393 } else {
94 - if ( !$this->adapter->isCache() ) {
 94+ if ( !$this->adapter->isCaching() ) {
9595 // if we're not caching, there's a token mismatch
9696 $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' );
9797 }
@@ -103,36 +103,24 @@
104104 */
105105 function getDeclinedResultPage() {
106106 global $wgOut;
 107+
 108+ $displayData = $this->adapter->getDisplayData();
107109 $failpage = $this->adapter->getGlobal( 'FailPage' );
108110
109111 if ( $failpage ) {
110 - $wgOut->redirect( $failpage . "/" . $data['language'] );
 112+ $wgOut->redirect( $failpage . "/" . $displayData['language'] );
111113 } else {
112 - // general decline message
113 - $declinedDefault = wfMsg( 'php-response-declined' );
114 -
115 - $displayData = $this->adapter->getDisplayData();
 114+ // Get the page we're going to send them back to.
116115 $referrer = $displayData['referrer'];
 116+ $returnto = htmlspecialchars_decode( $referrer ); // escape for security
117117
118 - $queryArray = array (
119 - 'fname' => $displayData['fname'],
120 - 'lname' => $displayData['lname'],
121 - 'street' => $displayData['street'],
122 - 'city' => $displayData['city'],
123 - 'state' => $displayData['state'],
124 - 'zip' => $displayData['zip'],
125 - 'country' => $displayData['country'],
126 - 'utm_source' => $displayData['utm_source'],
127 - 'utm_medium' => $displayData['utm_medium'],
128 - 'utm_campaign' => $displayData['utm_campaign'],
129 - 'numAttempt' => $displayData['numAttempt'],
130 - 'error' => $declinedDefault,
131 - );
 118+ // Set the response as failure so that an error message will be displayed when the form reloads.
 119+ $this->adapter->addData( array( 'response' => 'failure' ) );
132120
133 - // TODO: figure out something better so we aren't expanding the URL after every attempt.
134 - $returnto = wfAppendQuery( htmlspecialchars_decode( $referrer ), $queryArray );
 121+ // Store their data in the session.
 122+ $this->adapter->addDonorDataToSession();
135123
136 - // Return the referrer URL with the data included in the query string
 124+ // Return the referrer URL
137125 return $returnto;
138126 }
139127 }
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/globalcollect_gateway/globalcollect_gateway.body.php
@@ -84,7 +84,12 @@
8585
8686
8787 // dispatch forms/handling
88 - if ( $this->adapter->checkTokens() ) {
 88+ if ( $this->adapter->checkTokens() ) {
 89+
 90+ //TODO: Get rid of $data out here completely, by putting this logic inside the adapter somewhere.
 91+ //All we seem to be doing with it now, is internal adapter logic outside of the adapter.
 92+ $data = $this->adapter->getDisplayData();
 93+
8994 if ( $this->adapter->posted ) {
9095 // The form was submitted and the payment method has been set
9196 /*
@@ -92,11 +97,6 @@
9398 *
9499 * An invalid $payment_method will cause an error.
95100 */
96 -
97 - //TODO: Get rid of $data out here completely, by putting this logic inside the adapter somewhere.
98 - //All we seem to be doing with it now, is internal adapter logic outside of the adapter.
99 - $data = $this->adapter->getDisplayData();
100 -
101101 $payment_method = ( isset( $data['payment_method'] ) && !empty( $data['payment_method'] ) ) ? $data['payment_method'] : 'cc';
102102 $payment_submethod = ( isset( $data['payment_submethod'] ) && !empty( $data['payment_submethod'] ) ) ? $data['payment_submethod'] : '';
103103
@@ -124,17 +124,24 @@
125125
126126 }
127127 } else {
128 - // Display form for the first time
 128+ // Display form
 129+
 130+ // Not sure what this is for.
129131 $oid = $wgRequest->getText( 'order_id' );
130132 if ( $oid ) {
131 - // $wgOut->addHTML( "<pre>CAME BACK FROM SOMETHING.</pre>" );
132133 $result = $this->adapter->do_transaction( 'GET_ORDERSTATUS' );
133134 $this->displayResultsForDebug( $result );
134135 }
 136+
 137+ // If the result of the previous transaction was failure, set the retry message.
 138+ if ( $data && array_key_exists( 'response', $data ) && $data['response'] == 'failure' ) {
 139+ $this->errors['retryMsg'] = wfMsg( 'php-response-declined' );
 140+ }
 141+
135142 $this->displayForm( $this->errors );
136143 }
137144 } else {
138 - if ( !$this->adapter->isCache() ) {
 145+ if ( !$this->adapter->isCaching() ) {
139146 // if we're not caching, there's a token mismatch
140147 $this->errors['general']['token-mismatch'] = wfMsg( 'donate_interface-token-mismatch' );
141148 }
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/interface.i18n.php
@@ -122,7 +122,8 @@
123123 // Migrated messages
124124 'donate_interface-accessible' => 'This page is only accessible from the donation page.',
125125 'donate_interface-paypal-button' => 'Donate via PayPal',
126 - 'donate_interface-cc-button' => 'Donate by Credit Card',
 126+ 'donate_interface-cc-button' => 'Donate by credit card',
 127+ 'donate_interface-dd-button' => 'Donate by direct debit',
127128 'donate_interface-donor-legend' => 'Donor information',
128129 'donate_interface-card-legend' => 'Credit card information',
129130 'donate_interface-amount-legend' => 'Donation amount',
@@ -313,7 +314,6 @@
314315 'donate_interface-on-the-back' => 'With this on the back:',
315316 'donate_interface-tshirt-confirmation' => 'Your t-shirt will be shipped in the size and language below:',
316317 'donate_interface-donation-tshirt' => 'Donation (t-shirt offer)',
317 -
318318 'donate_interface-change' => 'Change',
319319 'donate_interface-select-credit-card' => 'Select credit card',
320320
@@ -340,9 +340,38 @@
341341 'donate_interface-translate-redlink1' => 'Help translate this page.',
342342 'donate_interface-translate-redlink2' => 'Or e-mail your translation to translations@wikimedia.org',
343343
 344+ // E-mail related variables
 345+ 'donate_interface-email-fallbackname' => 'friend of the Wikimedia Foundation',
 346+ 'donate_interface-email-subject' => 'Thank you from the Wikimedia Foundation',
 347+ 'donate_interface-email-unsub-title' => 'Wikimedia Foundation unsubscribe',
 348+ 'donate_interface-email-unsub-button' => 'Unsubscribe',
 349+ 'donate_interface-email-unsub-success' => 'You have successfully been removed from our mailing list',
 350+ 'donate_interface-email-unsub-delay' => 'Please allow up to four (4) days for the changes to take effect. We apologize for any emails you receive during this time. If you have any questions, please contact <donations@wikimedia.org>',
 351+ 'donate_interface-email-unsub-fail' => 'There was an error processing your request, please contact <donations@wikimedia.org>.',
 352+
 353+ // Various form interface elements
344354 'donate_interface-faqs' => 'Frequently asked questions',
345355 'donate_interface-tax-info' => 'Tax deductibility information',
346356 'donate_interface-informationsharing' => 'By donating, you are sharing your information with the Wikimedia Foundation, the nonprofit organization that hosts Wikipedia and other Wikimedia projects, and its service providers in the U.S. and elsewhere pursuant to our donor privacy policy. We do not sell or trade your information to anyone. For more information please read <a href="http://wikimediafoundation.org/wiki/Donor_policy/en">our donor policy</a>.'
 357+ 'donate_interface-currency-change' => 'Change?',
 358+ 'donate_interface-bank_transfer_message' => 'Please notice that your statement will show \'Global Collect\' as the recipient of this gift. Global Collect is authorized to accept and process payments on behalf of Wikimedia Foundation. Remember to include the reference number provided here on your bank transfer and feel free to email donations@wikimedia.org if you have any questions or concerns.',
 359+
 360+ // Tax deductibility and other legalese
 361+ 'donate_interface-taxded-link-int' => 'Tax and other legal information',
 362+ 'donate_interface-taxded-link-us' => 'Tax deductibility information',
 363+ 'donate_interface-taxded-msg-int' => 'Wikimedia Foundation is a non-profit charity established in the United States under the US IRS Code Section 501(c)(3), and, for that reason, donations from persons or entities located in the United States may benefit from tax deductible status. Donations from persons or entities located outside the United States may not be eligible for tax deductions in the United States and elsewhere; in such cases, donors should seek local tax advice. Importantly, Wikimedia does not seek donations from persons or entities located in any jurisdiction that prohibits or restricts fundraising activities by international charities such as Wikimedia or applies gift taxes on donations made to such international charities.',
 364+ 'donate_interface-taxded-msg-us' => 'Wikimedia Foundation is a non-profit charity established in the United States under the US IRS Code Section 501(c)(3), and, for that reason, donations from persons or entities located in the United States may benefit from tax deductible status.',
 365+ 'donate_interface-legal-original' => 'This is a courtesy translation. In the event of a conflict between this translation and the English version, the English version shall govern.',
 366+ 'donate_interface-legal-donorpolicy' => 'By donating, you are sharing your information with the Wikimedia Foundation, the nonprofit organization that hosts Wikipedia and other Wikimedia projects, and its service providers in the U.S. and elsewhere pursuant to our donor privacy policy. We do not sell or trade your information to anyone.',
 367+
 368+ // Monthly donation box
 369+ 'donate_interface-monthlybox-title' => 'Make it monthly?',
 370+ 'donate_interface-monthlybox-content' => 'Monthly donations are processed on the 2<sup>nd</sup> of every month. You may cancel at any time.',
 371+ 'donate_interface-monthlybox-amount' => 'Donation amount:',
 372+ 'donate_interface-monthlybox-yes' => 'Sure, make it monthly',
 373+ 'donate_interface-monthlybox-no' => 'NO, make a one-time donation',
 374+ 'donate_interface-monthlybox-bottom' => 'Your donation will be securely processed.',
 375+
347376
348377 );
349378
@@ -463,6 +492,7 @@
464493 'donate_interface-accessible' => 'Error message if you try to go to "Special:PayFlowProGateway" from anywhere else than the donation form.',
465494 'donate_interface-paypal-button' => 'Button to choose to donate via PayPal.',
466495 'donate_interface-cc-button' => 'Button to choose to donate by credit card.',
 496+ 'donate_interface-dd-button' => 'Button to choose to donate by direct debit.',
467497 'donate_interface-donor-legend' => 'Header for the entire form where you fill out your personal information.',
468498 'donate_interface-card-legend' => 'Header for part of the form that has information about the credit card itself.',
469499 'donate_interface-amount-legend' => 'Where you choose what amount to donate.',
@@ -671,6 +701,27 @@
672702 'donate_interface-translate-redlink2' => 'Plain text (not link) at the bottom of an appeal telling people that they can e-mail a translation. Preceded by [[MediaWiki:Donate interface-translate-redlink1]].',
673703 'donate_interface-faqs' => 'Link text to the frequently asked questions page',
674704 'donate_interface-tax-info' => 'Link to information about the tax deducability of donations',
 705+ 'donate_interface-email-fallbackname' => 'String that will be used instead of the donor\'s name in the e-mail in case it is missing.',
 706+ 'donate_interface-email-subject' => 'Subject line of thank you e-mail',
 707+ 'donate_interface-email-unsub-title' => 'Title for unsubscription box',
 708+ 'donate_interface-email-unsub-button' => 'The button you click to unsubscribe from receiving e-mails',
 709+ 'donate_interface-email-unsub-success' => 'The message that is shown when a user is successfully unsubscribed from the mailing list',
 710+ 'donate_interface-email-unsub-delay' => 'The message that is shown when there is a delay in the unsubscription of a donor from the mailing list',
 711+ 'donate_interface-email-unsub-fail' => 'The message that is shown when there has been an error in the unsubscription of a donor from the mailing list',
 712+ 'donate_interface-currency-change' => 'Link shown next to the radio buttons to choose amount. Users click this to change the currency of their donation.',
 713+ 'donate_interface-bank_transfer_message' => 'Message notifying donors that the recipient of the donation will show as Global Collect.',
 714+ 'donate_interface-taxded-link-int' => 'Link to information about tax deductibility and other legal information, to be used outside of the U.S.',
 715+ 'donate_interface-taxded-link-us' => 'Link to information about tax deductibility, to be used inside of the U.S.',
 716+ 'donate_interface-taxded-msg-int' => 'Legal information shown to international donors.',
 717+ 'donate_interface-taxded-msg-us' => 'Tax deductibility shown to U.S. donors.',
 718+ 'donate_interface-legal-original' => 'Message notifying users that the English version of legal pages is the prevalent one.',
 719+ 'donate_interface-legal-donorpolicy' => 'Message telling donors about the Donor Privacy Policy.',
 720+ 'donate_interface-monthlybox-title' => 'Header for box prompting users to change from one-time donation to a recurring monthly donation.',
 721+ 'donate_interface-monthlybox-content' => 'Information about when and how monthly donations are processed.',
 722+ 'donate_interface-monthlybox-amount' => 'Label for the field for the donation amount.',
 723+ 'donate_interface-monthlybox-yes' => 'Button to click to accept giving a monthly donation.',
 724+ 'donate_interface-monthlybox-no' => 'Button to click to decline giving a monthly donation.',
 725+ 'donate_interface-monthlybox-bottom' => 'Message in the bottom of the monthly donation box ensuring donors that their donation will be processed securely.',
675726 );
676727
677728 /** Magyar (magázó) (Magyar (magázó))
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -269,6 +269,14 @@
270270 }
271271 }
272272 }
 273+
 274+ /**
 275+ * A helper function to let us stash extra data after the form has been submitted.
 276+ * @param array $dataArray An associative array of data.
 277+ */
 278+ public function addData( $dataArray ) {
 279+ $this->dataObj->addData( $dataArray );
 280+ }
273281
274282 /**
275283 * Returns the variable $this->dataObj which should be an instance of
@@ -293,8 +301,8 @@
294302 }
295303 }
296304
297 - function isCache() {
298 - return $this->dataObj->isCache();
 305+ function isCaching() {
 306+ return $this->dataObj->isCaching();
299307 }
300308
301309 /**
Index: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface/gateway_common/DonationData.php
@@ -143,10 +143,6 @@
144144 return $this->normalized;
145145 }
146146
147 - function isCache() {
148 - return $this->cache;
149 - }
150 -
151147 function populateData_Test( $testdata = false ) {
152148 // define arrays of cc's and cc #s for random selection
153149 $cards = array( 'american' );
@@ -273,19 +269,27 @@
274270 */
275271 function handleContributionTrackingID(){
276272 if ( !$this->isSomething( 'contribution_tracking_id' ) &&
277 - ( !$this->canCache() ) ){
 273+ ( !$this->isCaching() ) ){
278274 $this->saveContributionTracking();
279275 }
280276 }
281277
282278
283 - function canCache(){
284 - if ( $this->getVal( '_cache_' ) === 'true' ){ //::head. hit. keyboard.::
285 - if ( $this->isSomething( 'utm_source_id' ) && !is_null( 'utm_source_id' ) ){
286 - return true;
 279+ function isCaching(){
 280+ //I think it's safe to static this here. I don't want to calc this every
 281+ //time some outside object asks if we're caching.
 282+ static $cache = null;
 283+ if ( is_null( $cache ) ){
 284+ if ( $this->getVal( '_cache_' ) === 'true' ){ //::head. hit. keyboard.::
 285+ if ( $this->isSomething( 'utm_source_id' ) && !is_null( 'utm_source_id' ) ){
 286+ $cache = true;
 287+ }
287288 }
 289+ if ( is_null( $cache ) ){
 290+ $cache = false;
 291+ }
288292 }
289 - return false;
 293+ return $cache;
290294 }
291295
292296 /**
@@ -404,9 +408,8 @@
405409 function doCacheStuff() {
406410 //TODO: Wow, name.
407411 // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax
408 - if ( $this->isSomething( '_cache_' ) ) {
 412+ if ( $this->isCaching() ) {
409413 self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Cache requested', LOG_DEBUG );
410 - $this->cache = true; //TODO: If we don't need this, kill it in the face.
411414 $this->setVal( 'token', 'cache' );
412415
413416 // if we have squid caching enabled, set the maxage
@@ -417,8 +420,6 @@
418421 self::log( $this->getAnnoyingOrderIDLogLinePrefix() . ' Setting s-max-age: ' . $maxAge, LOG_DEBUG );
419422 $wgOut->setSquidMaxage( $maxAge );
420423 }
421 - } else {
422 - $this->cache = false; //TODO: Kill this one in the face, too. (see above)
423424 }
424425 }
425426
Property changes on: branches/fundraising/deployment/payments_1.17/extensions/DonationInterface
___________________________________________________________________
Modified: svn:mergeinfo
426427 Merged /trunk/extensions/DonationInterface:r101778,101781,101786-101789

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r101778Had to revert this, because it both breaks GC non-ajax-based CC forms, and wi...khorn02:22, 3 November 2011
r101781follow-up to r101764 and r101576, fixing bogus call to $datakaldari02:43, 3 November 2011
r101786Cleans up all the cache functions that were all supposed to accomplish the sa...khorn04:34, 3 November 2011
r101787way smarter way to handle the failure messages from GlobalCollectkaldari04:36, 3 November 2011
r101788Adding all known missing interface messagesjhsoby05:16, 3 November 2011
r101789Adding qqq messages to the newly added messagesjhsoby05:31, 3 November 2011

Status & tagging log