From 4b436b70212bc301b271ffc47367d1cbc1ad9305 Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 31 Oct 2012 20:16:36 +0100 Subject: [PATCH] Fix handling of prot-rel URLs in SiteObject. Previously, getProtocol() would return null for a protocol relative URL, but the database field sites_protocol does not allow null as a value. Changed getProtocol() to return an empty string instead. Change-Id: I7e22cc3c3d8dca17a28fc4627083d5d2cb253887 --- includes/site/SiteObject.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/includes/site/SiteObject.php b/includes/site/SiteObject.php index 6470c86e0d..adb2217e3e 100644 --- a/includes/site/SiteObject.php +++ b/includes/site/SiteObject.php @@ -157,10 +157,20 @@ class SiteObject extends ORMRow implements Site { $path = $this->getLinkPath(); if ( $path === false ) { - return false; + return ''; + } + + $protocol = parse_url( $path, PHP_URL_SCHEME ); + + if ( $protocol === false ) { // malformed URL + throw new MWException( "failed to parse URL $path" ); + } + + if ( $protocol === null ) { // no schema + $protocol = ''; // used for protocol relative URLs } - return parse_url( $path, PHP_URL_SCHEME ); + return $protocol; } /** -- 2.20.1