jenkins-bot has submitted this change and it was merged. Change subject: Consolidate slayer logging; general cleanups ......................................................................
Consolidate slayer logging; general cleanups Wrap all echoing in a function that mirrors to console or cron, and to syslog. Bug: T107851 Change-Id: I87ad394c637827562c162c1728cf2e0231ba0708 --- M DonationInterface.php M gateway_common/gateway.adapter.php M globalcollect_gateway/globalcollect.adapter.php R globalcollect_gateway/scripts/orphan.adapter.php M globalcollect_gateway/scripts/orphans.php 5 files changed, 29 insertions(+), 20 deletions(-) Approvals: XenoRyet: Looks good to me, approved jenkins-bot: Verified diff --git a/DonationInterface.php b/DonationInterface.php index 7ee05f4..388c2d5 100644 --- a/DonationInterface.php +++ b/DonationInterface.php @@ -74,7 +74,7 @@ $wgAutoloadClasses['GlobalCollectGatewayResult'] = __DIR__ . '/globalcollect_gateway/globalcollect_resultswitcher.body.php'; $wgAutoloadClasses['GlobalCollectAdapter'] = __DIR__ . '/globalcollect_gateway/globalcollect.adapter.php'; -$wgAutoloadClasses['GlobalCollectOrphanAdapter'] = __DIR__ . '/globalcollect_gateway/scripts/orphan_adapter.php'; +$wgAutoloadClasses['GlobalCollectOrphanAdapter'] = __DIR__ . '/globalcollect_gateway/scripts/orphan.adapter.php'; $wgAutoloadClasses['GlobalCollectOrphanRectifier'] = __DIR__ . '/globalcollect_gateway/scripts/orphans.php'; // Amazon @@ -249,8 +249,9 @@ ); //GlobalCollect gateway globals +$wgGlobalCollectGatewayTestingURL = 'https://ps.gcsip.nl/wdl/wdl'; +// Actually it's ps.gcsip.com, but trust me it's better this way. $wgGlobalCollectGatewayURL = 'https://ps.gcsip.nl/wdl/wdl'; -$wgGlobalCollectGatewayTestingURL = 'https://'; // GlobalCollect testing URL # $wgGlobalCollectGatewayAccountInfo['example'] = array( # 'MerchantID' => '', // GlobalCollect ID diff --git a/gateway_common/gateway.adapter.php b/gateway_common/gateway.adapter.php index 5487289..ee98e3d 100644 --- a/gateway_common/gateway.adapter.php +++ b/gateway_common/gateway.adapter.php @@ -1539,11 +1539,10 @@ } /** - * This is only public for the orphan script. * Harvest the data we need back from the gateway. * @return array a key/value array */ - public function parseResponseData( $response ) { + protected function parseResponseData( $response ) { return array(); } diff --git a/globalcollect_gateway/globalcollect.adapter.php b/globalcollect_gateway/globalcollect.adapter.php index 2926ee4..75085df 100644 --- a/globalcollect_gateway/globalcollect.adapter.php +++ b/globalcollect_gateway/globalcollect.adapter.php @@ -1180,6 +1180,9 @@ /** * Either confirm or reject the payment + * + * FIXME: This function is way too complex. Unroll into new functions. + * * @global WebRequest $wgRequest * @return PaymentTransactionResponse */ diff --git a/globalcollect_gateway/scripts/orphan_adapter.php b/globalcollect_gateway/scripts/orphan.adapter.php similarity index 100% rename from globalcollect_gateway/scripts/orphan_adapter.php rename to globalcollect_gateway/scripts/orphan.adapter.php diff --git a/globalcollect_gateway/scripts/orphans.php b/globalcollect_gateway/scripts/orphans.php index 3ba8252..292dcf3 100644 --- a/globalcollect_gateway/scripts/orphans.php +++ b/globalcollect_gateway/scripts/orphans.php @@ -1,8 +1,6 @@ <?php //actually, as a maintenance script, this totally is a valid entry point. - -//If you want to use this script, you will have to add the following line to LocalSettings.php: -//$wgAutoloadClasses['GlobalCollectOrphanAdapter'] = $IP . '/extensions/DonationInterface/globalcollect_gateway/scripts/orphan_adapter.php'; +// FIXME: Prevent web access even if the security is misconfigured so this is runnable. $IP = getenv( 'MW_INSTALL_PATH' ); if ( $IP === false ) { @@ -30,7 +28,7 @@ $wgDonationInterfaceEnableIPVelocityFilter = false; if ( !$this->getOrphanGlobal( 'enable' ) ){ - echo "\nOrphan cron disabled. Have a nice day."; + $this->info( 'Orphan cron disabled. Have a nice day!' ); return; } @@ -64,7 +62,7 @@ */ protected function getProcessElapsed(){ $elapsed = time() - $this->start_time; - echo "Elapsed Time: $elapsed\n"; + $this->info( "Elapsed Time: {$elapsed}" ); return $elapsed; } @@ -83,7 +81,7 @@ $queue_pool = new CyclicalArray( GlobalCollectAdapter::GC_CC_LIMBO_QUEUE ); } - echo "Slaying orphans...\n"; + $this->info( "Slaying orphans..." ); $this->start_time = time(); //I want to be clear on the problem I hope to prevent with this. Say, @@ -100,7 +98,7 @@ $message = DonationQueue::instance()->peek( $current_queue ); if ( !$message ) { - $this->logger->info( "Emptied queue [{$current_queue}], removing from pool." ); + $this->info( "Emptied queue [{$current_queue}], removing from pool." ); $queue_pool->dropCurrent(); continue; } @@ -118,7 +116,7 @@ // chronological order. $elapsed = $this->start_time - $message['date']; if ( $elapsed < $time_buffer ) { - $this->logger->info( "Exhausted new messages in [{$current_queue}], removing from pool..." ); + $this->info( "Exhausted new messages in [{$current_queue}], removing from pool..." ); $queue_pool->dropCurrent(); continue; @@ -138,7 +136,7 @@ $queue_pool->rotate(); } catch ( ConnectionException $ex ) { // Drop this server, for the duration of this batch. - $this->logger->error( "Queue server for [$current_queue] is down! Ignoring for this run..." ); + $this->error( "Queue server for [$current_queue] is down! Ignoring for this run..." ); $queue_pool->dropCurrent(); } } @@ -165,8 +163,7 @@ } } $final .= "\n Approximately " . $this->getProcessElapsed() . " seconds to execute.\n"; - $this->logger->info( $final ); - echo $final; + $this->info( $final ); } /** @@ -179,18 +176,17 @@ protected function rectifyOrphan( $data, $query_contribution_tracking = true ){ $data['order_id'] = $data['gateway_txn_id']; - $this->logger->info( "Rectifying orphan: {$data['order_id']}" ); - echo 'Rectifying Orphan ' . $data['order_id'] . "\n"; + $this->info( "Rectifying orphan: {$data['order_id']}" ); $rectified = false; $this->adapter->loadDataAndReInit( $data, $query_contribution_tracking ); $results = $this->adapter->do_transaction( 'Confirm_CreditCard' ); $message = $results->getMessage(); if ( $results->getCommunicationStatus() ){ - $this->logger->info( $data['contribution_tracking_id'] . ": FINAL: " . $this->adapter->getValidationAction() ); + $this->info( $data['contribution_tracking_id'] . ": FINAL: " . $this->adapter->getValidationAction() ); $rectified = true; } else { - $this->logger->info( $data['contribution_tracking_id'] . ": ERROR: " . $message ); + $this->info( $data['contribution_tracking_id'] . ": ERROR: " . $message ); if ( strpos( $message, "GET_ORDERSTATUS reports that the payment is already complete." ) === 0 ){ $rectified = true; } @@ -207,7 +203,7 @@ } } - echo $message . "\n"; + $this->info( $message ); return $rectified; } @@ -226,6 +222,16 @@ return NULL; } } + + protected function info( $msg ) { + $this->logger->info( $msg ); + print( "{$msg}\n" ); + } + + protected function error( $msg ) { + $this->logger->error( $msg ); + error_log( $msg ); + } } $maintClass = 'GlobalCollectOrphanRectifier'; -- To view, visit https://gerrit.wikimedia.org/r/232906 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I87ad394c637827562c162c1728cf2e0231ba0708 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Awight <[email protected]> Gerrit-Reviewer: AndyRussG <[email protected]> Gerrit-Reviewer: Cdentinger <[email protected]> Gerrit-Reviewer: Ejegg <[email protected]> Gerrit-Reviewer: Katie Horn <[email protected]> Gerrit-Reviewer: Ssmith <[email protected]> Gerrit-Reviewer: XenoRyet <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
