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
$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;
}
/**