Merge "Add method parameter type documentation"
[lhc/web/wiklou.git] / includes / specials / SpecialUploadStash.php
index a8e140d..002e949 100644 (file)
@@ -88,19 +88,19 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                        } else {
                                return $this->outputLocalFile( $params['file'] );
                        }
-               } catch( UploadStashFileNotFoundException $e ) {
+               } catch ( UploadStashFileNotFoundException $e ) {
                        $code = 404;
                        $message = $e->getMessage();
-               } catch( UploadStashZeroLengthFileException $e ) {
+               } catch ( UploadStashZeroLengthFileException $e ) {
                        $code = 500;
                        $message = $e->getMessage();
-               } catch( UploadStashBadPathException $e ) {
+               } catch ( UploadStashBadPathException $e ) {
                        $code = 500;
                        $message = $e->getMessage();
-               } catch( SpecialUploadStashTooLargeException $e ) {
+               } catch ( SpecialUploadStashTooLargeException $e ) {
                        $code = 500;
                        $message = 'Cannot serve a file larger than ' . self::MAX_SERVE_BYTES . ' bytes. ' . $e->getMessage();
-               } catch( Exception $e ) {
+               } catch ( Exception $e ) {
                        $code = 500;
                        $message = $e->getMessage();
                }
@@ -134,8 +134,13 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                        $paramString = substr( $thumbPart, 0, $srcNamePos - 1 );
 
                        $handler = $file->getHandler();
-                       $params = $handler->parseParamString( $paramString );
-                       return array( 'file' => $file, 'type' => $type, 'params' => $params );
+                       if ( $handler ) {
+                               $params = $handler->parseParamString( $paramString );
+                               return array( 'file' => $file, 'type' => $type, 'params' => $params );
+                       } else {
+                               throw new UploadStashBadPathException( 'No handler found for ' .
+                                               "mime {$file->getMimeType()} of file {$file->getPath()}" );
+                       }
                }
 
                return array( 'file' => $file, 'type' => $type );
@@ -222,7 +227,7 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                global $wgUploadStashScalerBaseUrl;
                $scalerBaseUrl = $wgUploadStashScalerBaseUrl;
 
-               if( preg_match( '/^\/\//', $scalerBaseUrl ) ) {
+               if ( preg_match( '/^\/\//', $scalerBaseUrl ) ) {
                        // this is apparently a protocol-relative URL, which makes no sense in this context,
                        // since this is used for communication that's internal to the application.
                        // default to http.