summaryrefslogtreecommitdiff
path: root/classes/urlhelper.php
diff options
context:
space:
mode:
authorwn_ <[email protected]>2021-11-01 20:36:48 +0000
committerwn_ <[email protected]>2021-11-01 21:10:27 +0000
commit9dac9c5a0db520697794c00d29424e617aca55bd (patch)
tree794c4d573faf76ab13b8ec55b3cdcc35a3b0d15b /classes/urlhelper.php
parentac5a4f5937d2d763b6293d3db644c9f30aa704b6 (diff)
Address PHPStan warnings in 'classes/urlhelper.php'.
Intentionally skipping the line 66 one for now; adding an 'is_array' check clears the warning, but there's a larger topic of how to handle an invalid '' that doesn't result in an array. ------ --------------------------------------------------------------------- Line classes/urlhelper.php ------ --------------------------------------------------------------------- 66 Offset 'path' on array{scheme: string} in isset() does not exist. 165 Parameter #2 $associative of function get_headers expects bool, int given. 167 Parameter #2 $associative of function get_headers expects bool, int given. 278 Negated boolean expression is always true. 309 Negated boolean expression is always true. ------ ---------------------------------------------------------------------
Diffstat (limited to 'classes/urlhelper.php')
-rw-r--r--classes/urlhelper.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/classes/urlhelper.php b/classes/urlhelper.php
index 0e4834b72..4d11b5a4d 100644
--- a/classes/urlhelper.php
+++ b/classes/urlhelper.php
@@ -162,8 +162,12 @@ class UrlHelper {
$context = stream_context_create($context_options);
+ // PHP 8 changed the second param from int to bool, but we still support PHP >= 7.1.0
+ // @phpstan-ignore-next-line
$headers = get_headers($url, 0, $context);
} else {
+ // PHP 8 changed the second param from int to bool, but we still support PHP >= 7.1.0
+ // @phpstan-ignore-next-line
$headers = get_headers($url, 0);
}
@@ -275,7 +279,7 @@ class UrlHelper {
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout ? $timeout : Config::get(Config::FILE_FETCH_CONNECT_TIMEOUT));
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout ? $timeout : Config::get(Config::FILE_FETCH_TIMEOUT));
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, !ini_get("open_basedir") && $followlocation);
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followlocation);
curl_setopt($ch, CURLOPT_MAXREDIRS, 20);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@@ -283,6 +287,7 @@ class UrlHelper {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent ? $useragent : Config::get_user_agent());
curl_setopt($ch, CURLOPT_ENCODING, "");
+ curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null");
if ($http_referrer)
curl_setopt($ch, CURLOPT_REFERER, $http_referrer);
@@ -306,10 +311,6 @@ class UrlHelper {
}
- if (!ini_get("open_basedir")) {
- curl_setopt($ch, CURLOPT_COOKIEJAR, "/dev/null");
- }
-
if (Config::get(Config::HTTP_PROXY)) {
curl_setopt($ch, CURLOPT_PROXY, Config::get(Config::HTTP_PROXY));
}