summaryrefslogtreecommitdiff
path: root/modules/throttle
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-12-20 10:29:31 +0000
committerDries Buytaert <dries@buytaert.net>2006-12-20 10:29:31 +0000
commita4ed940ab8533800aa5478f79ae7f49e379d71b3 (patch)
tree661bfae9d02c4170c6d3a1f3d24507798acd9fe0 /modules/throttle
parentbb2a637d0f6bcf31b4d5bedfb46f0b65ebbdde11 (diff)
downloadbrdo-a4ed940ab8533800aa5478f79ae7f49e379d71b3.tar.gz
brdo-a4ed940ab8533800aa5478f79ae7f49e379d71b3.tar.bz2
- Patch #104309 by jvandyck: documentation improvements.
Diffstat (limited to 'modules/throttle')
-rw-r--r--modules/throttle/throttle.module24
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);