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.
This commit is contained in:
parent
a882eb13f7
commit
90e7bf7cc3
|
@ -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) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue