Switch custom code to wfParseUrl which covers the same bugfix
authorGilles Dubuc <gdubuc@wikimedia.org>
Thu, 2 Oct 2014 15:26:37 +0000 (17:26 +0200)
committerGilles Dubuc <gdubuc@wikimedia.org>
Thu, 2 Oct 2014 16:15:06 +0000 (18:15 +0200)
Change-Id: I60b20bd7e8f4b25acd5ef2de172786a152c0e589
Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/301

includes/jobqueue/jobs/ThumbnailRenderJob.php

index 6b1e7e3..dbc4f23 100644 (file)
@@ -81,11 +81,13 @@ 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;
+                       $parsedUrl = wfParseUrl( $thumbUrl );
+
+                       if ( !$parsedUrl || !isset( $parsedUrl['path'] ) || !strlen( $parsedUrl['path'] ) ) {
+                               return false;
                        }
-                       $thumbUrl = '//' . $wgUploadThumbnailRenderHttpCustomDomain . parse_url( $thumbUrl, PHP_URL_PATH );
+
+                       $thumbUrl = '//' . $wgUploadThumbnailRenderHttpCustomDomain . $parsedUrl['path'];
                }
 
                wfDebug( __METHOD__ . ": hitting url {$thumbUrl}\n" );