r104623 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104622‎ | r104623 | r104624 >
Date:00:04, 30 November 2011
Author:tstarling
Status:resolved (Comments)
Tags:
Comment:
* Fix for r103575: actually use $wgVipsThumbnailerHost
* Show informative error message on curl client error (connection refused etc.)
* Set IM_CONCURRENCY=1 when calling VIPS to reduce the chance of a deadlock on OOM
Modified paths:
  • /trunk/extensions/VipsScaler/SpecialVipsTest.php (modified) (history)
  • /trunk/extensions/VipsScaler/VipsScaler_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/VipsScaler/SpecialVipsTest.php
@@ -362,8 +362,21 @@
363363 $url = wfAppendQuery( $url, array( 'noproxy' => '1' ) );
364364 wfDebug( __METHOD__ . ": Getting vips thumb from remote url $url\n" );
365365
366 - $options = array( 'method' => 'GET' );
 366+ $bits = IP::splitHostAndPort( $wgVipsThumbnailerHost );
 367+ if ( !$bits ) {
 368+ throw new MWException( __METHOD__.': $wgVipsThumbnailerHost is not set to a valid host' );
 369+ }
 370+ list( $host, $port ) = $bits;
 371+ if ( $port === false ) {
 372+ $port = 80;
 373+ }
 374+ $proxy = IP::combineHostAndPort( $host, $port );
367375
 376+ $options = array(
 377+ 'method' => 'GET',
 378+ 'proxy' => $proxy,
 379+ );
 380+
368381 $req = MWHttpRequest::factory( $url, $options );
369382 $status = $req->execute();
370383 if ( $status->isOk() ) {
@@ -375,10 +388,12 @@
376389 header( "Cache-Control: public, max-age=$wgVipsTestExpiry, s-maxage=$wgVipsTestExpiry" );
377390 header( 'Expires: ' . gmdate( 'r ', time() + $wgVipsTestExpiry ) );
378391 print $req->getContent();
 392+ } elseif ( $status->hasMessage( 'http-bad-status' ) ) {
 393+ return $this->streamError( 500, $req->getContent() );
379394 } else {
380 - return $this->streamError( 500, $req->getContent() );
 395+ global $wgOut;
 396+ return $this->streamError( 500, $wgOut->parse( $status->getWikiText() ) );
381397 }
382 -
383398 }
384399 }
385400
Index: trunk/extensions/VipsScaler/VipsScaler_body.php
@@ -400,9 +400,13 @@
401401 */
402402 public function execute() {
403403 # Build and escape the command string
404 - $cmd = wfEscapeShellArg( $this->vips,
405 - array_shift( $this->args ),
406 - $this->input, $this->output );
 404+ $cmd =
 405+ 'IM_CONCURRENCY=1 ' .
 406+ wfEscapeShellArg(
 407+ $this->vips,
 408+ array_shift( $this->args ),
 409+ $this->input, $this->output
 410+ );
407411
408412 foreach ( $this->args as $arg ) {
409413 $cmd .= ' ' . wfEscapeShellArg( $arg );

Follow-up revisions

RevisionCommit summaryAuthorDate
r104625Merged changes from trunk up to r104623tstarling00:09, 30 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103575* Rewrote the proxy feature so that it actually works. Just reuse the same en...tstarling06:21, 18 November 2011

Comments

#Comment by Bryan (talk | contribs)   22:44, 2 December 2011

IM_CONCURRENCY=1 broke this extension on Windows, fixed in a later revision.

Status & tagging log