fix: various notice fixes (#3718)

This commit is contained in:
Dag 2023-09-29 19:17:03 +02:00 committed by GitHub
parent b9ec6a0eb4
commit 2172df9fa2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 5 deletions

View File

@ -260,7 +260,11 @@ class CodebergBridge extends BridgeAbstract
}
$item['author'] = $div->find('a.author', 0)->innertext;
$item['timestamp'] = $div->find('span.time-since', 0)->title;
$timeSince = $div->find('span.time-since', 0);
if ($timeSince) {
$item['timestamp'] = $timeSince->title;
}
$this->items[] = $item;
}

View File

@ -415,10 +415,14 @@ class CssSelectorComplexBridge extends BridgeAbstract
) {
$article_content = convertLazyLoading($entry_html);
$article_title = '';
if (is_null($title_selector)) {
$article_title = $title_default;
} else {
$article_title = trim($entry_html->find($title_selector, 0)->innertext);
$titleElement = $entry_html->find($title_selector, 0);
if ($titleElement) {
$article_title = trim($titleElement->innertext);
}
}
$author = null;

View File

@ -244,7 +244,7 @@ HTML,
if ($this->getInput('tagged')) {
$types[] = 'Tags';
}
$typesText = $types[0];
$typesText = $types[0] ?? '';
if (count($types) > 1) {
for ($i = 1; $i < count($types) - 1; $i++) {
$typesText .= ', ' . $types[$i];

View File

@ -463,7 +463,7 @@ HEREDOC;
)
)->{'src'};
} else {
return $deal->find('img[class*=' . $selectorPlain . ']', 0)->src;
return $deal->find('img[class*=' . $selectorPlain . ']', 0)->src ?? '';
}
}

View File

@ -65,6 +65,7 @@ class ThePirateBayBridge extends BridgeAbstract
'207' => 'HD Movies',
'208' => 'HD TV-Shows',
'209' => '3D',
'210' => 'CAM/TS',
'211' => 'UHD/4k Movies',
'212' => 'UHD/4k TV-Shows',
'299' => 'Other',

View File

@ -46,4 +46,14 @@ final class UtilsTest extends TestCase
$this->assertSame(4, strlen(create_random_string(2)));
$this->assertSame(6, strlen(create_random_string(3)));
}
public function testUrljoin()
{
$base = '/';
$rel = 'https://example.com/foo';
$url = urljoin($base, $rel);
$this->assertSame($rel, $url);
}
}

View File

@ -40,7 +40,10 @@ function urljoin($base, $rel) {
}
if (isset($prel['scheme'])) {
if ($prel['scheme'] != $pbase['scheme'] || in_array($prel['scheme'], $uses_relative) == false) {
if (
$prel['scheme'] != ($pbase['scheme'] ?? null)
|| in_array($prel['scheme'], $uses_relative) == false
) {
return $rel;
}
}