Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/150268
Change subject: Have SvgHandler create a directory for its RSVG input files ...................................................................... Have SvgHandler create a directory for its RSVG input files * This avoids needing to patch rsvg on 14.04 bug: 67402 Change-Id: I81ac0c6c62003ed5a8e33694751484498e6e7277 (cherry picked from commit 1bde7bdd490682654106c886a98b53fe58deed7a) --- M includes/media/SVG.php 1 file changed, 34 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/68/150268/1 diff --git a/includes/media/SVG.php b/includes/media/SVG.php index e28b38f..924dad1 100644 --- a/includes/media/SVG.php +++ b/includes/media/SVG.php @@ -185,7 +185,40 @@ } $srcPath = $image->getLocalRefPath(); - $status = $this->rasterize( $srcPath, $dstPath, $physicalWidth, $physicalHeight, $lang ); + if ( $srcPath === false ) { // Failed to get local copy + wfDebugLog( 'thumbnail', + sprintf( 'Thumbnail failed on %s: could not get local copy of "%s"', + wfHostname(), $image->getName() ) ); + + return new MediaTransformError( 'thumbnail_error', + $params['width'], $params['height'], + wfMessage( 'filemissing' )->text() + ); + } + + // Make a temp dir with a symlink to the local copy in it. + // This plays well with rsvg-convert policy for external entities. + // https://git.gnome.org/browse/librsvg/commit/?id=f01aded72c38f0e18bc7ff67dee800e380251c8e + $tmpDir = wfTempDir() . '/svg_' . wfRandomString( 24 ); + $lnPath = "$tmpDir/" . basename( $srcPath ); + $ok = mkdir( $tmpDir, 0771 ) && symlink( $srcPath, $lnPath ); + $cleaner = new ScopedCallback( function() use ( $tmpDir, $lnPath ) { + wfSuppressWarnings(); + unlink( $lnPath ); + rmdir( $tmpDir ); + wfRestoreWarnings(); + } ); + if ( !$ok ) { + wfDebugLog( 'thumbnail', + sprintf( 'Thumbnail failed on %s: could not link %s to %s', + wfHostname(), $lnPath, $srcPath ) ); + return new MediaTransformError( 'thumbnail_error', + $params['width'], $params['height'], + wfMessage( 'thumbnail-temp-create' )->text() + ); + } + + $status = $this->rasterize( $lnPath, $dstPath, $physicalWidth, $physicalHeight, $lang ); if ( $status === true ) { return new ThumbnailImage( $image, $dstUrl, $dstPath, $params ); } else { -- To view, visit https://gerrit.wikimedia.org/r/150268 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I81ac0c6c62003ed5a8e33694751484498e6e7277 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: wmf/1.24wmf14 Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits