From b892e4691db28cc8f3e14abf1929d4be546b0ead Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 3 Feb 2016 21:21:22 -0700 Subject: [PATCH] Added a separate error message for mkdir failures Bug: T125595 Change-Id: Id2daaad45c594d6f6265120039ca30742472987e --- includes/media/SVG.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/media/SVG.php b/includes/media/SVG.php index 1118598f88..457137bd58 100644 --- a/includes/media/SVG.php +++ b/includes/media/SVG.php @@ -204,7 +204,17 @@ class SvgHandler extends ImageHandler { // 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 ); + $ok = mkdir( $tmpDir, 0771 ); + if ( !$ok ) { + wfDebugLog( 'thumbnail', + sprintf( 'Thumbnail failed on %s: could not create temporary directory %s', + wfHostname(), $tmpDir ) ); + return new MediaTransformError( 'thumbnail_error', + $params['width'], $params['height'], + wfMessage( 'thumbnail-temp-create' )->text() + ); + } + $ok = symlink( $srcPath, $lnPath ); /** @noinspection PhpUnusedLocalVariableInspection */ $cleaner = new ScopedCallback( function () use ( $tmpDir, $lnPath ) { MediaWiki\suppressWarnings(); -- 2.20.1