https://www.mediawiki.org/wiki/Special:Code/MediaWiki/102134
Revision: 102134
Author: khorn
Date: 2011-11-06 00:41:15 +0000 (Sun, 06 Nov 2011)
Log Message:
-----------
Adds the ability to log out out communication stats, through the regular
logging functions.
Modified Paths:
--------------
trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
Modified: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
===================================================================
--- trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
2011-11-06 00:29:54 UTC (rev 102133)
+++ trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php
2011-11-06 00:41:15 UTC (rev 102134)
@@ -1242,25 +1242,46 @@
* @param type $vars
*/
function saveCommunicationStats( $function = '', $additional = '',
$vars = '' ) {
- $params = array();
- if ( self::getGlobal( 'SaveCommStats' ) ) {
+ static $saveStats = null;
+ static $saveDB = null;
+
+ if ( $saveStats === null ){
+ $saveStats = self::getGlobal( 'SaveCommStats' );
+ }
+
+ if ( !$saveStats ){
+ return;
+ }
+
+ if ( $saveDB === null ){
$db =
ContributionTrackingProcessor::contributionTrackingConnection();
-
- //TODO: Actually define this table somewhere in the
code, once we
- //are reasonably certain we know what we want to see in
it.
- if ( !( $db->tableExists( 'communication_stats' ) ) ) {
- return;
+ if ( $db->tableExists( 'communication_stats' ) ) {
+ $saveDB = true;
+ } else {
+ $saveDB = false;
}
-
- $params['contribution_id'] = $this->dataObj->getVal(
'contribution_tracking_id' );
+ }
+
+ $params = array(
+ 'contribution_id' => $this->dataObj->getVal(
'contribution_tracking_id' ),
+ 'duration' => $this->getStopwatch( $function ),
+ 'gateway' => self::getGatewayName(),
+ 'function' => $function,
+ 'vars' => $vars,
+ 'additional' => $additional,
+ );
+
+ if ( $saveDB ){
+ $db =
ContributionTrackingProcessor::contributionTrackingConnection();
$params['ts'] = $db->timestamp();
- $params['duration'] = $this->getStopwatch( __FUNCTION__
);
- $params['gateway'] = self::getGatewayName();
- $params['function'] = $function;
- $params['vars'] = $vars;
- $params['additional'] = $additional;
-
$db->insert( 'communication_stats', $params );
+ } else {
+ //save to syslog. But which syslog?
+ $msg = '';
+ foreach ($params as $key=>$val){
+ $msg .= "$key:$val - ";
+ }
+ self::log($msg, LOG_INFO, '_commstats');
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs