r103024 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103023‎ | r103024 | r103025 >
Date:20:43, 14 November 2011
Author:khorn
Status:ok
Tags:
Comment:
Preliminary steps toward a command-line solution for finding donations which were completed on GlobalCollect's hosted credit card form, but that never came back to us to finish up the final processing.
At his point, it mostly just demonstrates that our gateway object can be instantiated from the command line without blowing up.
Modified paths:
  • /trunk/extensions/DonationInterface/gateway_common/DonationData.php (modified) (history)
  • /trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php (modified) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/scripts (added) (history)
  • /trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php (added) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php
@@ -0,0 +1,33 @@
 2+<?php
 3+
 4+//TODO: Something that is not specific to anybody's install, here.
 5+global $IP;
 6+if ( !isset($IP) ) {
 7+ $IP = '/var/www/wikimedia-dev';
 8+}
 9+require_once( "$IP/maintenance/Maintenance.php" );
 10+
 11+class GlobalCollectOrphanRectifier extends Maintenance {
 12+ function execute(){
 13+
 14+ //load in and chunk the list of XML. Phase 1: From a file
 15+
 16+ //for each chunk, load it into a GC adapter, and have it parse as if it were a response.
 17+
 18+ //load that response into DonationData, and run the thing that completes the transaction,
 19+ //as if we were coming from resultSwitcher.
 20+ //(Note: This should only work if we're sitting at one of the designated statuses)
 21+
 22+ $data = array(
 23+ 'test' => 'something',
 24+ 'othertest' => 'otherthing'
 25+ );
 26+
 27+ $adapter = new GlobalCollectAdapter(array('external_data' => $data));
 28+ }
 29+}
 30+
 31+
 32+
 33+$maintClass = "GlobalCollectOrphanRectifier";
 34+require_once( "$IP/maintenance/doMaintenance.php" );
Property changes on: trunk/extensions/DonationInterface/globalcollect_gateway/scripts/orphans.php
___________________________________________________________________
Added: svn:eol-style
135 + native
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
@@ -205,24 +205,26 @@
206206 extract( $options );
207207
208208 $testData = isset( $testData ) ? $testData : false;
 209+ $external_data = isset( $external_data ) ? $external_data : false; //not test data: Regular type.
209210 $postDefaults = isset( $postDefaults ) ? $postDefaults : false;
210 -
 211+
211212 if ( !self::getGlobal( 'Test' ) ) {
212213 $this->url = self::getGlobal( 'URL' );
213 -
214214 // Only submit test data if we are in test mode.
215 - $testData = false;
216215 } else {
217216 $this->url = self::getGlobal( 'TestingURL' );
 217+ if ( $testData ){
 218+ $external_data = $testData;
 219+ }
218220 }
 221+
 222+ $this->dataObj = new DonationData( get_called_class(), self::getGlobal( 'Test' ), $external_data );
219223
220 - $this->dataObj = new DonationData( get_called_class(), self::getGlobal( 'Test' ), $testData );
221 -
222224 $this->raw_data = $this->dataObj->getData();
223225 $this->staged_data = $this->raw_data;
 226+
 227+ $this->posted = ( $this->dataObj->wasPosted() && ( !is_null( $wgRequest->getVal( 'numAttempt', null ) ) ) );
224228
225 - $this->posted = ( $wgRequest->wasPosted() && ( !is_null( $wgRequest->getVal( 'numAttempt', null ) ) ) );
226 -
227229 $this->setPostDefaults( $postDefaults );
228230 $this->defineTransactions();
229231 $this->defineErrorMap();
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php
@@ -101,7 +101,7 @@
102102 'iban' => $wgRequest->getText( 'iban', null ),
103103 'transaction_type' => $wgRequest->getText( 'transaction_type', null ),
104104 );
105 - if ( !$wgRequest->wasPosted() ) {
 105+ if ( !$this->wasPosted() ) {
106106 $this->setVal( 'posted', false );
107107 }
108108 }
@@ -666,7 +666,7 @@
667667 static $match = null;
668668
669669 if ( $match === null ) {
670 - if ( $this->isCaching() ){
 670+ if ( $this->isCaching() ){
671671 //This makes sense.
672672 //If all three conditions for caching are currently true, the
673673 //last thing we want to do is screw it up by setting a session
@@ -1023,6 +1023,23 @@
10241024 );
10251025 return $stomp_fields;
10261026 }
 1027+
 1028+ /**
 1029+ * Basically, this is a wrapper for the $wgRequest wasPosted function that
 1030+ * won't give us notices if we weren't even a web request.
 1031+ * I realize this is pretty lame.
 1032+ * Notices, however, are more lame.
 1033+ * @global type $wgRequest
 1034+ * @staticvar string $posted Keeps track so we don't have to figure it out twice.
 1035+ */
 1036+ public function wasPosted(){
 1037+ global $wgRequest;
 1038+ static $posted = null;
 1039+ if ($posted === null){
 1040+ $posted = (array_key_exists('REQUEST_METHOD', $_SERVER) && $wgRequest->wasPosted());
 1041+ }
 1042+ return $posted;
 1043+ }
10271044 }
10281045
10291046 ?>

Follow-up revisions

RevisionCommit summaryAuthorDate
r103512MFT r103506, r103501, r103499, r103491, r103416, r103385, r103288, r103246, r...khorn21:54, 17 November 2011
r103513MFT r103506, r103501, r103499, r103491, r103416, r103385, r103288, r103246, r...khorn21:57, 17 November 2011
r103847MFT r102338, r102681, r102685, r102810, r102828, r102829, r102832, r102836, r...khorn22:30, 21 November 2011
r103848MFT r102338, r102681, r102685, r102810, r102828, r102829, r102832, r102836, r...khorn22:31, 21 November 2011

Status & tagging log