r77511 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77510‎ | r77511 | r77512 >
Date:22:40, 30 November 2010
Author:awjrichards
Status:ok
Tags:
Comment:
Updated all wfDebugLog uses in gateway code and related extensions to optionally use syslog as the logging facility
Modified paths:
  • /trunk/extensions/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha-php/recaptchalib.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php (modified) (history)
  • /trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.body.php
@@ -110,7 +110,7 @@
111111
112112 // make a log entry if the user has submitted the cc form
113113 if ( $wgRequest->wasPosted() && $wgRequest->getText( 'process', 0 )) {
114 - wfDebugLog( 'payflowpro_gateway', $payflow_data[ 'order_id' ] . " Transaction initiated." );
 114+ self::log( $payflow_data[ 'order_id' ] . " Transaction initiated." );
115115 }
116116
117117 // if _cache_ is requested by the user, do not set a session/token; dynamic data will be loaded via ajax
@@ -163,9 +163,9 @@
164164 $this->fnPayflowDisplayForm( $data, $this->errors );
165165 } else { // The submitted form data is valid, so process it
166166 // allow any external validators to have their way with the data
167 - wfDebugLog( 'payflowpro_gateway', $data[ 'order_id' ] . " Preparing to query MaxMind" );
 167+ self::log( $data[ 'order_id' ] . " Preparing to query MaxMind" );
168168 wfRunHooks( 'PayflowGatewayValidate', array( &$this, &$data ) );
169 - wfDebugLog( 'payflowpro_gateway', $data[ 'order_id' ] . ' Finished querying Maxmind' );
 169+ self::log( $data[ 'order_id' ] . ' Finished querying Maxmind' );
170170
171171 // if the transaction was flagged for review
172172 if ( $this->action == 'review' ) {
@@ -227,7 +227,7 @@
228228 $tracked = $this->fnPayflowSaveContributionTracking( $data );
229229 if ( !$tracked ) {
230230 $when = time();
231 - wfDebugLog( 'payflowpro_gateway', $data[ 'order_id' ] . ' Unable to save data to the contribution_tracking table ' . $when );
 231+ self::log( $data[ 'order_id' ] . ' Unable to save data to the contribution_tracking table ' . $when );
232232 }
233233 }
234234
@@ -454,15 +454,15 @@
455455 $i = 1;
456456
457457 while ( $i++ <= 3 ) {
458 - wfDebugLog( 'payflowpro_gateway', $data[ 'order_id' ] . ' Preparing to send transaction to PayflowPro' );
 458+ self::log( $data[ 'order_id' ] . ' Preparing to send transaction to PayflowPro' );
459459 $result = curl_exec( $ch );
460460 $headers = curl_getinfo( $ch );
461461
462462 if ( $headers['http_code'] != 200 && $headers['http_code'] != 403 ) {
463 - wfDebugLog( 'payflowpro_gateway', $data[ 'order_id' ] . ' Failed sending transaction to PayflowPro, retrying' );
 463+ self::log( $data[ 'order_id' ] . ' Failed sending transaction to PayflowPro, retrying' );
464464 sleep( 1 );
465465 } elseif ( $headers['http_code'] == 200 || $headers['http_code'] == 403 ) {
466 - wfDebugLog( 'payflowpro_gateway', $data[ 'order_id' ] . ' Finished sending transaction to PayflowPro' );
 466+ self::log( $data[ 'order_id' ] . ' Finished sending transaction to PayflowPro' );
467467 break;
468468 }
469469 }
@@ -470,7 +470,7 @@
471471 if ( $headers['http_code'] != 200 ) {
472472 $wgOut->addHTML( '<h3>No response from credit card processor. Please try again later!</h3><p>' );
473473 $when = time();
474 - wfDebugLog( 'payflowpro_gateway', $data[ 'order_id' ] . ' No response from credit card processor: ' . curl_error( $ch ));
 474+ self::log( $data[ 'order_id' ] . ' No response from credit card processor: ' . curl_error( $ch ) );
475475 curl_close( $ch );
476476 return;
477477 }
@@ -523,7 +523,7 @@
524524 $errorCode = $this->fnPayflowGetResponseMsg( $resultCode, $responseMsg );
525525
526526 // log that the transaction is essentially complete
527 - wfDebugLog( 'payflowpro_gateway', $data[ 'order_id' ] . " Transaction complete." );
 527+ self::log( $data[ 'order_id' ] . " Transaction complete." );
528528
529529 // if approved, display results and send transaction to the queue
530530 if ( $errorCode == '1' ) {
@@ -1261,4 +1261,19 @@
12621262 // submit the data to the paypal redirect URL
12631263 $wgOut->redirect( $wgPayflowGatewayPaypalURL . '&' . http_build_query( $data ) );
12641264 }
 1265+
 1266+ public static function log( $msg, $identifier='payflowpro_gateway', $log_level=LOG_INFO ) {
 1267+ global $wgPayflowGatewayUseSyslog;
 1268+
 1269+ // if we're not using the syslog facility, use wfDebugLog
 1270+ if ( !$wgPayflowGatewayUseSyslog ) {
 1271+ wfDebugLog( $identifier, $msg );
 1272+ return;
 1273+ }
 1274+
 1275+ // otherwise, use syslogging
 1276+ openlog( $identifier, LOG_ODELAY, LOG_SYSLOG );
 1277+ syslog( $log_level, $msg );
 1278+ closelog();
 1279+ }
12651280 } // end class
Index: trunk/extensions/DonationInterface/payflowpro_gateway/extras/recaptcha/recaptcha-php/recaptchalib.php
@@ -125,7 +125,7 @@
126126
127127 $response = '';
128128 if ( false == ( $fs = @fsockopen( $host, $port, $errno, $errstr, 10 ) ) ) {
129 - wfDebugLog( 'payflowpro_gateway', 'Failed communicating with reCaptcha.' );
 129+ PayflowProGateway::log( 'Failed communicating with reCaptcha.' );
130130 die ( 'Could not open socket' );
131131 }
132132
@@ -160,18 +160,18 @@
161161
162162 // set proxy settings if necessary
163163 if ( RECAPTCHA_USE_HTTP_PROXY ) {
164 - wfDebugLog( 'payflowpro_gateway', 'Using http proxy ' . RECAPTCHA_HTTP_PROXY );
 164+ PayflowProGateway::log( 'Using http proxy ' . RECAPTCHA_HTTP_PROXY );
165165 curl_setopt( $ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP );
166166 curl_setopt( $ch, CURLOPT_PROXY, RECAPTCHA_HTTP_PROXY );
167167 }
168168
169169 // try up to three times
170170 for ( $i = 0; $i < RECAPTCHA_RETRY_LIMIT; $i++ ) {
171 - wfDebugLog( 'payflowpro_gateway', 'Preparing to communicate with reCaptcha via cURL at ' . $url . '.' );
 171+ PayflowProGateway::log( 'Preparing to communicate with reCaptcha via cURL at ' . $url . '.' );
172172 $response = curl_exec( $ch );
173 - wfDebugLog( 'payflowpro_gateway', "Finished communicating with reCaptcha." );
 173+ PayflowProGateway::log( "Finished communicating with reCaptcha." );
174174 if ( $response ) {
175 - wfDebugLog( 'payflowpro_gateway', 'Response from reCaptcha: ' . $response );
 175+ PayflowProGateway::log( 'Response from reCaptcha: ' . $response )
176176 break;
177177 }
178178 }
@@ -186,7 +186,7 @@
187187 * the user entered the correct values.
188188 */
189189 if ( !$response ) {
190 - wfDebugLog( 'payflowpro_gateway', 'Failed communicating with reCaptcha: ' . curl_error( $ch ) );
 190+ PayflowProGateway::log( 'Failed communicating with reCaptcha: ' . curl_error( $ch ) );
191191 $response = "true\r\n\r\nsuccess";
192192 }
193193
Index: trunk/extensions/DonationInterface/payflowpro_gateway/payflowpro_gateway.php
@@ -139,6 +139,13 @@
140140 $wgPayflowAllowedHtmlForms = array( $wgPayflowHtmlFormDir . "/demo.html" );
141141
142142 /**
 143+ * Configure PayflowproGateway to use syslog for log messages rather than wfDebugLog
 144+ *
 145+ * @var bool
 146+ */
 147+$wgPayflowGatewayUseSyslog = false;
 148+
 149+/**
143150 * Hooks required to interface with the donation extension (include <donate> on page)
144151 *
145152 * gwValue supplies the value of the form option, the name that appears on the form

Follow-up revisions

RevisionCommit summaryAuthorDate
r77805Follow up r77511. Missing ;...platonides15:14, 5 December 2010
r96109MFT r77511, r77805, r90286awjrichards15:53, 2 September 2011

Status & tagging log