summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwn_ <[email protected]>2023-12-30 15:38:41 +0000
committerwn_ <[email protected]>2023-12-30 15:39:17 +0000
commit90e7bf7cc385a64e3a91f30a6415a598ae0d0e99 (patch)
treecad5cb926791ff5284c7c20ffb5235181df02081
parenta882eb13f7ab36f4bab26a290a8e5ab1c6f2fb34 (diff)
Update all UrlHelper::fetch() calls to use the associative array approach.
The other approach (passing in individual params) was marked as deprecated a few years ago.
-rw-r--r--classes/Feeds.php2
-rw-r--r--classes/RSSUtils.php2
-rw-r--r--plugins/af_comics/filters/af_comics_cad.php7
-rw-r--r--plugins/af_comics/filters/af_comics_comicclass.php7
-rw-r--r--plugins/af_comics/filters/af_comics_darklegacy.php8
-rw-r--r--plugins/af_comics/filters/af_comics_dilbert.php8
-rw-r--r--plugins/af_comics/filters/af_comics_explosm.php2
-rw-r--r--plugins/af_comics/filters/af_comics_pa.php4
-rw-r--r--plugins/af_comics/filters/af_comics_pvp.php8
-rw-r--r--plugins/af_comics/filters/af_comics_tfd.php9
-rw-r--r--plugins/af_comics/filters/af_comics_twp.php2
-rw-r--r--plugins/af_comics/filters/af_comics_whomp.php8
-rw-r--r--tests/UrlHelperTest.php8
13 files changed, 39 insertions, 36 deletions
diff --git a/classes/Feeds.php b/classes/Feeds.php
index ac7a58f26..c673f0bd7 100644
--- a/classes/Feeds.php
+++ b/classes/Feeds.php
@@ -1145,7 +1145,7 @@ class Feeds extends Handler_Protected {
},
$url, $auth_login, $auth_pass);
- $contents = UrlHelper::fetch($url, false, $auth_login, $auth_pass);
+ $contents = UrlHelper::fetch(['url' => $url, 'login' => $auth_login, 'pass' => $auth_pass]);
PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_SUBSCRIBE_FEED,
function ($result) use (&$contents) {
diff --git a/classes/RSSUtils.php b/classes/RSSUtils.php
index c340f6cad..ea3c074ab 100644
--- a/classes/RSSUtils.php
+++ b/classes/RSSUtils.php
@@ -2007,7 +2007,7 @@ class RSSUtils {
$favicon_urls = [];
- if ($html = @UrlHelper::fetch($url)) {
+ if ($html = @UrlHelper::fetch(['url' => $url])) {
$doc = new DOMDocument();
if (@$doc->loadHTML($html)) {
diff --git a/plugins/af_comics/filters/af_comics_cad.php b/plugins/af_comics/filters/af_comics_cad.php
index b2b65ee05..780aaabf9 100644
--- a/plugins/af_comics/filters/af_comics_cad.php
+++ b/plugins/af_comics/filters/af_comics_cad.php
@@ -10,9 +10,10 @@ class Af_Comics_Cad extends Af_ComicFilter {
if (strpos($article["title"], "News:") === false) {
$doc = new DOMDocument();
- $res = UrlHelper::fetch($article["link"], false, false, false,
- false, false, 0,
- "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
+ $res = UrlHelper::fetch([
+ 'url' => $article['link'],
+ 'useragent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0',
+ ]);
if (!$res && UrlHelper::$fetch_last_error_content)
$res = UrlHelper::$fetch_last_error_content;
diff --git a/plugins/af_comics/filters/af_comics_comicclass.php b/plugins/af_comics/filters/af_comics_comicclass.php
index 5e14ea930..6a8811fd4 100644
--- a/plugins/af_comics/filters/af_comics_comicclass.php
+++ b/plugins/af_comics/filters/af_comics_comicclass.php
@@ -11,9 +11,10 @@ class Af_Comics_ComicClass extends Af_ComicFilter {
// lol at people who block clients by user agent
// oh noes my ad revenue Q_Q
- $res = UrlHelper::fetch($article["link"], false, false, false,
- false, false, 0,
- "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
+ $res = UrlHelper::fetch([
+ 'url' => $article['link'],
+ 'useragent' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',
+ ]);
$doc = new DOMDocument();
diff --git a/plugins/af_comics/filters/af_comics_darklegacy.php b/plugins/af_comics/filters/af_comics_darklegacy.php
index d1f6016cb..7cdc48e25 100644
--- a/plugins/af_comics/filters/af_comics_darklegacy.php
+++ b/plugins/af_comics/filters/af_comics_darklegacy.php
@@ -8,10 +8,10 @@ class Af_Comics_DarkLegacy extends Af_ComicFilter {
function process(&$article) {
if (strpos($article["guid"], "darklegacycomics.com") !== false) {
-
- $res = UrlHelper::fetch($article["link"], false, false, false,
- false, false, 0,
- "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
+ $res = UrlHelper::fetch([
+ 'url' => $article['link'],
+ 'useragent' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',
+ ]);
if (!$res && UrlHelper::$fetch_last_error_content)
$res = UrlHelper::$fetch_last_error_content;
diff --git a/plugins/af_comics/filters/af_comics_dilbert.php b/plugins/af_comics/filters/af_comics_dilbert.php
index a1c59b94c..bbd936621 100644
--- a/plugins/af_comics/filters/af_comics_dilbert.php
+++ b/plugins/af_comics/filters/af_comics_dilbert.php
@@ -9,10 +9,10 @@ class Af_Comics_Dilbert extends Af_ComicFilter {
function process(&$article) {
if (strpos($article["link"], "dilbert.com") !== false ||
strpos($article["link"], "/DilbertDailyStrip") !== false) {
-
- $res = UrlHelper::fetch($article["link"], false, false, false,
- false, false, 0,
- "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0");
+ $res = UrlHelper::fetch([
+ 'url' => $article['link'],
+ 'useragent' => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0',
+ ]);
if (!$res && UrlHelper::$fetch_last_error_content)
$res = UrlHelper::$fetch_last_error_content;
diff --git a/plugins/af_comics/filters/af_comics_explosm.php b/plugins/af_comics/filters/af_comics_explosm.php
index 3f8b49726..65691ae2b 100644
--- a/plugins/af_comics/filters/af_comics_explosm.php
+++ b/plugins/af_comics/filters/af_comics_explosm.php
@@ -11,7 +11,7 @@ class Af_Comics_Explosm extends Af_ComicFilter {
$doc = new DOMDocument();
- if (@$doc->loadHTML(UrlHelper::fetch($article["link"]))) {
+ if (@$doc->loadHTML(UrlHelper::fetch(['url' => $article['link']]))) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('//div[contains(@class, "MainComic__ComicImage")]//img')->item(0);
diff --git a/plugins/af_comics/filters/af_comics_pa.php b/plugins/af_comics/filters/af_comics_pa.php
index a5a81edcb..f4283be77 100644
--- a/plugins/af_comics/filters/af_comics_pa.php
+++ b/plugins/af_comics/filters/af_comics_pa.php
@@ -10,7 +10,7 @@ class Af_Comics_Pa extends Af_ComicFilter {
$doc = new DOMDocument();
- if ($doc->loadHTML(UrlHelper::fetch($article["link"]))) {
+ if ($doc->loadHTML(UrlHelper::fetch(['url' => $article['link']]))) {
$xpath = new DOMXPath($doc);
$basenode = $xpath->query('(//div[@id="comicFrame"])')->item(0);
@@ -25,7 +25,7 @@ class Af_Comics_Pa extends Af_ComicFilter {
if (strpos($article["link"], "penny-arcade.com") !== false && strpos($article["title"], "News Post:") !== false) {
$doc = new DOMDocument();
- $res = UrlHelper::fetch($article["link"]);
+ $res = UrlHelper::fetch(['url' => $article['link']]);
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
diff --git a/plugins/af_comics/filters/af_comics_pvp.php b/plugins/af_comics/filters/af_comics_pvp.php
index a27fbca87..e938f1501 100644
--- a/plugins/af_comics/filters/af_comics_pvp.php
+++ b/plugins/af_comics/filters/af_comics_pvp.php
@@ -7,10 +7,10 @@ class Af_Comics_Pvp extends Af_ComicFilter {
function process(&$article) {
if (strpos($article["guid"], "pvponline.com") !== false) {
-
- $res = UrlHelper::fetch($article["link"], false, false, false,
- false, false, 0,
- "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
+ $res = UrlHelper::fetch([
+ 'url' => $article['link'],
+ 'useragent' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',
+ ]);
$doc = new DOMDocument();
diff --git a/plugins/af_comics/filters/af_comics_tfd.php b/plugins/af_comics/filters/af_comics_tfd.php
index 2010da37e..ec245ef94 100644
--- a/plugins/af_comics/filters/af_comics_tfd.php
+++ b/plugins/af_comics/filters/af_comics_tfd.php
@@ -8,15 +8,16 @@ class Af_Comics_Tfd extends Af_ComicFilter {
function process(&$article) {
if (strpos($article["link"], "toothpastefordinner.com") !== false ||
strpos($article["link"], "marriedtothesea.com") !== false) {
- $res = UrlHelper::fetch($article["link"], false, false, false,
- false, false, 0,
- "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
+ $res = UrlHelper::fetch([
+ 'url' => $article['link'],
+ 'useragent' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',
+ ]);
if (!$res) return false;
$doc = new DOMDocument();
- $res = UrlHelper::fetch($article["link"]);
+ $res = UrlHelper::fetch(['url' => $article["link"]]);
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXPath($doc);
diff --git a/plugins/af_comics/filters/af_comics_twp.php b/plugins/af_comics/filters/af_comics_twp.php
index 6715be3c2..8f0077883 100644
--- a/plugins/af_comics/filters/af_comics_twp.php
+++ b/plugins/af_comics/filters/af_comics_twp.php
@@ -11,7 +11,7 @@ class Af_Comics_Twp extends Af_ComicFilter {
$doc = new DOMDocument();
- $res = UrlHelper::fetch($article["link"]);
+ $res = UrlHelper::fetch(['url' => $article['link']]);
if ($res && $doc->loadHTML($res)) {
$xpath = new DOMXpath($doc);
diff --git a/plugins/af_comics/filters/af_comics_whomp.php b/plugins/af_comics/filters/af_comics_whomp.php
index 712388449..fbdf0a049 100644
--- a/plugins/af_comics/filters/af_comics_whomp.php
+++ b/plugins/af_comics/filters/af_comics_whomp.php
@@ -7,10 +7,10 @@ class Af_Comics_Whomp extends Af_ComicFilter {
function process(&$article) {
if (strpos($article["guid"], "whompcomic.com") !== false) {
-
- $res = UrlHelper::fetch($article["link"], false, false, false,
- false, false, 0,
- "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)");
+ $res = UrlHelper::fetch([
+ 'url' => $article['link'],
+ 'useragent' => 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',
+ ]);
if (!$res && UrlHelper::$fetch_last_error_content)
$res = UrlHelper::$fetch_last_error_content;
diff --git a/tests/UrlHelperTest.php b/tests/UrlHelperTest.php
index 825c71e8e..249a5b412 100644
--- a/tests/UrlHelperTest.php
+++ b/tests/UrlHelperTest.php
@@ -71,18 +71,18 @@ final class UrlHelperTest extends TestCase {
]);
$mock->append(new Response(200, [], 'Hello, World'));
- $result = UrlHelper::fetch('https://www.example.com');
+ $result = UrlHelper::fetch(['url' => 'https://www.example.com']);
$this->assertEquals(200, UrlHelper::$fetch_last_error_code);
$this->assertEquals('Hello, World', $result);
$mock->reset();
foreach (['ftp://ftp.example.com', 'http://127.0.0.1', 'blah', '', 42, null] as $url) {
- $result = UrlHelper::fetch($url);
+ $result = UrlHelper::fetch(['url' => $url]);
$this->assertFalse($result);
}
$mock->append(new Response(200, ['Content-Length' => (string) PHP_INT_MAX]));
- $result = UrlHelper::fetch('https://www.example.com/very-large-content-length');
+ $result = UrlHelper::fetch(['url' => 'https://www.example.com/very-large-content-length']);
$this->assertFalse($result);
$mock->reset();
@@ -99,7 +99,7 @@ final class UrlHelperTest extends TestCase {
$mock->reset();
$mock->append(new Response(200, [], ''));
- $result = UrlHelper::fetch('https://www.example.com');
+ $result = UrlHelper::fetch(['url' => 'https://www.example.com']);
$this->assertFalse($result);
$this->assertEquals('Successful response, but no content was received.', UrlHelper::$fetch_last_error);
$mock->reset();