From: Aaron Schulz Date: Wed, 25 Sep 2013 17:58:30 +0000 (-0700) Subject: Support rate-limiting thumbnail generation X-Git-Tag: 1.31.0-rc.0~18499^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22calendrier%22%2C%22type=semaine%22%29%20.%20%22?a=commitdiff_plain;h=43d3304ed6502bd78bf989c2c4ce7f8882fe9c66;p=lhc%2Fweb%2Fwiklou.git Support rate-limiting thumbnail generation * Added some rate limit comments Change-Id: I987bb5d0ed8821d64131baefd4457acd25678818 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 5b1d4b3089..48e6efce7d 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4647,13 +4647,20 @@ $wgRateLimits = array( 'ip' => null, 'subnet' => null, ), - 'mailpassword' => array( + 'mailpassword' => array( // triggering password resets emails 'anon' => null, ), - 'emailuser' => array( + 'emailuser' => array( // emailing other users using MediaWiki 'user' => null, ), - 'linkpurge' => array( + 'linkpurge' => array( // purges of link tables + 'anon' => null, + 'user' => null, + 'newbie' => null, + 'ip' => null, + 'subnet' => null, + ), + 'renderfile' => array( // files rendered via thumb.php or thumb_handler.php 'anon' => null, 'user' => null, 'newbie' => null, diff --git a/thumb.php b/thumb.php index ef2af24939..f89618079d 100644 --- a/thumb.php +++ b/thumb.php @@ -304,6 +304,12 @@ function wfStreamThumb( array $params ) { return; } + $user = RequestContext::getMain()->getUser(); + if ( $user->pingLimiter( 'renderfile' ) ) { + wfThumbError( 500, wfMessage( 'actionthrottledtext' ) ); + return; + } + // Thumbnail isn't already there, so create the new thumbnail... try { $thumb = $img->transform( $params, File::RENDER_NOW );