r104693 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104692‎ | r104693 | r104694 >
Date:15:32, 30 November 2011
Author:reedy
Status:ok
Tags:
Comment:
Using return from a method that doesn't return anything is unobvious
Modified paths:
  • /trunk/extensions/VipsScaler/SpecialVipsTest.php (modified) (history)
  • /trunk/extensions/VipsScaler/VipsTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/VipsScaler/VipsTest.php
@@ -18,7 +18,7 @@
1919 */
2020 $wgVipsTestExpiry = 3600;
2121
22 - $dir = dirname( __FILE__ );
 22+$dir = dirname( __FILE__ );
2323
2424 /** Registration */
2525 $wgAutoloadClasses['SpecialVipsTest'] = "$dir/SpecialVipsTest.php";
Index: trunk/extensions/VipsScaler/SpecialVipsTest.php
@@ -277,23 +277,27 @@
278278 # Validate title and file existance
279279 $title = Title::makeTitleSafe( NS_FILE, $request->getText( 'thumb' ) );
280280 if ( is_null( $title ) ) {
281 - return $this->streamError( 404, "VipsScaler: invalid title\n" );
 281+ $this->streamError( 404, "VipsScaler: invalid title\n" );
 282+ return;
282283 }
283284 $file = wfFindFile( $title );
284285 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;
286288 }
287289
288290 # Check if vips can handle this file
289291 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;
291294 }
292295
293296 # Validate param string
294297 $handler = $file->getHandler();
295298 $params = array( 'width' => $request->getInt( 'width' ) );
296299 if ( !$handler->normaliseParams( $file, $params ) ) {
297 - return $this->streamError( 500, "VipsScaler: invalid parameters\n" );
 300+ $this->streamError( 500, "VipsScaler: invalid parameters\n" );
 301+ return;
298302 }
299303
300304 # Get the thumbnail
@@ -336,7 +340,6 @@
337341 wfDebug( __METHOD__ . ": sharpening with radius {$options['sharpen']}\n" );
338342 }
339343
340 -
341344 # Call the hook
342345 $mto = null;
343346 VipsScaler::doTransform( $handler, $file, $scalerParams, $options, $mto );
@@ -389,10 +392,12 @@
390393 header( 'Expires: ' . gmdate( 'r ', time() + $wgVipsTestExpiry ) );
391394 print $req->getContent();
392395 } elseif ( $status->hasMessage( 'http-bad-status' ) ) {
393 - return $this->streamError( 500, $req->getContent() );
 396+ $this->streamError( 500, $req->getContent() );
 397+ return;
394398 } else {
395399 global $wgOut;
396 - return $this->streamError( 500, $wgOut->parse( $status->getWikiText() ) );
 400+ $this->streamError( 500, $wgOut->parse( $status->getWikiText() ) );
 401+ return;
397402 }
398403 }
399404 }
@@ -404,9 +409,9 @@
405410 * @param $error string
406411 */
407412 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 );
411417 }
412 -
413418 }

Status & tagging log