Skip to content

Commit 2172df9

Browse files
authored
fix: various notice fixes (RSS-Bridge#3718)
1 parent b9ec6a0 commit 2172df9

7 files changed

+27
-5
lines changed

bridges/CodebergBridge.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,11 @@ private function extractIssueComments($html)
260260
}
261261

262262
$item['author'] = $div->find('a.author', 0)->innertext;
263-
$item['timestamp'] = $div->find('span.time-since', 0)->title;
263+
264+
$timeSince = $div->find('span.time-since', 0);
265+
if ($timeSince) {
266+
$item['timestamp'] = $timeSince->title;
267+
}
264268

265269
$this->items[] = $item;
266270
}

bridges/CssSelectorComplexBridge.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,14 @@ protected function parseEntryElement(
415415
) {
416416
$article_content = convertLazyLoading($entry_html);
417417

418+
$article_title = '';
418419
if (is_null($title_selector)) {
419420
$article_title = $title_default;
420421
} else {
421-
$article_title = trim($entry_html->find($title_selector, 0)->innertext);
422+
$titleElement = $entry_html->find($title_selector, 0);
423+
if ($titleElement) {
424+
$article_title = trim($titleElement->innertext);
425+
}
422426
}
423427

424428
$author = null;

bridges/ImgsedBridge.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public function getName()
244244
if ($this->getInput('tagged')) {
245245
$types[] = 'Tags';
246246
}
247-
$typesText = $types[0];
247+
$typesText = $types[0] ?? '';
248248
if (count($types) > 1) {
249249
for ($i = 1; $i < count($types) - 1; $i++) {
250250
$typesText .= ', ' . $types[$i];

bridges/PepperBridgeAbstract.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ private function getImage($deal)
463463
)
464464
)->{'src'};
465465
} else {
466-
return $deal->find('img[class*=' . $selectorPlain . ']', 0)->src;
466+
return $deal->find('img[class*=' . $selectorPlain . ']', 0)->src ?? '';
467467
}
468468
}
469469

bridges/ThePirateBayBridge.php

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class ThePirateBayBridge extends BridgeAbstract
6565
'207' => 'HD Movies',
6666
'208' => 'HD TV-Shows',
6767
'209' => '3D',
68+
'210' => 'CAM/TS',
6869
'211' => 'UHD/4k Movies',
6970
'212' => 'UHD/4k TV-Shows',
7071
'299' => 'Other',

tests/UtilsTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,14 @@ public function testCreateRandomString()
4646
$this->assertSame(4, strlen(create_random_string(2)));
4747
$this->assertSame(6, strlen(create_random_string(3)));
4848
}
49+
50+
public function testUrljoin()
51+
{
52+
$base = '/';
53+
$rel = 'https://example.com/foo';
54+
55+
$url = urljoin($base, $rel);
56+
57+
$this->assertSame($rel, $url);
58+
}
4959
}

vendor/php-urljoin/src/urljoin.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ function urljoin($base, $rel) {
4040
}
4141

4242
if (isset($prel['scheme'])) {
43-
if ($prel['scheme'] != $pbase['scheme'] || in_array($prel['scheme'], $uses_relative) == false) {
43+
if (
44+
$prel['scheme'] != ($pbase['scheme'] ?? null)
45+
|| in_array($prel['scheme'], $uses_relative) == false
46+
) {
4447
return $rel;
4548
}
4649
}

0 commit comments

Comments
 (0)