summaryrefslogtreecommitdiff
path: root/thumb.php
diff options
context:
space:
mode:
Diffstat (limited to 'thumb.php')
-rw-r--r--thumb.php13
1 files changed, 11 insertions, 2 deletions
diff --git a/thumb.php b/thumb.php
index 6e04f4aa..1a1dee46 100644
--- a/thumb.php
+++ b/thumb.php
@@ -56,11 +56,13 @@ function wfThumbMain() {
$bits = explode( '!', $fileName, 2 );
if( !isset($bits[1]) ) {
wfThumbError( 404, wfMsg( 'badtitletext' ) );
+ wfProfileOut( __METHOD__ );
return;
}
$title = Title::makeTitleSafe( NS_FILE, $bits[1] );
if( is_null($title) ) {
wfThumbError( 404, wfMsg( 'badtitletext' ) );
+ wfProfileOut( __METHOD__ );
return;
}
$img = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $title, $fileName );
@@ -73,6 +75,7 @@ function wfThumbMain() {
if ( !$img->getTitle()->userCanRead() ) {
wfThumbError( 403, 'Access denied. You do not have permission to access ' .
'the source file.' );
+ wfProfileOut( __METHOD__ );
return;
}
$headers[] = 'Cache-Control: private';
@@ -81,15 +84,18 @@ function wfThumbMain() {
if ( !$img ) {
wfThumbError( 404, wfMsg( 'badtitletext' ) );
+ wfProfileOut( __METHOD__ );
return;
}
if ( !$img->exists() ) {
wfThumbError( 404, 'The source file for the specified thumbnail does not exist.' );
+ wfProfileOut( __METHOD__ );
return;
}
$sourcePath = $img->getPath();
if ( $sourcePath === false ) {
wfThumbError( 500, 'The source file is not locally accessible.' );
+ wfProfileOut( __METHOD__ );
return;
}
@@ -101,10 +107,11 @@ function wfThumbMain() {
// Calculate time
wfSuppressWarnings();
$imsUnix = strtotime( $imsString );
+ $stat = stat( $sourcePath );
wfRestoreWarnings();
- $stat = @stat( $sourcePath );
if ( $stat['mtime'] <= $imsUnix ) {
header( 'HTTP/1.1 304 Not Modified' );
+ wfProfileOut( __METHOD__ );
return;
}
}
@@ -116,11 +123,13 @@ function wfThumbMain() {
if ( is_file( $thumbPath ) ) {
wfStreamFile( $thumbPath, $headers );
+ wfProfileOut( __METHOD__ );
return;
}
}
} catch ( MWException $e ) {
wfThumbError( 500, $e->getHTML() );
+ wfProfileOut( __METHOD__ );
return;
}
@@ -164,7 +173,7 @@ function wfThumbError( $status, $msg ) {
header( 'HTTP/1.1 500 Internal server error' );
}
if( $wgShowHostnames ) {
- $url = htmlspecialchars( @$_SERVER['REQUEST_URI'] );
+ $url = htmlspecialchars( isset( $_SERVER['REQUEST_URI'] ) ? $_SERVER['REQUEST_URI'] : '' );
$hostname = htmlspecialchars( wfHostname() );
$debug = "<!-- $url -->\n<!-- $hostname -->\n";
} else {