Support rate-limiting thumbnail generation
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 25 Sep 2013 17:58:30 +0000 (10:58 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 4 Oct 2013 22:51:55 +0000 (15:51 -0700)
* Added some rate limit comments

Change-Id: I987bb5d0ed8821d64131baefd4457acd25678818

includes/DefaultSettings.php
thumb.php

index 5b1d4b3..48e6efc 100644 (file)
@@ -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,
index ef2af24..f896180 100644 (file)
--- 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 );