Return HTTP 429 when thumbnailing is throttled due to too many errors
authorGergő Tisza <tgr.huwiki@gmail.com>
Wed, 26 Aug 2015 21:18:54 +0000 (14:18 -0700)
committerGergő Tisza <tgr.huwiki@gmail.com>
Wed, 26 Aug 2015 21:18:54 +0000 (14:18 -0700)
Bug: T110109
Change-Id: I8af527661a041964690faae7566fb97e305e2b0f

thumb.php

index eea6dda..f5eb8c9 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -332,6 +332,9 @@ function wfStreamThumb( array $params ) {
        $errorCode = 500;
        if ( !$thumb ) {
                $errorMsg = $errorMsg ?: $msg->rawParams( 'File::transform() returned false' )->escaped();
+               if ( $errorMsg instanceof MessageSpecifier && $errorMsg->getKey() === 'thumbnail_image-failure-limit' ) {
+                       $errorCode = 429;
+               }
        } elseif ( $thumb->isError() ) {
                $errorMsg = $thumb->getHtmlMsg();
        } elseif ( !$thumb->hasFile() ) {