Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -1242,25 +1242,46 @@ |
1243 | 1243 | * @param type $vars |
1244 | 1244 | */ |
1245 | 1245 | function saveCommunicationStats( $function = '', $additional = '', $vars = '' ) { |
1246 | | - $params = array(); |
1247 | | - if ( self::getGlobal( 'SaveCommStats' ) ) { |
| 1246 | + static $saveStats = null; |
| 1247 | + static $saveDB = null; |
| 1248 | + |
| 1249 | + if ( $saveStats === null ){ |
| 1250 | + $saveStats = self::getGlobal( 'SaveCommStats' ); |
| 1251 | + } |
| 1252 | + |
| 1253 | + if ( !$saveStats ){ |
| 1254 | + return; |
| 1255 | + } |
| 1256 | + |
| 1257 | + if ( $saveDB === null ){ |
1248 | 1258 | $db = ContributionTrackingProcessor::contributionTrackingConnection(); |
1249 | | - |
1250 | | - //TODO: Actually define this table somewhere in the code, once we |
1251 | | - //are reasonably certain we know what we want to see in it. |
1252 | | - if ( !( $db->tableExists( 'communication_stats' ) ) ) { |
1253 | | - return; |
| 1259 | + if ( $db->tableExists( 'communication_stats' ) ) { |
| 1260 | + $saveDB = true; |
| 1261 | + } else { |
| 1262 | + $saveDB = false; |
1254 | 1263 | } |
1255 | | - |
1256 | | - $params['contribution_id'] = $this->dataObj->getVal( 'contribution_tracking_id' ); |
| 1264 | + } |
| 1265 | + |
| 1266 | + $params = array( |
| 1267 | + 'contribution_id' => $this->dataObj->getVal( 'contribution_tracking_id' ), |
| 1268 | + 'duration' => $this->getStopwatch( $function ), |
| 1269 | + 'gateway' => self::getGatewayName(), |
| 1270 | + 'function' => $function, |
| 1271 | + 'vars' => $vars, |
| 1272 | + 'additional' => $additional, |
| 1273 | + ); |
| 1274 | + |
| 1275 | + if ( $saveDB ){ |
| 1276 | + $db = ContributionTrackingProcessor::contributionTrackingConnection(); |
1257 | 1277 | $params['ts'] = $db->timestamp(); |
1258 | | - $params['duration'] = $this->getStopwatch( __FUNCTION__ ); |
1259 | | - $params['gateway'] = self::getGatewayName(); |
1260 | | - $params['function'] = $function; |
1261 | | - $params['vars'] = $vars; |
1262 | | - $params['additional'] = $additional; |
1263 | | - |
1264 | 1278 | $db->insert( 'communication_stats', $params ); |
| 1279 | + } else { |
| 1280 | + //save to syslog. But which syslog? |
| 1281 | + $msg = ''; |
| 1282 | + foreach ($params as $key=>$val){ |
| 1283 | + $msg .= "$key:$val - "; |
| 1284 | + } |
| 1285 | + self::log($msg, LOG_INFO, '_commstats'); |
1265 | 1286 | } |
1266 | 1287 | } |
1267 | 1288 | |