jenkins-bot has submitted this change and it was merged. Change subject: Fix unstaging issue ......................................................................
Fix unstaging issue We can copy the newly unstaged data into the normalized DonationData, but we should not also merge the other staged data. Bug: T94506 Change-Id: I5c7c528e9a5183ac3451a2ff81a04fb97a91be1e --- M gateway_common/gateway.adapter.php M globalcollect_gateway/globalcollect.adapter.php M tests/Adapter/GlobalCollect/GlobalCollectTest.php 3 files changed, 36 insertions(+), 5 deletions(-) Approvals: Ejegg: Looks good to me, approved Awight: Looks good to me, approved jenkins-bot: Verified diff --git a/gateway_common/gateway.adapter.php b/gateway_common/gateway.adapter.php index 7da1270..1376733 100644 --- a/gateway_common/gateway.adapter.php +++ b/gateway_common/gateway.adapter.php @@ -603,7 +603,14 @@ $this->unstageData(); - $this->dataObj->addData( $this->unstaged_data ); + // Only copy the affected values back into the normalized data. + $newlyUnstagedData = array(); + foreach ( $dataArray as $key => $stagedValue ) { + if ( array_key_exists( $key, $this->unstaged_data ) ) { + $newlyUnstagedData[$key] = $this->unstaged_data[$key]; + } + } + $this->dataObj->addData( $newlyUnstagedData ); } /** diff --git a/globalcollect_gateway/globalcollect.adapter.php b/globalcollect_gateway/globalcollect.adapter.php index 4b18945..ec55261 100644 --- a/globalcollect_gateway/globalcollect.adapter.php +++ b/globalcollect_gateway/globalcollect.adapter.php @@ -1158,6 +1158,7 @@ 'CVVRESULT' => 'cvv_result', 'AVSRESULT' => 'avs_result', ); + // FIXME: Refactor as normal unstaging. $qsResults = array(); foreach ( $pull_vars as $theirkey => $ourkey) { $tmp = $wgRequest->getVal( $theirkey, null ); @@ -1205,6 +1206,7 @@ // live users get antifraud hooks run in this txn's pre-process $ran_hooks = true; } + // FIXME: Refactor as normal unstaging. $xmlResults = array( 'cvv_result' => '', 'avs_result' => '' @@ -1330,6 +1332,7 @@ //confirm or cancel the payment based on $cancelflag if ( !$problemflag ){ if ( isset( $status_result['data'] ) && is_array( $status_result['data'] ) ){ + // FIXME: Refactor as normal unstaging. //if they're set, get CVVRESULT && AVSRESULT $pull_vars['EFFORTID'] = 'effort_id'; $pull_vars['ATTEMPTID'] = 'attempt_id'; @@ -2428,5 +2431,4 @@ return false; } } - } diff --git a/tests/Adapter/GlobalCollect/GlobalCollectTest.php b/tests/Adapter/GlobalCollect/GlobalCollectTest.php index 4cb8953..d0d4159 100644 --- a/tests/Adapter/GlobalCollect/GlobalCollectTest.php +++ b/tests/Adapter/GlobalCollect/GlobalCollectTest.php @@ -325,7 +325,7 @@ $this->assertEquals( $gateway->_getData_Staged( 'language' ), 'no', "'NO' donor's language was inproperly set. Should be 'no'" ); } - public function testLanguageFallback() { + public function testLanguageFallbackStaging() { $options = $this->getDonorTestData( 'Catalonia' ); $options['payment_method'] = 'cc'; $options['payment_submethod'] = 'visa'; @@ -335,9 +335,31 @@ // Requesting the fallback language from the gateway. $this->assertEquals( 'en', $gateway->_getData_Staged( 'language' ) ); + } - // Preferred language is not damaged by side effects. - $this->assertEquals( 'ca', $gateway->getData_Unstaged_Escaped( 'language' ) ); + /** + * Make sure unstaging functions don't overwrite core donor data. + */ + public function testAddResponseData_underzealous() { + $options = $this->getDonorTestData( 'Catalonia' ); + $options['payment_method'] = 'cc'; + $options['payment_submethod'] = 'visa'; + $gateway = $this->getFreshGatewayObject( $options ); + + // This will set staged_data['language'] = 'en'. + $gateway->_stageData(); + + $ctid = mt_rand(); + + $gateway->addResponseData( array( + 'contribution_tracking_id' => $ctid . '.1', + ) ); + + // Desired vars were written into normalized data. + $this->assertEquals( $ctid, $gateway->getDonationData()->getVal_Escaped( 'contribution_tracking_id' ) ); + + // Language was not overwritten. + $this->assertEquals( 'ca', $gateway->getDonationData()->getVal_Escaped( 'language' ) ); } /** -- To view, visit https://gerrit.wikimedia.org/r/201382 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5c7c528e9a5183ac3451a2ff81a04fb97a91be1e Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Awight <awi...@wikimedia.org> Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com> Gerrit-Reviewer: Awight <awi...@wikimedia.org> Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org> Gerrit-Reviewer: Katie Horn <kh...@wikimedia.org> Gerrit-Reviewer: Ssmith <ssm...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits