r102047 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102046‎ | r102047 | r102048 >
Date:21:09, 4 November 2011
Author:khorn
Status:ok
Tags:
Comment:
Establishes constraints on settable fields that should contain the over-arching result for one discrete donation attempt (which can involve multiple transactions, posts, errors, whatever).
This is the quick and dirty version.
Also noticed upon implementation that we (and by "we" I mean "mostly me": r97341, r99036, r101959 ) had already screwed this up, so this is a Very Good Thing.
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -1276,15 +1276,26 @@
12771277 * @param string $transaction The transaction these codes map to.
12781278 * @param string $key The (incoming) field name containing the numeric codes
12791279 * we're defining here.
1280 - * @param string $action Should be limited to the values 'complete',
1281 - * 'pending', 'pending-poke', 'failed' and 'revised'... but for now you're
1282 - * on the honor system, kids. TODO: Limit these values in this function,
1283 - * once we are slightly more certain we don't need more values.
 1280+ * @param string $action Limited to the values 'complete', 'pending',
 1281+ * 'pending-poke', 'failed' and 'revised'.
12841282 * @param int $lower The integer value of the lower-bound in this code range.
12851283 * @param int $upper Optional: The integer value of the upper-bound in the
12861284 * code range. If omitted, it will make a range of one value: The lower bound.
12871285 */
12881286 protected function addCodeRange( $transaction, $key, $action, $lower, $upper = null ) {
 1287+ //our choices here are:
 1288+ //TODO: Move this somewhere both this function and
 1289+ //setTransactionWMFStatus can get to it.
 1290+ $statuses = array(
 1291+ 'complete',
 1292+ 'pending',
 1293+ 'pending-poke',
 1294+ 'failed',
 1295+ 'revised'
 1296+ );
 1297+ if ( !in_array( $action, $statuses ) ) {
 1298+ throw new MWException( "Transaction WMF Status $action is invalid." );
 1299+ }
12891300 if ( $upper === null ) {
12901301 $this->return_value_map[$transaction][$key][$lower] = $action;
12911302 } else {
@@ -1573,11 +1584,23 @@
15741585 * process to completion: This status being set at all, denotes the very end
15751586 * of the donation process on our end. Further attempts by the same user
15761587 * will be seen as starting over.
1577 - * @param string $status Only five strings will do anything good in the rest
1578 - * of the code so far:
1579 - * 'complete', 'pending', 'pending-poke', 'failed', 'revised'
 1588+ * @param string $status The final status of one discrete donation attempt,
 1589+ * can be one of five values: 'complete', 'pending', 'pending-poke',
 1590+ * 'failed', 'revised'
15801591 */
15811592 public function setTransactionWMFStatus( $status ) {
 1593+ //our choices here are:
 1594+ $statuses = array(
 1595+ 'complete',
 1596+ 'pending',
 1597+ 'pending-poke',
 1598+ 'failed',
 1599+ 'revised'
 1600+ );
 1601+ if ( !in_array( $status, $statuses ) ) {
 1602+ throw new MWException( "Transaction WMF Status $status is invalid." );
 1603+ }
 1604+
15821605 $this->transaction_results['WMF_STATUS'] = $status;
15831606 }
15841607
Index: trunk/extensions/DonationInterface/globalcollect_gateway/globalcollect.adapter.php
@@ -110,7 +110,7 @@
111111 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending', 300 );
112112 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'failed', 310, 350 );
113113 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'revised', 400 );
114 - $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending_poke', 525 );
 114+ $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending-poke', 525 );
115115 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'pending', 550, 650 );
116116 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'complete', 800, 975 ); //these are all post-authorized, but technically pre-settled...
117117 $this->addCodeRange( 'GET_ORDERSTATUS', 'STATUSID', 'complete', 1000, 1050 );
@@ -130,7 +130,7 @@
131131 * Allowed:
132132 * - complete
133133 * - pending
134 - * - pending_poke
 134+ * - pending-poke
135135 * - revised
136136 *
137137 * Denied:
@@ -143,7 +143,7 @@
144144 $this->goToThankYouOn = array(
145145 'complete',
146146 'pending',
147 - 'pending_poke',
 147+ 'pending-poke',
148148 'revised',
149149 );
150150 }
@@ -289,7 +289,7 @@
290290 ),
291291 'loop_for_status' => array(
292292 //'pending',
293 - 'pending_poke',
 293+ 'pending-poke',
294294 'complete',
295295 'failed',
296296 'revised',

Follow-up revisions

RevisionCommit summaryAuthorDate
r102236MFT r90286, r100671, r100837, r100950, r101060, r101063, r101064, r101073, r1......khorn03:06, 7 November 2011
r102237MFT r90286, r100671, r100837, r100950, r101060, r101063, r101064, r101073, r1......khorn03:07, 7 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97341Adds a processor-type page for the iframe to come back from, and a way to han...khorn22:02, 16 September 2011
r99036Latest round of bug fixes and additions for DonationInterface:...khorn19:52, 5 October 2011
r101959Added defineErrorMap(), Added new code range. Added defineGoToThankYouOn(). U...jpostlethwaite05:36, 4 November 2011

Status & tagging log