Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/368307 )
Change subject: Store processed payments in main cache, not session ...................................................................... Store processed payments in main cache, not session Seeing users still being redirected to failpage on reload. These users also seem to have gotten new sessions between the first ResultSwitcher hit and the second. Bug: T167990 Change-Id: I79f593fd126a2cb6d24662f770d8a7846bd4eb93 --- M gateway_common/GatewayPage.php M gateway_common/gateway.adapter.php M tests/phpunit/Adapter/PayPal/PayPalExpressTest.php M tests/phpunit/DonationInterfaceApiTestCase.php M tests/phpunit/DonationInterfaceTestCase.php M tests/phpunit/TestConfiguration.php 6 files changed, 21 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/07/368307/1 diff --git a/gateway_common/GatewayPage.php b/gateway_common/GatewayPage.php index f2061ea..634d558 100644 --- a/gateway_common/GatewayPage.php +++ b/gateway_common/GatewayPage.php @@ -589,11 +589,9 @@ $requestProcessId = $this->adapter->getRequestProcessId( $request->getValues() ); - $processedRequests = $request->getSessionData( 'processed_requests' ); - if ( !$requestProcessId || empty( $processedRequests ) ) { - return false; - } - return array_key_exists( $requestProcessId, $processedRequests ); + $key = 'processed_request-' . $requestProcessId; + $cachedResult = wfGetMainCache()->get( $key ); + return boolval( $cachedResult ); } protected function markReturnProcessed() { @@ -604,13 +602,10 @@ if ( !$requestProcessId ) { return; } - $processedRequests = $request->getSessionData( 'processed_requests' ); - if ( !$processedRequests ) { - $processedRequests = array(); - } + $key = 'processed_request-' . $requestProcessId; + // TODO: we could store the results of the last process here, but for now // we just indicate we did SOMETHING with it - $processedRequests[$requestProcessId] = true; - $request->setSessionData( 'processed_requests', $processedRequests ); + wfGetMainCache()->add( $key, true, 7200 ); } } diff --git a/gateway_common/gateway.adapter.php b/gateway_common/gateway.adapter.php index 5da2a72..8c0859d 100644 --- a/gateway_common/gateway.adapter.php +++ b/gateway_common/gateway.adapter.php @@ -2967,7 +2967,6 @@ 'PaymentForms', 'numAttempt', 'order_status', //for post-payment activities - 'processed_requests', //for post-payment activities 'sequence', ); $preservedData = array(); diff --git a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php index b13db0c..6ba90a9 100644 --- a/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php +++ b/tests/phpunit/Adapter/PayPal/PayPalExpressTest.php @@ -283,8 +283,9 @@ ); $this->verifyFormOutput( 'PaypalExpressGatewayResult', $request, $assertNodes, false, $session ); - $processed = RequestContext::getMain()->getRequest()->getSessionData( 'processed_requests' ); - $this->assertArrayHasKey( $request['token'], $processed ); + $key = 'processed_request-' . $request['token']; + $processed = wfGetMainCache()->get( $key ); + $this->assertTrue( $processed ); // Make sure we logged the expected cURL attempts $messages = self::getLogMatches( 'info', '/Preparing to send GetExpressCheckoutDetails transaction to Paypal Express Checkout/' ); @@ -303,12 +304,12 @@ $init['gateway_session_id'] = mt_rand(); $init['language'] = 'pt'; $session = array( - 'Donor' => $init, - 'processed_requests' => array( - $init['gateway_session_id'] => true - ) + 'Donor' => $init ); + $key = 'processed_request-' . $init['gateway_session_id']; + wfGetMainCache()->add( $key, true, 100 ); + $request = array( 'token' => $init['gateway_session_id'], 'PayerID' => 'ASdASDAS', diff --git a/tests/phpunit/DonationInterfaceApiTestCase.php b/tests/phpunit/DonationInterfaceApiTestCase.php index f033056..39b0c85 100644 --- a/tests/phpunit/DonationInterfaceApiTestCase.php +++ b/tests/phpunit/DonationInterfaceApiTestCase.php @@ -26,6 +26,8 @@ parent::tearDown(); Context::set( null ); TestingQueue::clearAll(); + // Clear out our HashBagOStuff + wfGetMainCache()->clear(); DonationLoggerFactory::$overrideLogger = null; } } diff --git a/tests/phpunit/DonationInterfaceTestCase.php b/tests/phpunit/DonationInterfaceTestCase.php index 7199e72..d9cddad 100644 --- a/tests/phpunit/DonationInterfaceTestCase.php +++ b/tests/phpunit/DonationInterfaceTestCase.php @@ -511,6 +511,8 @@ } // Reset SmashPig context Context::set( null ); + // Clear out our HashBagOStuff, used for testing + wfGetMainCache()->clear(); } /** diff --git a/tests/phpunit/TestConfiguration.php b/tests/phpunit/TestConfiguration.php index 30d6cb4..6d9418e 100644 --- a/tests/phpunit/TestConfiguration.php +++ b/tests/phpunit/TestConfiguration.php @@ -88,7 +88,10 @@ $wgDonationInterfaceUtmCampaignMap, $wgDonationInterfaceUtmSourceMap, $wgDonationInterfaceUtmMediumMap, - $wgDonationInterfaceEmailDomainMap; + $wgDonationInterfaceEmailDomainMap, + $wgMainCacheType; + +$wgMainCacheType = 'hash'; $wgDonationInterfaceGatewayAdapters = array( 'globalcollect'=> 'TestingGlobalCollectAdapter', -- To view, visit https://gerrit.wikimedia.org/r/368307 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I79f593fd126a2cb6d24662f770d8a7846bd4eb93 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg <ej...@ejegg.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits