fix: various php notices (#3145)

* fix: notice

* fix: Trying to get property content of non-object at bridges/PcGamerBridge.php line 36

* fix: better exception message

* fix: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior
This commit is contained in:
Dag 2022-11-15 00:30:51 +01:00 committed by GitHub
parent 734a5868b8
commit 95c199c2eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 8 deletions

View File

@ -67,7 +67,7 @@ class GelbooruBridge extends BridgeAbstract
. $thumbnailUri . '" /></a><br><br><b>Dimensions:</b> '
. strval($element->width) . ' x ' . strval($element->height) . '<br><br><b>Tags:</b> '
. $item['tags'];
if (!is_null($element->source)) {
if (isset($element->source)) {
$item['content'] .= '<br><br><b>Source: </b><a href="' . $element->source . '">' . $element->source . '</a>';
}

View File

@ -28,7 +28,12 @@ class PcGamerBridge extends BridgeAbstract
$item['title'] = $articleHtml->find('meta[name=parsely-title]', 0)->content;
$item['content'] = html_entity_decode($articleHtml->find('meta[name=description]', 0)->content);
$item['author'] = $articleHtml->find('meta[name=parsely-author]', 0)->content;
$item['enclosures'][] = $articleHtml->find('meta[name=parsely-image-url]', 0)->content;
$imageUrl = $articleHtml->find('meta[name=parsely-image-url]', 0);
if ($imageUrl) {
$item['enclosures'][] = $imageUrl->content;
}
/* I don't know why every article has two extra tags, but because
one matches another common tag, "guide," it needs to be removed. */
$item['categories'] = array_diff(

View File

@ -420,7 +420,7 @@ class ReutersBridge extends BridgeAbstract
{
$description = '';
foreach ($contents as $content) {
$data;
$data = '';
if (isset($content['content'])) {
$data = $content['content'];
}

View File

@ -277,7 +277,7 @@ class WikipediaBridge extends BridgeAbstract
switch ($subject) {
case WIKIPEDIA_SUBJECT_TFA:
$element = $html->find('div[id=mp-tfa]', 0);
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle, -1);
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle, '...', -1);
break;
case WIKIPEDIA_SUBJECT_DYK:
$element = $html->find('div[id=mp-dyk]', 0);
@ -296,7 +296,7 @@ class WikipediaBridge extends BridgeAbstract
switch ($subject) {
case WIKIPEDIA_SUBJECT_TFA:
$element = $html->find('div[id=main-tfa]', 0);
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle, -1);
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle, '...', -1);
break;
case WIKIPEDIA_SUBJECT_DYK:
$element = $html->find('div[id=main-dyk]', 0);

View File

@ -146,15 +146,15 @@ abstract class FeedExpander extends BridgeAbstract
$this->collectAtom1($rssContent, $maxItems);
break;
default:
Debug::log('Unknown feed format/version');
throw new \Exception('The feed format is unknown!');
Debug::log(sprintf('Unable to detect feed format from `%s`', $url));
throw new \Exception(sprintf('Unable to detect feed format from `%s`', $url));
}
return $this;
}
/**
* Collect data from a RSS 1.0 compatible feed
* Collect data from an RSS 1.0 compatible feed
*
* @link http://web.resource.org/rss/1.0/spec RDF Site Summary (RSS) 1.0
*