Index: trunk/phase3/includes/GlobalFunctions.php |
— | — | @@ -1201,6 +1201,57 @@ |
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | /** |
| 1205 | + * Increment a statistics counter |
| 1206 | + * |
| 1207 | + * @param $key String |
| 1208 | + * @param $count Int |
| 1209 | + */ |
| 1210 | +function wfIncrStats( $key, $count = 1 ) { |
| 1211 | + global $wgStatsMethod; |
| 1212 | + |
| 1213 | + $count = intval( $count ); |
| 1214 | + |
| 1215 | + if( $wgStatsMethod == 'udp' ) { |
| 1216 | + global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname, $wgAggregateStatsID; |
| 1217 | + static $socket; |
| 1218 | + |
| 1219 | + $id = $wgAggregateStatsID !== false ? $wgAggregateStatsID : $wgDBname; |
| 1220 | + |
| 1221 | + if ( !$socket ) { |
| 1222 | + $socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); |
| 1223 | + $statline = "stats/{$id} - 1 1 1 1 1 -total\n"; |
| 1224 | + socket_sendto( |
| 1225 | + $socket, |
| 1226 | + $statline, |
| 1227 | + strlen( $statline ), |
| 1228 | + 0, |
| 1229 | + $wgUDPProfilerHost, |
| 1230 | + $wgUDPProfilerPort |
| 1231 | + ); |
| 1232 | + } |
| 1233 | + $statline = "stats/{$id} - {$count} 1 1 1 1 {$key}\n"; |
| 1234 | + wfSuppressWarnings(); |
| 1235 | + socket_sendto( |
| 1236 | + $socket, |
| 1237 | + $statline, |
| 1238 | + strlen( $statline ), |
| 1239 | + 0, |
| 1240 | + $wgUDPProfilerHost, |
| 1241 | + $wgUDPProfilerPort |
| 1242 | + ); |
| 1243 | + wfRestoreWarnings(); |
| 1244 | + } elseif( $wgStatsMethod == 'cache' ) { |
| 1245 | + global $wgMemc; |
| 1246 | + $key = wfMemcKey( 'stats', $key ); |
| 1247 | + if ( is_null( $wgMemc->incr( $key, $count ) ) ) { |
| 1248 | + $wgMemc->add( $key, $count ); |
| 1249 | + } |
| 1250 | + } else { |
| 1251 | + // Disabled |
| 1252 | + } |
| 1253 | +} |
| 1254 | + |
| 1255 | +/** |
1205 | 1256 | * Check if the wiki read-only lock file is present. This can be used to lock |
1206 | 1257 | * off editing functions, but doesn't guarantee that the database will not be |
1207 | 1258 | * modified. |
— | — | @@ -2563,57 +2614,6 @@ |
2564 | 2615 | } |
2565 | 2616 | |
2566 | 2617 | /** |
2567 | | - * Increment a statistics counter |
2568 | | - * |
2569 | | - * @param $key String |
2570 | | - * @param $count Int |
2571 | | - */ |
2572 | | -function wfIncrStats( $key, $count = 1 ) { |
2573 | | - global $wgStatsMethod; |
2574 | | - |
2575 | | - $count = intval( $count ); |
2576 | | - |
2577 | | - if( $wgStatsMethod == 'udp' ) { |
2578 | | - global $wgUDPProfilerHost, $wgUDPProfilerPort, $wgDBname, $wgAggregateStatsID; |
2579 | | - static $socket; |
2580 | | - |
2581 | | - $id = $wgAggregateStatsID !== false ? $wgAggregateStatsID : $wgDBname; |
2582 | | - |
2583 | | - if ( !$socket ) { |
2584 | | - $socket = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); |
2585 | | - $statline = "stats/{$id} - 1 1 1 1 1 -total\n"; |
2586 | | - socket_sendto( |
2587 | | - $socket, |
2588 | | - $statline, |
2589 | | - strlen( $statline ), |
2590 | | - 0, |
2591 | | - $wgUDPProfilerHost, |
2592 | | - $wgUDPProfilerPort |
2593 | | - ); |
2594 | | - } |
2595 | | - $statline = "stats/{$id} - {$count} 1 1 1 1 {$key}\n"; |
2596 | | - wfSuppressWarnings(); |
2597 | | - socket_sendto( |
2598 | | - $socket, |
2599 | | - $statline, |
2600 | | - strlen( $statline ), |
2601 | | - 0, |
2602 | | - $wgUDPProfilerHost, |
2603 | | - $wgUDPProfilerPort |
2604 | | - ); |
2605 | | - wfRestoreWarnings(); |
2606 | | - } elseif( $wgStatsMethod == 'cache' ) { |
2607 | | - global $wgMemc; |
2608 | | - $key = wfMemcKey( 'stats', $key ); |
2609 | | - if ( is_null( $wgMemc->incr( $key, $count ) ) ) { |
2610 | | - $wgMemc->add( $key, $count ); |
2611 | | - } |
2612 | | - } else { |
2613 | | - // Disabled |
2614 | | - } |
2615 | | -} |
2616 | | - |
2617 | | -/** |
2618 | 2618 | * @param $nr Mixed: the number to format |
2619 | 2619 | * @param $acc Integer: the number of digits after the decimal point, default 2 |
2620 | 2620 | * @param $round Boolean: whether or not to round the value, default true |