Index: trunk/extensions/VipsScaler/VipsTest.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | */ |
20 | 20 | $wgVipsTestExpiry = 3600; |
21 | 21 | |
22 | | - $dir = dirname( __FILE__ ); |
| 22 | +$dir = dirname( __FILE__ ); |
23 | 23 | |
24 | 24 | /** Registration */ |
25 | 25 | $wgAutoloadClasses['SpecialVipsTest'] = "$dir/SpecialVipsTest.php"; |
Index: trunk/extensions/VipsScaler/SpecialVipsTest.php |
— | — | @@ -277,23 +277,27 @@ |
278 | 278 | # Validate title and file existance |
279 | 279 | $title = Title::makeTitleSafe( NS_FILE, $request->getText( 'thumb' ) ); |
280 | 280 | if ( is_null( $title ) ) { |
281 | | - return $this->streamError( 404, "VipsScaler: invalid title\n" ); |
| 281 | + $this->streamError( 404, "VipsScaler: invalid title\n" ); |
| 282 | + return; |
282 | 283 | } |
283 | 284 | $file = wfFindFile( $title ); |
284 | 285 | if ( !$file || !$file->exists() ) { |
285 | | - return $this->streamError( 404, "VipsScaler: file not found\n" ); |
| 286 | + $this->streamError( 404, "VipsScaler: file not found\n" ); |
| 287 | + return; |
286 | 288 | } |
287 | 289 | |
288 | 290 | # Check if vips can handle this file |
289 | 291 | if ( VipsScaler::getVipsHandler( $file ) === false ) { |
290 | | - return $this->streamError( 500, "VipsScaler: VIPS cannot handle this file type\n" ); |
| 292 | + $this->streamError( 500, "VipsScaler: VIPS cannot handle this file type\n" ); |
| 293 | + return; |
291 | 294 | } |
292 | 295 | |
293 | 296 | # Validate param string |
294 | 297 | $handler = $file->getHandler(); |
295 | 298 | $params = array( 'width' => $request->getInt( 'width' ) ); |
296 | 299 | if ( !$handler->normaliseParams( $file, $params ) ) { |
297 | | - return $this->streamError( 500, "VipsScaler: invalid parameters\n" ); |
| 300 | + $this->streamError( 500, "VipsScaler: invalid parameters\n" ); |
| 301 | + return; |
298 | 302 | } |
299 | 303 | |
300 | 304 | # Get the thumbnail |
— | — | @@ -336,7 +340,6 @@ |
337 | 341 | wfDebug( __METHOD__ . ": sharpening with radius {$options['sharpen']}\n" ); |
338 | 342 | } |
339 | 343 | |
340 | | - |
341 | 344 | # Call the hook |
342 | 345 | $mto = null; |
343 | 346 | VipsScaler::doTransform( $handler, $file, $scalerParams, $options, $mto ); |
— | — | @@ -389,10 +392,12 @@ |
390 | 393 | header( 'Expires: ' . gmdate( 'r ', time() + $wgVipsTestExpiry ) ); |
391 | 394 | print $req->getContent(); |
392 | 395 | } elseif ( $status->hasMessage( 'http-bad-status' ) ) { |
393 | | - return $this->streamError( 500, $req->getContent() ); |
| 396 | + $this->streamError( 500, $req->getContent() ); |
| 397 | + return; |
394 | 398 | } else { |
395 | 399 | global $wgOut; |
396 | | - return $this->streamError( 500, $wgOut->parse( $status->getWikiText() ) ); |
| 400 | + $this->streamError( 500, $wgOut->parse( $status->getWikiText() ) ); |
| 401 | + return; |
397 | 402 | } |
398 | 403 | } |
399 | 404 | } |
— | — | @@ -404,9 +409,9 @@ |
405 | 410 | * @param $error string |
406 | 411 | */ |
407 | 412 | protected function streamError( $code, $error = '' ) { |
408 | | - $this->getOutput()->setStatusCode( $code ); |
409 | | - $this->getOutput()->setArticleBodyOnly( true ); |
410 | | - $this->getOutput()->addHTML( $error ); |
| 413 | + $output = $this->getOutput(); |
| 414 | + $output->setStatusCode( $code ); |
| 415 | + $output->setArticleBodyOnly( true ); |
| 416 | + $output->addHTML( $error ); |
411 | 417 | } |
412 | | - |
413 | 418 | } |