From 560caf837768a39d7e13f067f9221347ad348774 Mon Sep 17 00:00:00 2001 From: jmechnich Date: Sat, 1 Oct 2022 11:05:12 +0200 Subject: Fix PHP8 strtime warning if argument is null (addendum) --- classes/counters.php | 2 +- classes/digest.php | 2 +- classes/feeditem/atom.php | 6 +++--- classes/feeditem/rss.php | 4 ++-- classes/handler/public.php | 6 +++--- plugins/af_psql_trgm/init.php | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/classes/counters.php b/classes/counters.php index bc4d2d4a3..9699cb97c 100644 --- a/classes/counters.php +++ b/classes/counters.php @@ -193,7 +193,7 @@ class Counters { } // hide default un-updated timestamp i.e. 1970-01-01 (?) -fox - if ((int)date('Y') - (int)date('Y', strtotime($line['last_updated'])) > 2) + if ((int)date('Y') - (int)date('Y', strtotime($line['last_updated'] ?? '')) > 2) $last_updated = ''; $cv = [ diff --git a/classes/digest.php b/classes/digest.php index 3e943e6dd..a5dbc0945 100644 --- a/classes/digest.php +++ b/classes/digest.php @@ -22,7 +22,7 @@ class Digest while ($line = $res->fetch()) { if (get_pref(Prefs::DIGEST_ENABLE, $line['id'])) { - $preferred_ts = strtotime(get_pref(Prefs::DIGEST_PREFERRED_TIME, $line['id'])); + $preferred_ts = strtotime(get_pref(Prefs::DIGEST_PREFERRED_TIME, $line['id']) ?? ''); // try to send digests within 2 hours of preferred time if ($preferred_ts && time() >= $preferred_ts && diff --git a/classes/feeditem/atom.php b/classes/feeditem/atom.php index 59bf403b3..f6c96f959 100755 --- a/classes/feeditem/atom.php +++ b/classes/feeditem/atom.php @@ -19,19 +19,19 @@ class FeedItem_Atom extends FeedItem_Common { $updated = $this->elem->getElementsByTagName("updated")->item(0); if ($updated) { - return strtotime($updated->nodeValue); + return strtotime($updated->nodeValue ?? ''); } $published = $this->elem->getElementsByTagName("published")->item(0); if ($published) { - return strtotime($published->nodeValue); + return strtotime($published->nodeValue ?? ''); } $date = $this->xpath->query("dc:date", $this->elem)->item(0); if ($date) { - return strtotime($date->nodeValue); + return strtotime($date->nodeValue ?? ''); } // consistent with strtotime failing to parse diff --git a/classes/feeditem/rss.php b/classes/feeditem/rss.php index 132eabff5..e07fd1d06 100755 --- a/classes/feeditem/rss.php +++ b/classes/feeditem/rss.php @@ -17,13 +17,13 @@ class FeedItem_RSS extends FeedItem_Common { $pubDate = $this->elem->getElementsByTagName("pubDate")->item(0); if ($pubDate) { - return strtotime($pubDate->nodeValue); + return strtotime($pubDate->nodeValue ?? ''); } $date = $this->xpath->query("dc:date", $this->elem)->item(0); if ($date) { - return strtotime($date->nodeValue); + return strtotime($date->nodeValue ?? ''); } // consistent with strtotime failing to parse diff --git a/classes/handler/public.php b/classes/handler/public.php index 5c2f2bd02..08b73b87d 100755 --- a/classes/handler/public.php +++ b/classes/handler/public.php @@ -128,9 +128,9 @@ class Handler_Public extends Handler { $tpl->setVariable('ARTICLE_CONTENT', $content, true); $tpl->setVariable('ARTICLE_UPDATED_ATOM', - date('c', strtotime($line["updated"])), true); + date('c', strtotime($line["updated"] ?? '')), true); $tpl->setVariable('ARTICLE_UPDATED_RFC822', - date(DATE_RFC822, strtotime($line["updated"])), true); + date(DATE_RFC822, strtotime($line["updated"] ?? '')), true); $tpl->setVariable('ARTICLE_AUTHOR', htmlspecialchars($line['author']), true); @@ -214,7 +214,7 @@ class Handler_Public extends Handler { $article['title'] = $line['title']; $article['excerpt'] = $line["content_preview"]; $article['content'] = Sanitizer::sanitize($line["content"], false, $owner_uid, $feed_site_url, null, $line["id"]); - $article['updated'] = date('c', strtotime($line["updated"])); + $article['updated'] = date('c', strtotime($line["updated"] ?? '')); if (!empty($line['note'])) $article['note'] = $line['note']; if (!empty($line['author'])) $article['author'] = $line['author']; diff --git a/plugins/af_psql_trgm/init.php b/plugins/af_psql_trgm/init.php index 657b11934..4767e071b 100644 --- a/plugins/af_psql_trgm/init.php +++ b/plugins/af_psql_trgm/init.php @@ -122,7 +122,7 @@ class Af_Psql_Trgm extends Plugin { print ""; - print "
" . TimeHelper::smart_date_time(strtotime($line["updated"])) . "
"; + print "
" . TimeHelper::smart_date_time(strtotime($line["updated"] ?? '')) . "
"; print ""; } -- cgit v1.2.3