From 2dc3c05a2b40653f10bd57e76007de22b6468a8f Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 18 Oct 2009 11:34:45 +0000 Subject: - Patch #589126 by mfb: fixed bug with user module using a flood window of 6 hours, but flood events more than 1 hour old being deleted by cron. Improved API documentation, and added tests. --- includes/common.inc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index bcc07fe29..5ecdcddf6 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1563,10 +1563,15 @@ function valid_url($url, $absolute = FALSE) { * * @param $name * The name of an event. + * @param $window + * Optional number of seconds before this event expires. Defaults to 3600 (1 + * hour). Typically uses the same value as the flood_is_allowed() $window + * parameter. Expired events are purged on cron run to prevent the flood table + * from growing indefinitely. * @param $identifier * Optional identifier (defaults to the current user's IP address). */ -function flood_register_event($name, $identifier = NULL) { +function flood_register_event($name, $window = 3600, $identifier = NULL) { if (!isset($identifier)) { $identifier = ip_address(); } @@ -1575,6 +1580,7 @@ function flood_register_event($name, $identifier = NULL) { 'event' => $name, 'identifier' => $identifier, 'timestamp' => REQUEST_TIME, + 'expiration' => REQUEST_TIME + $window, )) ->execute(); } -- cgit v1.2.3