From 0bd62fe71be23a1f3ef6de85287ac586eddfa2fa Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 26 Aug 2015 11:52:23 -0700 Subject: [PATCH] Reduced some instances of HTTP 500 in thumb.php * This add noise to logs and graphs that can look like outages due to a single crawler. Bug: T110109 Change-Id: Ie2a1edd0330b0f858729fcc56c828c11d9c7476c --- thumb.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/thumb.php b/thumb.php index 25bca87954..eea6ddafa6 100644 --- a/thumb.php +++ b/thumb.php @@ -221,7 +221,7 @@ function wfStreamThumb( array $params ) { wfThumbErrorText( 404, "The source file '$fileName' does not exist." ); return; } elseif ( $img->getPath() === false ) { - wfThumbErrorText( 500, "The source file '$fileName' is not locally accessible." ); + wfThumbErrorText( 400, "The source file '$fileName' is not locally accessible." ); return; } @@ -316,10 +316,10 @@ function wfStreamThumb( array $params ) { $user = RequestContext::getMain()->getUser(); if ( !wfThumbIsStandard( $img, $params ) && $user->pingLimiter( 'renderfile-nonstandard' ) ) { - wfThumbError( 500, wfMessage( 'actionthrottledtext' )->parse() ); + wfThumbError( 429, wfMessage( 'actionthrottledtext' )->parse() ); return; } elseif ( $user->pingLimiter( 'renderfile' ) ) { - wfThumbError( 500, wfMessage( 'actionthrottledtext' )->parse() ); + wfThumbError( 429, wfMessage( 'actionthrottledtext' )->parse() ); return; } @@ -555,7 +555,7 @@ function wfExtractThumbParams( $file, $params ) { * @return void */ function wfThumbErrorText( $status, $msgText ) { - return wfThumbError( $status, htmlspecialchars( $msgText ) ); + wfThumbError( $status, htmlspecialchars( $msgText ) ); } /** @@ -570,10 +570,8 @@ function wfThumbError( $status, $msgHtml ) { header( 'Cache-Control: no-cache' ); header( 'Content-Type: text/html; charset=utf-8' ); - if ( $status == 400 ) { - HttpStatus::header( 400 ); - } elseif ( $status == 404 ) { - HttpStatus::header( 404 ); + if ( $status == 400 || $status == 404 || $status == 429 ) { + HttpStatus::header( $status ); } elseif ( $status == 403 ) { HttpStatus::header( 403 ); header( 'Vary: Cookie' ); -- 2.20.1