Workaround for thumbnail pre rendering with PHP < 5.4.7
authorGilles Dubuc <gdubuc@wikimedia.org>
Wed, 1 Oct 2014 20:55:23 +0000 (22:55 +0200)
committerGilles Dubuc <gdubuc@wikimedia.org>
Wed, 1 Oct 2014 21:01:39 +0000 (23:01 +0200)
Since this code is dealing with scheme-less URLs, parse_url()
can cause issues in older versions of PHP.

Change-Id: Ic1276feed9ed51772a05c4a73c787a315b848066
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/301

includes/jobqueue/jobs/ThumbnailRenderJob.php

index ec68d7e..6b1e7e3 100644 (file)
@@ -81,6 +81,10 @@ class ThumbnailRenderJob extends Job {
                $thumbUrl = $file->getThumbUrl( $thumbName );
 
                if ( $wgUploadThumbnailRenderHttpCustomDomain ) {
+                       // Workaround for parse_url not handling scheme-less urls properly in PHP < 5.4.7
+                       if ( substr( $thumbUrl, 0, 2 ) === '//' ) {
+                               $thumbUrl = 'http:' . $thumbUrl;
+                       }
                        $thumbUrl = '//' . $wgUploadThumbnailRenderHttpCustomDomain . parse_url( $thumbUrl, PHP_URL_PATH );
                }