diff options
Diffstat (limited to 'modules/throttle')
-rw-r--r-- | modules/throttle/throttle.module | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/modules/throttle/throttle.module b/modules/throttle/throttle.module index c2e1834aa..36510be63 100644 --- a/modules/throttle/throttle.module +++ b/modules/throttle/throttle.module @@ -28,10 +28,15 @@ function throttle_menu($may_cache) { * Determine the current load on the site. * * Call the throttle_status() function from your own modules, themes, blocks, - * etc. to determine the current throttle status. For example, in your theme - * you might choose to disable pictures when your site is too busy (reducing - * bandwidth), or in your modules you might choose to disable some complicated - * logic when your site is too busy (reducing CPU utilization). + * etc. as follows: + * + * $throttle = module_invoke('throttle', 'status'); + * + * to determine the current throttle status. Use module_invoke() so the + * call will still work if the throttle module is disabled. For example, in + * your theme you might choose to disable pictures when your site is too busy + * (reducing bandwidth), or in your modules you might choose to disable + * some complicated logic when your site is too busy (reducing CPU utilization). * * @return * 0 or 1. 0 means that the throttle is currently disabled. 1 means that @@ -57,10 +62,15 @@ function throttle_exit() { // limiting throttle related database calls to 1 in N. if (!mt_rand(0, variable_get('throttle_probability_limiter', 9))) { - // Count users with activity in the past n seconds, defined in user module - $time_period = variable_get('user_block_seconds_online', 2700); + // Count users with activity in the past n seconds. + // This value is defined in the user module Who's Online block. + $time_period = variable_get('user_block_seconds_online', 900); - $throttle = module_invoke('throttle', 'status'); + // When determining throttle status in your own module or theme, use + // $throttle = module_invoke('throttle', 'status'); + // as that will still work when throttle.module is disabled. + // Clearly here the module is enabled so we call throttle_status() directly. + $throttle = throttle_status(); if ($max_guests = variable_get('throttle_anonymous', 0)) { $guests = sess_count(time() - $time_period, TRUE); |