jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/338410 )
Change subject: process payment before popping out of iframe ...................................................................... process payment before popping out of iframe Bug: T153972 Change-Id: I92ef647303985f4edb3bdbeb3a1d354c3f3b9857 --- M gateway_common/GatewayPage.php M modules/iframe.liberator.js 2 files changed, 33 insertions(+), 34 deletions(-) Approvals: jenkins-bot: Verified Awight: Looks good to me, approved diff --git a/gateway_common/GatewayPage.php b/gateway_common/GatewayPage.php index f3bcb40..aeed169 100644 --- a/gateway_common/GatewayPage.php +++ b/gateway_common/GatewayPage.php @@ -117,7 +117,7 @@ if( $wgContributionTrackingFundraiserMaintenance || $wgContributionTrackingFundraiserMaintenanceUnsched ){ - $this->getOutput()->redirect( Title::newFromText('Special:FundraiserMaintenance')->getFullURL(), '302' ); + $this->redirect( Title::newFromText('Special:FundraiserMaintenance')->getFullURL(), '302' ); return; } @@ -185,6 +185,15 @@ } /** + * @param string $logReason Logged explanation for redirect + */ + protected function displayThankYouPage( $logReason ) { + $thankYouPage = ResultPages::getThankYouPage( $this->adapter ); + $this->logger->info( "Displaying thank you page $thankYouPage for status $logReason." ); + $this->redirect( $thankYouPage ); + } + + /** * Display a failure page * * @param bool $allowRapid Whether to allow rendering a RapidFail form @@ -212,8 +221,25 @@ } $log_message = "Redirecting to [{$page}]"; $this->logger->info( $log_message ); - $output->redirect( $page ); + } + + public function redirect ( $url, $responsecode = '302' ) { + // Do we need to pop out of an iframe? + if ( $this->isReturnFramed() ) { + $this->logger->info( + "Resultswitcher: Popping out of iframe for Order ID " . + $this->adapter->getData_Unstaged_Escaped( 'order_id' ) + ); + $this->getOutput()->allowClickjacking(); + $this->getOutput()->addModules( 'iframe.liberator' ); + $this->getOutput()->addJsConfigVars( + 'wgDonationInterfaceLiberationDestination', $url + ); + return; + } + // No, normal redirect. + $this->getOutput()->redirect( $url, $responsecode ); } /** @@ -373,27 +399,12 @@ $request = $this->getRequest(); $referrer = $request->getHeader( 'referer' ); - $liberated = false; - if ( $this->adapter->session_getData( 'order_status', $oid ) === 'liberated' ) { - $liberated = true; - } - - // XXX need to know whether we were in an iframe or not. - global $wgServer; - if ( $this->isReturnFramed() && ( strpos( $referrer, $wgServer ) === false ) && !$liberated ) { - $sessionOrderStatus = $request->getSessionData( 'order_status' ); - $sessionOrderStatus[$oid] = 'liberated'; - $request->setSessionData( 'order_status', $sessionOrderStatus ); - $this->logger->info( "Resultswitcher: Popping out of iframe for Order ID " . $oid ); - $this->getOutput()->allowClickjacking(); - $this->getOutput()->addModules( 'iframe.liberator' ); - return; - } $this->setHeaders(); if ( $deadSession ){ if ( $this->adapter->isReturnProcessingRequired() ) { + // FIXME: this may display inside an iframe wfHttpError( 403, 'Forbidden', wfMessage( 'donate_interface-error-http-403' )->text() ); throw new RuntimeException( 'Resultswitcher: Request forbidden. No active donation in the session. ' . @@ -418,13 +429,11 @@ $this->logger->info( "Resultswitcher: OK to process Order ID: " . $oid ); if ( $this->adapter->checkTokens() ) { - $this->getOutput()->allowClickjacking(); - // FIXME: do we really need this again? - $this->getOutput()->addModules( 'iframe.liberator' ); // feed processDonorReturn all the GET and POST vars $requestValues = $this->getRequest()->getValues(); $this->adapter->processDonorReturn( $requestValues ); $status = $this->adapter->getFinalStatus(); + switch ( $status ) { case FinalStatus::COMPLETE: case FinalStatus::PENDING: @@ -457,7 +466,7 @@ $this->displayFailPage(); } elseif ( $url = $result->getRedirect() ) { $this->adapter->logPending(); - $this->getOutput()->redirect( $url ); + $this->redirect( $url ); } elseif ( $url = $result->getIframe() ) { // Show a form containing an iframe. @@ -495,7 +504,7 @@ // Success. $thankYouPage = ResultPages::getThankYouPage( $this->adapter ); $this->logger->info( "Displaying thank you page $thankYouPage for successful PaymentResult." ); - $this->getOutput()->redirect( $thankYouPage ); + $this->redirect( $thankYouPage ); } } @@ -547,14 +556,5 @@ // TODO: Switch title according to failiness. // Maybe ask $form_obj for a title so different errors can show different titles $this->getOutput()->setPageTitle( wfMessage( 'donate_interface-make-your-donation' ) ); - } - - /** - * @param string $logReason Logged explanation for redirect - */ - protected function displayThankYouPage( $logReason ) { - $thankYouPage = ResultPages::getThankYouPage( $this->adapter ); - $this->logger->info( "Displaying thank you page $thankYouPage for status $logReason." ); - $this->getOutput()->redirect( $thankYouPage ); } } diff --git a/modules/iframe.liberator.js b/modules/iframe.liberator.js index 5d55eec..d3ed1b5 100644 --- a/modules/iframe.liberator.js +++ b/modules/iframe.liberator.js @@ -1,9 +1,8 @@ -/*global self:false */ if ( top.frames.length !== 0 ) { jQuery( document ).ready( function () { // we're going to immediately redirect. // Hide the page contents (skin, mostly) so it doesn't appear in the iframe while we're waiting for the reload. jQuery( 'body' ).children().attr( 'style', 'display:none' ); } ); - top.location = self.document.location + '&liberated=1'; + top.location = mw.config.get( 'wgDonationInterfaceLiberationDestination' ); } -- To view, visit https://gerrit.wikimedia.org/r/338410 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I92ef647303985f4edb3bdbeb3a1d354c3f3b9857 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Cdentinger <cdentin...@wikimedia.org> Gerrit-Reviewer: AndyRussG <andrew.green...@gmail.com> Gerrit-Reviewer: Awight <awi...@wikimedia.org> Gerrit-Reviewer: Cdentinger <cdentin...@wikimedia.org> Gerrit-Reviewer: Ejegg <eeggles...@wikimedia.org> Gerrit-Reviewer: Ssmith <ssm...@wikimedia.org> Gerrit-Reviewer: XenoRyet <dkozlow...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits