Ejegg has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/355370 )
Change subject: Get rid of some more php-message-class, WmfFramework::getHostname ...................................................................... Get rid of some more php-message-class, WmfFramework::getHostname Change-Id: I08ad14a19e8d5e4d1d85facbaf38ba1d4733ff95 --- M extras/FraudFilter.php M gateway_common/GatewayType.php M gateway_common/WmfFramework.drupal.php M gateway_common/WmfFramework.mediawiki.php M gateway_common/gateway.adapter.php M tests/phpunit/DonationQueueTest.php 6 files changed, 10 insertions(+), 28 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface refs/changes/70/355370/1 diff --git a/extras/FraudFilter.php b/extras/FraudFilter.php index 9113c88..3656fb3 100644 --- a/extras/FraudFilter.php +++ b/extras/FraudFilter.php @@ -28,7 +28,6 @@ 'validation_action' => $validationAction, 'risk_score' => $totalScore, 'score_breakdown' => $scoreBreakdown, - 'php-message-class' => 'SmashPig\CrmLink\Messages\DonationInterfaceAntifraud', 'user_ip' => $this->gateway_adapter->getData_Unstaged_Escaped( 'user_ip' ), ); //If we need much more here to help combat fraud, we could just @@ -36,7 +35,7 @@ //Legal said ok... but this seems a bit excessive to me at the //moment. - $transaction = $this->gateway_adapter->makeFreeformStompTransaction( $stomp_msg ); + $transaction = $this->gateway_adapter->addStandardMessageFields( $stomp_msg ); // In the rare case that we fraud-fail before we have an order ID, use ct_id if ( empty( $transaction['order_id'] ) ) { diff --git a/gateway_common/GatewayType.php b/gateway_common/GatewayType.php index 8389b1c..b5226f9 100644 --- a/gateway_common/GatewayType.php +++ b/gateway_common/GatewayType.php @@ -345,7 +345,7 @@ * @param array $transaction The fields that we are interested in sending. * @return array The fields that will actually be sent. So, $transaction ++ some other things we think we're likely to always need. */ - public function makeFreeformStompTransaction( $transaction ); + public function addStandardMessageFields( $transaction ); /** * returns information about how to manage the Order ID diff --git a/gateway_common/WmfFramework.drupal.php b/gateway_common/WmfFramework.drupal.php index 4ddd5f8..9cb3d9f 100644 --- a/gateway_common/WmfFramework.drupal.php +++ b/gateway_common/WmfFramework.drupal.php @@ -29,10 +29,6 @@ throw new BadMethodCallException( 'Unimplemented' ); } - static function getHostname() { - return gethostname(); - } - static function formatMessage( $message_identifier ) { // TODO: Use the i18n logic in wmf_communication return $message_identifier; diff --git a/gateway_common/WmfFramework.mediawiki.php b/gateway_common/WmfFramework.mediawiki.php index 94ac1e4..73d76bf 100644 --- a/gateway_common/WmfFramework.mediawiki.php +++ b/gateway_common/WmfFramework.mediawiki.php @@ -27,10 +27,6 @@ return RequestContext::getMain()->getRequest()->getHeader( $key ); } - static function getHostname() { - return wfHostname(); - } - static function formatMessage( $message_identifier /*, ... */ ) { return call_user_func_array( 'wfMessage', func_get_args() )->text(); } diff --git a/gateway_common/gateway.adapter.php b/gateway_common/gateway.adapter.php index b9a15cd..e97430f 100644 --- a/gateway_common/gateway.adapter.php +++ b/gateway_common/gateway.adapter.php @@ -20,6 +20,7 @@ use ForceUTF8\Encoding; use MediaWiki\Session\SessionManager; use Psr\Log\LogLevel; +use SmashPig\Core\UtcDate; use Symfony\Component\Yaml\Parser; /** @@ -1823,32 +1824,23 @@ return $queueMessage; } - public function makeFreeformStompTransaction( $transaction ) { - if ( !array_key_exists( 'php-message-class', $transaction ) ) { - $this->logger->warning( "Trying to send a freeform STOMP message with no class defined. Bad programmer." ); - $transaction['php-message-class'] = 'undefined-loser-message'; - } - + public function addStandardMessageFields( $transaction ) { //bascially, add all the stuff we have come to take for granted, because syslog. - $transaction['gateway_txn_id'] = $this->getTransactionGatewayTxnID(); - $transaction['date'] = ( int ) time(); //I know this looks odd. Just trust me here. - $transaction['server'] = WmfFramework::getHostname(); // FIXME: duplicated in the source fields + $transaction['gateway_txn_id'] = + $this->transaction_response->getGatewayTransactionId(); + $transaction['date'] = UtcDate::getUtcTimestamp(); + $transaction['server'] = gethostname(); $these_too = array ( 'gateway', 'contribution_tracking_id', 'order_id', - 'payment_method', //the stomp sender gets mad if we don't have this. @TODO: Stop being lazy someday. ); foreach ( $these_too as $field ) { $transaction[$field] = $this->getData_Unstaged_Escaped( $field ); } return $transaction; - } - - protected function getCorrelationID(){ - return $this->getIdentifier() . '-' . $this->getData_Unstaged_Escaped('order_id'); } /** @@ -2078,7 +2070,6 @@ */ public function sendFinalStatusMessage( $status ) { $transaction = array( - 'php-message-class' => 'SmashPig\CrmLink\Messages\DonationInterfaceFinalStatus', 'validation_action' => $this->getValidationAction(), 'payments_final_status' => $status, ); @@ -2097,7 +2088,7 @@ $transaction[$key] = $this->getData_Unstaged_Escaped( $key ); } - $transaction = $this->makeFreeformStompTransaction( $transaction ); + $transaction = $this->addStandardMessageFields( $transaction ); try { // FIXME: Dispatch "freeform" messages transparently as well. diff --git a/tests/phpunit/DonationQueueTest.php b/tests/phpunit/DonationQueueTest.php index 6d5d453..e21be67 100644 --- a/tests/phpunit/DonationQueueTest.php +++ b/tests/phpunit/DonationQueueTest.php @@ -90,7 +90,7 @@ 'gross' => '1.24', 'user_ip' => '127.0.0.1', 'date' => (int)$this->transaction['date'], - 'source_host' => WmfFramework::getHostname(), + 'source_host' => gethostname(), 'source_name' => 'DonationInterface', 'source_run_id' => getmypid(), 'source_type' => 'payments', -- To view, visit https://gerrit.wikimedia.org/r/355370 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I08ad14a19e8d5e4d1d85facbaf38ba1d4733ff95 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DonationInterface Gerrit-Branch: master Gerrit-Owner: Ejegg <eeggles...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits