From c0350861ef0da66209e6b08c75af2c16e3673e25 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 13 Feb 2022 19:31:51 +0000 Subject: php8 warnings --- include/feedutils.php | 14 +++++++------- include/oembed.php | 12 +++++++----- include/text.php | 3 ++- include/zid.php | 2 ++ 4 files changed, 18 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/feedutils.php b/include/feedutils.php index 1c653325d..b21495d72 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -194,14 +194,14 @@ function construct_activity_object($item) { $r = json_decode($item['obj'],false); if(! $r) - return ''; - if($r->type) + return EMPTY_STR; + if(isset($r->type)) $o .= '' . xmlify($r->type) . '' . "\r\n"; - if($r->id) + if(isset($r->id)) $o .= '' . xmlify($r->id) . '' . "\r\n"; - if($r->title) + if(isset($r->title)) $o .= '' . xmlify($r->title) . '' . "\r\n"; - if($r->links) { + if(isset($r->links)) { /** @FIXME!! */ if(substr($r->link,0,1) === '<') { $r->link = preg_replace('/\/','',$r->link); @@ -210,7 +210,7 @@ function construct_activity_object($item) { else $o .= '' . "\r\n"; } - if($r->content) { + if(isset($r->content)) { $o .= '' . xmlify(bbcode($r->content)) . '' . "\r\n"; } $o .= '' . "\r\n"; @@ -218,7 +218,7 @@ function construct_activity_object($item) { return $o; } - return ''; + return EMPTY_STR; } function construct_activity_target($item) { diff --git a/include/oembed.php b/include/oembed.php index 9a25686fa..36938c577 100644 --- a/include/oembed.php +++ b/include/oembed.php @@ -134,6 +134,7 @@ function oembed_fetch_url($embedurl){ } $txt = null; + $j = null; // we should try to cache this and avoid a lookup on each render $is_matrix = is_matrix_url($embedurl); @@ -160,7 +161,7 @@ function oembed_fetch_url($embedurl){ if(is_null($txt)) { - $txt = ""; + $txt = EMPTY_STR; if ($action !== 'block') { // try oembed autodiscovery @@ -168,7 +169,7 @@ function oembed_fetch_url($embedurl){ $result = z_fetch_url($furl, false, $redirects, [ 'timeout' => 30, - 'accept_content' => "text/*", + 'accept_content' => 'text/*', 'novalidate' => true, 'session' => ((local_channel() && $zrl) ? true : false) ] @@ -227,9 +228,10 @@ function oembed_fetch_url($embedurl){ $txt = $x['embed']; } - $txt=trim($txt); + $txt = trim($txt); - if ($txt[0]!="{") $txt='{"type":"error"}'; + if (substr($txt, 0, 1) !== '{') + $txt = '{"type":"error"}'; // save in cache @@ -247,7 +249,7 @@ function oembed_fetch_url($embedurl){ } if($action === 'filter') { - if($j['html']) { + if(isset($j['html']) && $j['html']) { $orig = $j['html']; $allow_position = (($is_matrix) ? true : false); diff --git a/include/text.php b/include/text.php index f69801302..9a2ca1af4 100644 --- a/include/text.php +++ b/include/text.php @@ -4057,9 +4057,10 @@ function sanitize_text_field($str) { */ function substr_words($str, $max_length, $suffix = '...') { + $ret = ''; + if (strlen($str) > $max_length) { $words = preg_split('/\s/', $str); - $ret = ''; $i = 0; while (true) { $length = (strlen($ret) + strlen($words[$i])); diff --git a/include/zid.php b/include/zid.php index ae7d9e252..5710d9f3f 100644 --- a/include/zid.php +++ b/include/zid.php @@ -58,6 +58,8 @@ function zid($s, $address = '') { $mine_parsed = parse_url($mine); $s_parsed = parse_url($s); + + $url_match = false; if(isset($mine_parsed['host']) && isset($s_parsed['host']) && $mine_parsed['host'] === $s_parsed['host']) $url_match = true; -- cgit v1.2.3