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 |
1 | 35 | + native |
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -205,24 +205,26 @@ |
206 | 206 | extract( $options ); |
207 | 207 | |
208 | 208 | $testData = isset( $testData ) ? $testData : false; |
| 209 | + $external_data = isset( $external_data ) ? $external_data : false; //not test data: Regular type. |
209 | 210 | $postDefaults = isset( $postDefaults ) ? $postDefaults : false; |
210 | | - |
| 211 | + |
211 | 212 | if ( !self::getGlobal( 'Test' ) ) { |
212 | 213 | $this->url = self::getGlobal( 'URL' ); |
213 | | - |
214 | 214 | // Only submit test data if we are in test mode. |
215 | | - $testData = false; |
216 | 215 | } else { |
217 | 216 | $this->url = self::getGlobal( 'TestingURL' ); |
| 217 | + if ( $testData ){ |
| 218 | + $external_data = $testData; |
| 219 | + } |
218 | 220 | } |
| 221 | + |
| 222 | + $this->dataObj = new DonationData( get_called_class(), self::getGlobal( 'Test' ), $external_data ); |
219 | 223 | |
220 | | - $this->dataObj = new DonationData( get_called_class(), self::getGlobal( 'Test' ), $testData ); |
221 | | - |
222 | 224 | $this->raw_data = $this->dataObj->getData(); |
223 | 225 | $this->staged_data = $this->raw_data; |
| 226 | + |
| 227 | + $this->posted = ( $this->dataObj->wasPosted() && ( !is_null( $wgRequest->getVal( 'numAttempt', null ) ) ) ); |
224 | 228 | |
225 | | - $this->posted = ( $wgRequest->wasPosted() && ( !is_null( $wgRequest->getVal( 'numAttempt', null ) ) ) ); |
226 | | - |
227 | 229 | $this->setPostDefaults( $postDefaults ); |
228 | 230 | $this->defineTransactions(); |
229 | 231 | $this->defineErrorMap(); |
Index: trunk/extensions/DonationInterface/gateway_common/DonationData.php |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | 'iban' => $wgRequest->getText( 'iban', null ), |
103 | 103 | 'transaction_type' => $wgRequest->getText( 'transaction_type', null ), |
104 | 104 | ); |
105 | | - if ( !$wgRequest->wasPosted() ) { |
| 105 | + if ( !$this->wasPosted() ) { |
106 | 106 | $this->setVal( 'posted', false ); |
107 | 107 | } |
108 | 108 | } |
— | — | @@ -666,7 +666,7 @@ |
667 | 667 | static $match = null; |
668 | 668 | |
669 | 669 | if ( $match === null ) { |
670 | | - if ( $this->isCaching() ){ |
| 670 | + if ( $this->isCaching() ){ |
671 | 671 | //This makes sense. |
672 | 672 | //If all three conditions for caching are currently true, the |
673 | 673 | //last thing we want to do is screw it up by setting a session |
— | — | @@ -1023,6 +1023,23 @@ |
1024 | 1024 | ); |
1025 | 1025 | return $stomp_fields; |
1026 | 1026 | } |
| 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 | + } |
1027 | 1044 | } |
1028 | 1045 | |
1029 | 1046 | ?> |