Fix a potential PHP notice when detecting a VCS service
In the (unlikely) case where the update metadata URL does not include a path, the getVcsService() method could previously trigger a deprecation notice like "preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated". This is because parse_url() returns NULL when the specified component is not present. Fixed by always casting the $path to string. The VCS detection code doesn't care about the difference between "empty path" and "no path" - it should correctly return NULL (= no VCS host found) anyway. Also, let's cast $host to a string as well to avoid another potential notice if the URL somehow has a path but no domain name. Initially reported in #499.
This commit is contained in:
parent
6eb27a6911
commit
5b863c26bd
|
|
@ -256,8 +256,8 @@ if ( !class_exists('Puc_v4p13_Factory', false) ):
|
|||
$service = null;
|
||||
|
||||
//Which hosting service does the URL point to?
|
||||
$host = parse_url($metadataUrl, PHP_URL_HOST);
|
||||
$path = parse_url($metadataUrl, PHP_URL_PATH);
|
||||
$host = (string)(parse_url($metadataUrl, PHP_URL_HOST));
|
||||
$path = (string)(parse_url($metadataUrl, PHP_URL_PATH));
|
||||
|
||||
//Check if the path looks like "/user-name/repository".
|
||||
//For GitLab.com it can also be "/user/group1/group2/.../repository".
|
||||
|
|
|
|||
Loading…
Reference in New Issue