mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-21 17:15:25 +03:00
refactor: drop usage of Debug::log (#4202)
* refactor: drop usage of Debug::log * lint
This commit is contained in:
parent
6afd13eb06
commit
2acd415475
20 changed files with 37 additions and 105 deletions
|
@ -45,7 +45,6 @@ class AsahiShimbunAJWBridge extends BridgeAbstract
|
|||
|
||||
foreach ($html->find('#MainInner li a') as $element) {
|
||||
if ($element->parent()->class == 'HeadlineTopImage-S') {
|
||||
Debug::log('Skip Headline, it is repeated below');
|
||||
continue;
|
||||
}
|
||||
$item = [];
|
||||
|
|
|
@ -27,11 +27,6 @@ class DagensNyheterDirektBridge extends BridgeAbstract
|
|||
$url = self::BASEURL . $link;
|
||||
$title = $element->find('h2', 0)->plaintext;
|
||||
$author = $element->find('div.ds-byline__titles', 0)->plaintext;
|
||||
// Debug::log($link);
|
||||
// Debug::log($datetime);
|
||||
// Debug::log($title);
|
||||
// Debug::log($url);
|
||||
// Debug::log($author);
|
||||
|
||||
$article_content = $element->find('div.direkt-post__content', 0);
|
||||
$article_html = '';
|
||||
|
|
|
@ -187,7 +187,6 @@ class FicbookBridge extends BridgeAbstract
|
|||
$fixed_date = str_replace(' г.', '', $fixed_date);
|
||||
|
||||
if ($fixed_date === $date) {
|
||||
Debug::log('Unable to fix date: ' . $date);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,6 @@ class FolhaDeSaoPauloBridge extends FeedExpander
|
|||
$item['content'] = $text;
|
||||
$item['uri'] = explode('*', $item['uri'])[1];
|
||||
}
|
||||
} else {
|
||||
Debug::log('???: ' . $item['uri']);
|
||||
}
|
||||
} else {
|
||||
$item['uri'] = explode('*', $item['uri'])[1];
|
||||
|
@ -58,13 +56,11 @@ class FolhaDeSaoPauloBridge extends FeedExpander
|
|||
{
|
||||
$feed_input = $this->getInput('feed');
|
||||
if (substr($feed_input, 0, strlen(self::URI)) === self::URI) {
|
||||
Debug::log('Input:: ' . $feed_input);
|
||||
$feed_url = $feed_input;
|
||||
} else {
|
||||
/* TODO: prepend `/` if missing */
|
||||
$feed_url = self::URI . '/' . $this->getInput('feed');
|
||||
}
|
||||
Debug::log('URL: ' . $feed_url);
|
||||
$limit = $this->getInput('amount');
|
||||
$this->collectExpandableDatas($feed_url, $limit);
|
||||
}
|
||||
|
|
|
@ -21,8 +21,6 @@ class HackerNewsUserThreadsBridge extends BridgeAbstract
|
|||
{
|
||||
$url = 'https://news.ycombinator.com/threads?id=' . $this->getInput('user');
|
||||
$html = getSimpleHTMLDOM($url);
|
||||
Debug::log('queried ' . $url);
|
||||
Debug::log('found ' . $html);
|
||||
|
||||
$item = [];
|
||||
$articles = $html->find('tr[class*="comtr"]');
|
||||
|
|
|
@ -522,7 +522,7 @@ class ItakuBridge extends BridgeAbstract
|
|||
{
|
||||
$url = self::URI . '/api/commissions/' . $id . '/?format=json';
|
||||
$uri = self::URI . '/commissions/' . $id;
|
||||
// Debug::log(var_dump($metadata));
|
||||
|
||||
$data = $metadata ?? $this->getData($url, true, true)
|
||||
or returnServerError("Could not load $url");
|
||||
|
||||
|
@ -664,7 +664,6 @@ class ItakuBridge extends BridgeAbstract
|
|||
|
||||
private function getData(string $url, bool $cache = false, bool $getJSON = false, array $httpHeaders = [], array $curlOptions = [])
|
||||
{
|
||||
// Debug::log($url);
|
||||
if ($getJSON) { //get JSON object
|
||||
if ($cache) {
|
||||
$data = $this->loadCacheValue($url);
|
||||
|
|
|
@ -138,8 +138,6 @@ class JustETFBridge extends BridgeAbstract
|
|||
|
||||
date_time_set($df, 0, 0);
|
||||
|
||||
// Debug::log(date_format($df, 'U'));
|
||||
|
||||
return date_format($df, 'U');
|
||||
}
|
||||
|
||||
|
@ -216,8 +214,6 @@ class JustETFBridge extends BridgeAbstract
|
|||
$element = $article->find('div.subheadline', 0)
|
||||
or returnServerError('Date not found!');
|
||||
|
||||
// Debug::log($element->plaintext);
|
||||
|
||||
$date = trim(explode('|', $element->plaintext)[0]);
|
||||
|
||||
return $this->fixDate($date);
|
||||
|
@ -230,8 +226,6 @@ class JustETFBridge extends BridgeAbstract
|
|||
|
||||
$element->find('a', 0)->onclick = '';
|
||||
|
||||
// Debug::log($element->innertext);
|
||||
|
||||
return $element->innertext;
|
||||
}
|
||||
|
||||
|
@ -300,8 +294,6 @@ class JustETFBridge extends BridgeAbstract
|
|||
$element = $html->find('div.infobox div.vallabel', 0)
|
||||
or returnServerError('Date not found!');
|
||||
|
||||
// Debug::log($element->plaintext);
|
||||
|
||||
$date = trim(explode("\r\n", $element->plaintext)[1]);
|
||||
|
||||
return $this->fixDate($date);
|
||||
|
|
|
@ -275,11 +275,13 @@ class MastodonBridge extends BridgeAbstract
|
|||
$toSign = '(request-target): get ' . $matches[2] . "\nhost: " . $matches[1] . "\ndate: " . $date;
|
||||
$result = openssl_sign($toSign, $signature, $pkey, 'RSA-SHA256');
|
||||
if ($result) {
|
||||
Debug::log($toSign);
|
||||
$sig = 'Signature: keyId="' . $keyId . '",headers="(request-target) host date",signature="' .
|
||||
base64_encode($signature) . '"';
|
||||
Debug::log($sig);
|
||||
array_push($headers, $sig);
|
||||
$sig = sprintf(
|
||||
'Signature: keyId="%s",headers="(request-target) host date",signature="%s"',
|
||||
$keyId,
|
||||
base64_encode($signature)
|
||||
);
|
||||
|
||||
$headers[] = $sig;
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -38,7 +38,7 @@ class PanacheDigitalGamesBridge extends BridgeAbstract
|
|||
$image_html = $element->find('.news-item-thumbnail-image', 0);
|
||||
if ($image_html) {
|
||||
$image_strings = explode('\'', $image_html);
|
||||
/* Debug::log('S: ' . count($image_strings) . '||' . implode('_ _', $image_strings)); */
|
||||
|
||||
if (count($image_strings) == 4) {
|
||||
$item['content'] = '<img src="' . $image_strings[1] . '" />';
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ class PresidenciaPTBridge extends BridgeAbstract
|
|||
$contexts = $this->getParameters();
|
||||
|
||||
foreach (array_keys($contexts['Section']) as $k) {
|
||||
Debug::log('Key: ' . var_export($k, true));
|
||||
if ($this->getInput($k)) {
|
||||
$html = getSimpleHTMLDOMCached($this->getURI() . $k);
|
||||
|
||||
|
|
|
@ -118,13 +118,8 @@ class SlusheBridge extends BridgeAbstract
|
|||
|
||||
$html = getSimpleHTMLDOM($uri, $headers);
|
||||
|
||||
//Debug::log($html);
|
||||
//Debug::log($html->find('div.blog-item')[0]);
|
||||
|
||||
//Loop on each entry
|
||||
foreach ($html->find('div.blog-item') as $element) {
|
||||
//Debug::log($element);
|
||||
|
||||
$title = $element->find('h3.title', 0)->first_child()->innertext;
|
||||
$article_uri = $element->find('h3.title', 0)->first_child()->href;
|
||||
$timestamp = $element->find('div.publication-date', 0)->innertext;
|
||||
|
@ -153,7 +148,6 @@ class SlusheBridge extends BridgeAbstract
|
|||
// Add image thumbnail(s)
|
||||
foreach ($media_uris->find('img') as $media_uri) {
|
||||
$media_html .= '<a href="' . $article_uri . '">' . $media_uri . '</a>';
|
||||
//Debug::log('Adding to enclosures: ' . str_replace(' ', '%20', $media_uri->src));
|
||||
$item['enclosures'][] = str_replace(' ', '%20', $media_uri->src);
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +159,7 @@ class SlusheBridge extends BridgeAbstract
|
|||
foreach ($media_uris->find('img') as $media_uri) {
|
||||
$media_html .= '<p>Video:</p><a href="' .
|
||||
$article_uri . '">' . $media_uri . '</a>';
|
||||
//Debug::log('Adding to enclosures: ' . $media_uri->src);
|
||||
|
||||
$item['enclosures'][] = $media_uri->src;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,9 +70,9 @@ class ThreadsBridge extends BridgeAbstract
|
|||
public function collectData()
|
||||
{
|
||||
$html = getSimpleHTMLDOMCached($this->getURI(), static::CACHE_TIMEOUT);
|
||||
Debug::log(sprintf('Fetched: %s', $this->getURI()));
|
||||
|
||||
$jsonBlobs = $html->find('script[type="application/json"]');
|
||||
Debug::log(sprintf('%d JSON blobs found.', count($jsonBlobs)));
|
||||
|
||||
$gatheredCodes = [];
|
||||
$limit = $this->getInput('limit');
|
||||
foreach ($jsonBlobs as $jsonBlob) {
|
||||
|
@ -87,7 +87,6 @@ class ThreadsBridge extends BridgeAbstract
|
|||
}
|
||||
}
|
||||
}
|
||||
Debug::log(sprintf('Candidate codes found in JSON in script tags: %s', print_r($gatheredCodes, true)));
|
||||
|
||||
$this->feedName = html_entity_decode($html->find('meta[property=og:title]', 0)->content);
|
||||
// todo: meta[property=og:description] could populate the feed description
|
||||
|
|
|
@ -541,7 +541,7 @@ EOD;
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Debug::log('Missing support for media type: ' . $media->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,6 @@ EOD
|
|||
. $this->getInput('u'), $authHeaders, $params);
|
||||
|
||||
if (isset($user->errors)) {
|
||||
Debug::log('User JSON: ' . json_encode($user));
|
||||
returnServerError('Requested username can\'t be found.');
|
||||
}
|
||||
|
||||
|
@ -266,7 +265,6 @@ EOD
|
|||
(isset($data->errors) && !isset($data->data)) ||
|
||||
(isset($data->meta) && $data->meta->result_count === 0)
|
||||
) {
|
||||
Debug::log('Data JSON: ' . json_encode($data));
|
||||
switch ($this->queriedContext) {
|
||||
case 'By keyword or hashtag':
|
||||
returnServerError('No results for this query.');
|
||||
|
@ -311,7 +309,6 @@ EOD
|
|||
foreach ($includesTweets as $includesTweet) {
|
||||
$includesTweetsIds[] = $includesTweet->id;
|
||||
}
|
||||
Debug::log('includesTweetsIds: ' . join(',', $includesTweetsIds));
|
||||
|
||||
// Set default params for API query
|
||||
$params = [
|
||||
|
@ -336,8 +333,6 @@ EOD
|
|||
|
||||
// Create output array with all required elements for each tweet
|
||||
foreach ($tweets as $tweet) {
|
||||
//Debug::log('Tweet JSON: ' . json_encode($tweet));
|
||||
|
||||
// Skip pinned tweet (if selected)
|
||||
if ($hidePinned && $tweet->id === $pinnedTweetId) {
|
||||
continue;
|
||||
|
@ -376,12 +371,10 @@ EOD
|
|||
$cleanedQuotedTweet = null;
|
||||
$quotedUser = null;
|
||||
if ($isQuote) {
|
||||
Debug::log('Tweet is quote');
|
||||
foreach ($includesTweets as $includesTweet) {
|
||||
if ($includesTweet->id === $tweet->referenced_tweets[0]->id) {
|
||||
$quotedTweet = $includesTweet;
|
||||
$cleanedQuotedTweet = nl2br($quotedTweet->text);
|
||||
//Debug::log('Found quoted tweet');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -389,7 +382,6 @@ EOD
|
|||
$quotedUser = $this->getTweetUser($quotedTweet, $retweetedUsers, $includesUsers);
|
||||
}
|
||||
if ($isRetweet || is_null($user)) {
|
||||
Debug::log('Tweet is retweet, or $user is null');
|
||||
// Replace tweet object with original retweeted object
|
||||
if ($isRetweet) {
|
||||
foreach ($includesTweets as $includesTweet) {
|
||||
|
@ -430,7 +422,6 @@ EOD
|
|||
. $this->item['username'] . ')';
|
||||
|
||||
$cleanedTweet = nl2br($tweet->text);
|
||||
//Debug::log('cleanedTweet: ' . $cleanedTweet);
|
||||
|
||||
// Perform optional keyword filtering (only keep tweet if keyword is found)
|
||||
if (! empty($tweetFilter)) {
|
||||
|
@ -452,7 +443,6 @@ EOD
|
|||
// Search for and replace URLs in Tweet text
|
||||
$cleanedTweet = $this->replaceTweetURLs($tweet, $cleanedTweet);
|
||||
if (isset($cleanedQuotedTweet)) {
|
||||
Debug::log('Replacing URLs in Quoted Tweet text');
|
||||
$cleanedQuotedTweet = $this->replaceTweetURLs($quotedTweet, $cleanedQuotedTweet);
|
||||
}
|
||||
|
||||
|
@ -478,9 +468,7 @@ EOD
|
|||
// Get external link info
|
||||
$extURL = null;
|
||||
if (isset($tweet->entities->urls) && strpos($tweet->entities->urls[0]->expanded_url, 'twitter.com') === false) {
|
||||
Debug::log('Found an external link!');
|
||||
$extURL = $tweet->entities->urls[0]->expanded_url;
|
||||
Debug::log($extURL);
|
||||
$extDisplayURL = $tweet->entities->urls[0]->display_url;
|
||||
$extTitle = $tweet->entities->urls[0]->title;
|
||||
$extDesc = $tweet->entities->urls[0]->description;
|
||||
|
@ -513,15 +501,12 @@ EOD;
|
|||
$ext_media_html = '';
|
||||
if (!$hideImages) {
|
||||
if (isset($tweet->attachments->media_keys)) {
|
||||
Debug::log('Generating HTML for tweet media');
|
||||
$media_html = $this->createTweetMediaHTML($tweet, $includesMedia, $retweetedMedia);
|
||||
}
|
||||
if (isset($quotedTweet->attachments->media_keys)) {
|
||||
Debug::log('Generating HTML for quoted tweet media');
|
||||
$quoted_media_html = $this->createTweetMediaHTML($quotedTweet, $includesMedia, $retweetedMedia);
|
||||
}
|
||||
if (isset($extURL)) {
|
||||
Debug::log('Generating HTML for external link media');
|
||||
if ($this->getInput('noimgscaling')) {
|
||||
$extMediaURL = $extMediaOrig;
|
||||
} else {
|
||||
|
@ -562,7 +547,6 @@ QUOTE;
|
|||
|
||||
// Add External Link HTML, if relevant
|
||||
if (isset($extURL) && !$this->getInput('noexternallink')) {
|
||||
Debug::log('Adding HTML for external link');
|
||||
$ext_html = <<<EXTERNAL
|
||||
<div style="display: table; border-style: solid; border-width: 1px; border-radius: 5px; padding: 5px;">
|
||||
$ext_media_html<br>
|
||||
|
@ -653,21 +637,18 @@ EXTERNAL;
|
|||
{
|
||||
$originalUser = new stdClass(); // make the linters stop complaining
|
||||
if (isset($retweetedUsers)) {
|
||||
Debug::log('Searching for tweet author_id in $retweetedUsers');
|
||||
foreach ($retweetedUsers as $retweetedUser) {
|
||||
if ($retweetedUser->id === $tweetObject->author_id) {
|
||||
$matchedUser = $retweetedUser;
|
||||
Debug::log('Found author_id match in $retweetedUsers');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($matchedUser->username) && isset($includesUsers)) {
|
||||
Debug::log('Searching for tweet author_id in $includesUsers');
|
||||
foreach ($includesUsers as $includesUser) {
|
||||
if ($includesUser->id === $tweetObject->author_id) {
|
||||
$matchedUser = $includesUser;
|
||||
Debug::log('Found author_id match in $includesUsers');
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -689,7 +670,6 @@ EXTERNAL;
|
|||
$tweetMedia = [];
|
||||
// Start by checking the original list of tweet Media includes
|
||||
if (isset($includesMedia)) {
|
||||
Debug::log('Searching for media_key in $includesMedia');
|
||||
foreach ($includesMedia as $includesMedium) {
|
||||
if (
|
||||
in_array(
|
||||
|
@ -697,14 +677,12 @@ EXTERNAL;
|
|||
$tweetObject->attachments->media_keys
|
||||
)
|
||||
) {
|
||||
Debug::log('Found media_key in $includesMedia');
|
||||
$tweetMedia[] = $includesMedium;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If no matches found, check the retweet Media includes
|
||||
if (empty($tweetMedia) && isset($retweetedMedia)) {
|
||||
Debug::log('Searching for media_key in $retweetedMedia');
|
||||
foreach ($retweetedMedia as $retweetedMedium) {
|
||||
if (
|
||||
in_array(
|
||||
|
@ -712,7 +690,6 @@ EXTERNAL;
|
|||
$tweetObject->attachments->media_keys
|
||||
)
|
||||
) {
|
||||
Debug::log('Found media_key in $retweetedMedia');
|
||||
$tweetMedia[] = $retweetedMedium;
|
||||
}
|
||||
}
|
||||
|
@ -760,8 +737,7 @@ EOD;
|
|||
EOD;
|
||||
break;
|
||||
default:
|
||||
Debug::log('Missing support for media type: '
|
||||
. $media->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,14 +14,12 @@ class UnraidCommunityApplicationsBridge extends BridgeAbstract
|
|||
|
||||
private function fetchApps()
|
||||
{
|
||||
Debug::log('Fetching all applications/plugins');
|
||||
$this->apps = getContents(self::APPSURI);
|
||||
$this->apps = json_decode($this->apps, true)['applist'];
|
||||
}
|
||||
|
||||
private function sortApps()
|
||||
{
|
||||
Debug::log('Sorting applications/plugins');
|
||||
usort($this->apps, function ($app1, $app2) {
|
||||
return $app1['FirstSeen'] < $app2['FirstSeen'] ? 1 : -1;
|
||||
});
|
||||
|
|
|
@ -436,8 +436,6 @@ class XenForoBridge extends BridgeAbstract
|
|||
break;
|
||||
}
|
||||
|
||||
// Debug::log(date_format($df, 'U'));
|
||||
|
||||
return date_format($df, 'U');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ final class BridgeCard
|
|||
{
|
||||
$required = $entry['required'] ?? null;
|
||||
if ($required) {
|
||||
Debug::log('The "required" attribute is not supported for lists.');
|
||||
trigger_error('The required attribute is not supported for lists');
|
||||
unset($entry['required']);
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ final class BridgeCard
|
|||
{
|
||||
$required = $entry['required'] ?? null;
|
||||
if ($required) {
|
||||
Debug::log('The "required" attribute is not supported for checkboxes.');
|
||||
trigger_error('The required attribute is not supported for checkboxes');
|
||||
unset($entry['required']);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,20 +15,4 @@ class Debug
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use $this->logger->debug()
|
||||
*/
|
||||
public static function log($message)
|
||||
{
|
||||
$e = new \Exception();
|
||||
$trace = trace_from_exception($e);
|
||||
// Drop the current frame
|
||||
array_pop($trace);
|
||||
$lastFrame = $trace[array_key_last($trace)];
|
||||
$text = sprintf('%s(%s): %s', $lastFrame['file'], $lastFrame['line'], $message);
|
||||
|
||||
$logger = RssBridge::getLogger();
|
||||
$logger->debug($text);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ class FeedItem
|
|||
protected ?string $uid = null;
|
||||
protected array $misc = [];
|
||||
|
||||
private Logger $logger;
|
||||
|
||||
public static function fromArray(array $itemArray): self
|
||||
{
|
||||
$item = new self();
|
||||
|
@ -23,6 +25,7 @@ class FeedItem
|
|||
|
||||
private function __construct()
|
||||
{
|
||||
$this->logger = RssBridge::getLogger();
|
||||
}
|
||||
|
||||
public function __set($name, $value)
|
||||
|
@ -99,17 +102,17 @@ class FeedItem
|
|||
} elseif ($uri->hasAttribute('src')) { // Image
|
||||
$uri = $uri->src;
|
||||
} else {
|
||||
Debug::log('The item provided as URI is unknown!');
|
||||
$this->logger->debug('The item provided as URI is unknown!');
|
||||
}
|
||||
}
|
||||
if (!is_string($uri)) {
|
||||
Debug::log(sprintf('Expected $uri to be string but got %s', gettype($uri)));
|
||||
$this->logger->debug(sprintf('Expected $uri to be string but got %s', gettype($uri)));
|
||||
return;
|
||||
}
|
||||
$uri = trim($uri);
|
||||
// Intentionally doing a weak url validation here because FILTER_VALIDATE_URL is too strict
|
||||
if (!preg_match('#^https?://#i', $uri)) {
|
||||
Debug::log(sprintf('Not a valid url: "%s"', $uri));
|
||||
$this->logger->debug(sprintf('Not a valid url: "%s"', $uri));
|
||||
return;
|
||||
}
|
||||
$this->uri = $uri;
|
||||
|
@ -124,7 +127,7 @@ class FeedItem
|
|||
{
|
||||
$this->title = null;
|
||||
if (!is_string($title)) {
|
||||
trigger_error('Title must be a string: ' . print_r($title, true));
|
||||
$this->logger->debug('Title must be a string: ' . print_r($title, true));
|
||||
} else {
|
||||
$this->title = truncate(trim($title));
|
||||
}
|
||||
|
@ -143,11 +146,11 @@ class FeedItem
|
|||
} else {
|
||||
$timestamp = strtotime($datetime);
|
||||
if ($timestamp === false) {
|
||||
Debug::log('Unable to parse timestamp!');
|
||||
$this->logger->debug('Unable to parse timestamp!');
|
||||
}
|
||||
}
|
||||
if ($timestamp <= 0) {
|
||||
Debug::log('Timestamp must be greater than zero!');
|
||||
$this->logger->debug('Timestamp must be greater than zero!');
|
||||
} else {
|
||||
$this->timestamp = $timestamp;
|
||||
}
|
||||
|
@ -162,7 +165,7 @@ class FeedItem
|
|||
{
|
||||
$this->author = null;
|
||||
if (!is_string($author)) {
|
||||
Debug::log('Author must be a string!');
|
||||
$this->logger->debug('Author must be a string!');
|
||||
} else {
|
||||
$this->author = $author;
|
||||
}
|
||||
|
@ -190,7 +193,7 @@ class FeedItem
|
|||
if (is_string($content)) {
|
||||
$this->content = $content;
|
||||
} else {
|
||||
Debug::log(sprintf('Unable to convert feed content to string: %s', gettype($content)));
|
||||
$this->logger->debug(sprintf('Unable to convert feed content to string: %s', gettype($content)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,7 +207,7 @@ class FeedItem
|
|||
$this->enclosures = [];
|
||||
|
||||
if (!is_array($enclosures)) {
|
||||
Debug::log('Enclosures must be an array!');
|
||||
$this->logger->debug('Enclosures must be an array!');
|
||||
return;
|
||||
}
|
||||
foreach ($enclosures as $enclosure) {
|
||||
|
@ -215,7 +218,7 @@ class FeedItem
|
|||
FILTER_FLAG_PATH_REQUIRED
|
||||
)
|
||||
) {
|
||||
Debug::log('Each enclosure must contain a scheme, host and path!');
|
||||
$this->logger->debug('Each enclosure must contain a scheme, host and path!');
|
||||
} elseif (!in_array($enclosure, $this->enclosures)) {
|
||||
$this->enclosures[] = $enclosure;
|
||||
}
|
||||
|
@ -232,14 +235,14 @@ class FeedItem
|
|||
$this->categories = [];
|
||||
|
||||
if (!is_array($categories)) {
|
||||
Debug::log('Categories must be an array!');
|
||||
$this->logger->debug('Categories must be an array!');
|
||||
return;
|
||||
}
|
||||
foreach ($categories as $category) {
|
||||
if (is_string($category)) {
|
||||
$this->categories[] = $category;
|
||||
} else {
|
||||
Debug::log('Category must be a string!');
|
||||
$this->logger->debug('Category must be a string!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +256,7 @@ class FeedItem
|
|||
{
|
||||
$this->uid = null;
|
||||
if (!is_string($uid)) {
|
||||
Debug::log(sprintf('uid must be string: %s (%s)', (string) $uid, var_export($uid, true)));
|
||||
$this->logger->debug(sprintf('uid must be string: %s (%s)', (string) $uid, var_export($uid, true)));
|
||||
return;
|
||||
}
|
||||
if (preg_match('/^[a-f0-9]{40}$/', $uid)) {
|
||||
|
@ -267,9 +270,9 @@ class FeedItem
|
|||
public function addMisc($name, $value)
|
||||
{
|
||||
if (!is_string($name)) {
|
||||
Debug::log('Key must be a string!');
|
||||
$this->logger->debug('Key must be a string!');
|
||||
} elseif (in_array($name, get_object_vars($this))) {
|
||||
Debug::log('Key must be unique!');
|
||||
$this->logger->debug('Key must be unique!');
|
||||
} else {
|
||||
$this->misc[$name] = $value;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,8 @@ final class RssBridge
|
|||
|
||||
public static function getLogger(): Logger
|
||||
{
|
||||
return self::$logger;
|
||||
// null logger is only for the tests not to fail
|
||||
return self::$logger ?? new NullLogger();
|
||||
}
|
||||
|
||||
public static function getCache(): CacheInterface
|
||||
|
|
Loading…
Reference in a new issue