From: Antoine Musso Date: Thu, 27 Feb 2014 13:37:33 +0000 (+0100) Subject: Deprecates $wgRateLimitLog in favor of debug log X-Git-Tag: 1.31.0-rc.0~16754 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=5b52c881be2c791209ec1d24cfab5790e19b0ec8;p=lhc%2Fweb%2Fwiklou.git Deprecates $wgRateLimitLog in favor of debug log $wgRateLimitLog is meant to log rate limiting occuring in MediaWiki. The feature was introduced by e46d19e72d3 / r9202 in 2005. We might not have wfDebugLog() at that time and we used error_log() with the global pointing to a file. A later patch converted to file_put_contents(). On Wikimedia production the variable is set to a udp:// URL, I am not sure file_put_contents() can write to it. Additionally the warning are suppressed which I tend to hate. Instead use the log bucket 'ratelimit'. For backcompabitilibity purposes, if $wgRateLmitLog is still set: attempt to set $wgDebugLogGroup['ratelimit'] with its value. Change-Id: I86131c4a8053800afd9f41fa1906c998a88736c6 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 1dae5e78ba..4ad2188e4e 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4739,6 +4739,8 @@ $wgRateLimits = array( /** * Set to a filename to log rate limiter hits. + * + * @deprecated since 1.23, use $wgDebugLogGroups['ratelimit'] instead */ $wgRateLimitLog = null; diff --git a/includes/Setup.php b/includes/Setup.php index 0ae6e9b562..209edefc28 100644 --- a/includes/Setup.php +++ b/includes/Setup.php @@ -452,6 +452,11 @@ if ( !$wgHTCPRouting && $wgHTCPMulticastAddress ) { ); } +// Back compatibility for $wgRateLimitLog deprecated with 1.23 +if ( $wgRateLimitLog && ! array_key_exists( 'ratelimit', $wgDebugLogGroups ) ) { + $wgDebugLogGroups['ratelimit'] = $wgRateLimitLog; +} + wfProfileOut( $fname . '-defaults2' ); wfProfileIn( $fname . '-misc1' ); diff --git a/includes/User.php b/includes/User.php index 0b28f664ad..e7283238ba 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1602,7 +1602,7 @@ class User { return false; } - global $wgMemc, $wgRateLimitLog; + global $wgMemc; wfProfileIn( __METHOD__ ); $limits = $wgRateLimits[$action]; @@ -1665,12 +1665,7 @@ class User { // Already pinged? if ( $count ) { if ( $count >= $max ) { - wfDebug( __METHOD__ . ": tripped! $key at $count $summary\n" ); - if ( $wgRateLimitLog ) { - wfSuppressWarnings(); - file_put_contents( $wgRateLimitLog, wfTimestamp( TS_MW ) . ' ' . wfWikiID() . ': ' . $this->getName() . " tripped $key at $count $summary\n", FILE_APPEND ); - wfRestoreWarnings(); - } + wfDebugLog( 'ratelimit', $this->getName() . " tripped! $key at $count $summary"); $triggered = true; } else { wfDebug( __METHOD__ . ": ok. $key at $count $summary\n" );