diff options
author | Mario <mario@mariovavti.com> | 2022-09-11 14:58:40 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2022-09-11 14:58:40 +0000 |
commit | 480862d7143f291658b48e785eda2e61a438a74b (patch) | |
tree | 29661e5f26e4ca5b1e9aff1e8875485157a057d3 | |
parent | 990a3af2a7349e07c10224cf2a023d179ecfd6ca (diff) | |
download | volse-hubzilla-480862d7143f291658b48e785eda2e61a438a74b.tar.gz volse-hubzilla-480862d7143f291658b48e785eda2e61a438a74b.tar.bz2 volse-hubzilla-480862d7143f291658b48e785eda2e61a438a74b.zip |
php8: fix more warnings
-rw-r--r-- | Zotlabs/Lib/Activity.php | 22 | ||||
-rw-r--r-- | Zotlabs/Lib/ActivityStreams.php | 8 | ||||
-rw-r--r-- | Zotlabs/Lib/Libzot.php | 5 | ||||
-rw-r--r-- | Zotlabs/Lib/System.php | 16 | ||||
-rw-r--r-- | Zotlabs/Lib/ThreadItem.php | 6 | ||||
-rw-r--r-- | Zotlabs/Module/Sse_bs.php | 6 | ||||
-rw-r--r-- | Zotlabs/Widget/Notifications.php | 1 | ||||
-rw-r--r-- | include/conversation.php | 19 | ||||
-rw-r--r-- | include/event.php | 12 | ||||
-rw-r--r-- | include/feedutils.php | 28 | ||||
-rw-r--r-- | include/items.php | 10 | ||||
-rw-r--r-- | include/nav.php | 5 | ||||
-rw-r--r-- | include/text.php | 1 |
13 files changed, 71 insertions, 68 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index b400ffd61..7e6f7d42d 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -646,15 +646,15 @@ class Activity { $ret = []; - if (is_array($item['attachment']) && $item['attachment']) { + if (isset($item['attachment'])) { $ptr = $item['attachment']; if (!array_key_exists(0, $ptr)) { $ptr = [$ptr]; } foreach ($ptr as $att) { $entry = []; - if ($att['type'] === 'PropertyValue') { - if (array_key_exists('name', $att) && $att['name']) { + if (isset($att['type']) && $att['type'] === 'PropertyValue') { + if (isset($att['name'])) { $key = explode('.', $att['name']); if (count($key) === 3 && $key[0] === 'zot') { $entry['cat'] = $key[1]; @@ -674,7 +674,7 @@ class Activity { $ret = []; - if (array_key_exists('attachment', $item) && is_array($item['attachment'])) { + if (isset($item['attachment'])) { $ptr = $item['attachment']; if (!array_key_exists(0, $ptr)) { $ptr = [$ptr]; @@ -1600,7 +1600,7 @@ class Activity { $m = parse_url($url); if ($m) { $hostname = $m['host']; - $baseurl = $m['scheme'] . '://' . $m['host'] . (($m['port']) ? ':' . $m['port'] : ''); + $baseurl = $m['scheme'] . '://' . $m['host'] . ((isset($m['port'])) ? ':' . $m['port'] : ''); $site_url = $m['scheme'] . '://' . $m['host']; } @@ -1791,9 +1791,13 @@ class Activity { // sort function width decreasing static function vid_sort($a, $b) { - if ($a['width'] === $b['width']) + $a_width = $a['width'] ?? 0; + $b_width = $b['width'] ?? 0; + + if ($a_width === $b_width) return 0; - return (($a['width'] > $b['width']) ? -1 : 1); + + return (($a_width > $b_width) ? -1 : 1); } static function create_note($channel, $observer_hash, $act) { @@ -2673,7 +2677,7 @@ class Activity { } } - if (!$s['plink']) { + if (!(isset($s['plink']) && $s['plink'])) { $s['plink'] = $s['mid']; } @@ -2865,7 +2869,7 @@ class Activity { // The $item['item_fetched'] flag is set in fetch_and_store_parents(). // In this case we should check against author permissions because sender is not owner. - if (perm_is_allowed($channel['channel_id'], (($item['item_fetched']) ? $item['author_xchan'] : $observer_hash), 'send_stream') || $is_sys_channel) { + if (perm_is_allowed($channel['channel_id'], ((isset($item['item_fetched']) && $item['item_fetched']) ? $item['author_xchan'] : $observer_hash), 'send_stream') || $is_sys_channel) { $allowed = true; } // TODO: not implemented diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php index c0b07bfb5..fc580e9aa 100644 --- a/Zotlabs/Lib/ActivityStreams.php +++ b/Zotlabs/Lib/ActivityStreams.php @@ -116,17 +116,17 @@ class ActivityStreams { $this->obj['object'] = $this->get_compound_property($this->obj['object']); } - if ($this->obj && is_array($this->obj) && $this->obj['actor']) + if ($this->obj && is_array($this->obj) && isset($this->obj['actor'])) $this->obj['actor'] = $this->get_actor('actor', $this->obj); - if ($this->tgt && is_array($this->tgt) && $this->tgt['actor']) + if ($this->tgt && is_array($this->tgt) && isset($this->tgt['actor'])) $this->tgt['actor'] = $this->get_actor('actor', $this->tgt); $this->parent_id = $this->get_property_obj('inReplyTo'); - if ((!$this->parent_id) && is_array($this->obj)) { + if ((!$this->parent_id) && is_array($this->obj) && isset($this->obj['inReplyTo'])) { $this->parent_id = $this->obj['inReplyTo']; } - if ((!$this->parent_id) && is_array($this->obj)) { + if ((!$this->parent_id) && is_array($this->obj) && isset($this->obj['id'])) { $this->parent_id = $this->obj['id']; } } diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 09ce3a9de..340f844d5 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -2926,12 +2926,11 @@ class Libzot { // This is a template - %s will be replaced with the follow_url we discover for the return channel. if ($special_channel) { - $ret['connect_url'] = (($e['xchan_connpage']) ? $e['xchan_connpage'] : z_root() . '/connect/' . $e['channel_address']); + $ret['connect_url'] = $e['xchan_connpage'] ?? z_root() . '/connect/' . $e['channel_address']; } // This is a template for our follow url, %s will be replaced with a webbie - if (!$ret['follow_url']) - $ret['follow_url'] = z_root() . '/follow?f=&url=%s'; + $ret['follow_url'] = $ret['follow_url'] ?? z_root() . '/follow?f=&url=%s'; $permissions = get_all_perms($e['channel_id'], $ztarget_hash, false, false); diff --git a/Zotlabs/Lib/System.php b/Zotlabs/Lib/System.php index 3cc46fbda..087378f16 100644 --- a/Zotlabs/Lib/System.php +++ b/Zotlabs/Lib/System.php @@ -16,13 +16,13 @@ class System { } static public function get_site_name() { - if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['sitename']) + if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['sitename'])) return \App::$config['system']['sitename']; return ''; } static public function get_project_version() { - if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['hide_version']) + if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['hide_version'])) return ''; if(is_array(\App::$config) && is_array(\App::$config['system']) && array_key_exists('std_version',\App::$config['system'])) return \App::$config['system']['std_version']; @@ -31,33 +31,33 @@ class System { } static public function get_update_version() { - if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['hide_version']) + if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['hide_version'])) return ''; return DB_UPDATE_VERSION; } static public function get_notify_icon() { - if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['email_notify_icon_url']) + if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['email_notify_icon_url'])) return \App::$config['system']['email_notify_icon_url']; return z_root() . DEFAULT_NOTIFY_ICON; } static public function get_site_icon() { - if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['site_icon_url']) + if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['site_icon_url'])) return \App::$config['system']['site_icon_url']; return z_root() . DEFAULT_PLATFORM_ICON ; } static public function get_project_link() { - if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['project_link']) + if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['project_link'])) return \App::$config['system']['project_link']; return 'https://hubzilla.org'; } static public function get_project_srclink() { - if(is_array(\App::$config) && is_array(\App::$config['system']) && \App::$config['system']['project_srclink']) + if(is_array(\App::$config) && is_array(\App::$config['system']) && isset(\App::$config['system']['project_srclink'])) return \App::$config['system']['project_srclink']; return 'https://framagit.org/hubzilla/core.git'; } @@ -68,7 +68,7 @@ class System { static public function get_zot_revision() { - $x = [ 'revision' => ZOT_REVISION ]; + $x = [ 'revision' => ZOT_REVISION ]; call_hooks('zot_revision',$x); return $x['revision']; } diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 20cbff4fc..0a7e40e0e 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -180,7 +180,7 @@ class ThreadItem { $dropping = false; } - + $drop = []; if($dropping) { $drop = array( 'dropping' => $dropping, @@ -309,6 +309,10 @@ class ThreadItem { if(($item['obj_type'] === ACTIVITY_OBJ_EVENT) && $conv->get_profile_owner() == local_channel()) $has_event = true; + $like = []; + $dislike = []; + $reply_to = []; + if($this->is_commentable() && $observer) { $like = array( t("I like this \x28toggle\x29"), t("like")); $dislike = array( t("I don't like this \x28toggle\x29"), t("dislike")); diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php index 619050aaf..3a4e4e09e 100644 --- a/Zotlabs/Module/Sse_bs.php +++ b/Zotlabs/Module/Sse_bs.php @@ -580,12 +580,12 @@ class Sse_bs extends Controller { $forums[$x]['notify_link'] = z_root() . '/network/?f=&pf=1&unseen=1&cid=' . $forums[$x]['abook_id']; $forums[$x]['name'] = $forums[$x]['xchan_name']; - $forums[$x]['addr'] = $forums[$x]['xchan_addr']; + $forums[$x]['addr'] = $forums[$x]['xchan_addr'] ?? $forums[$x]['xchan_url']; $forums[$x]['url'] = $forums[$x]['xchan_url']; $forums[$x]['photo'] = $forums[$x]['xchan_photo_s']; $forums[$x]['unseen'] = count($b64mids); - $forums[$x]['private_forum'] = (($forums[$x]['private_forum']) ? 'lock' : ''); - $forums[$x]['message'] = (($forums[$x]['private_forum']) ? t('Private forum') : t('Public forum')); + $forums[$x]['private_forum'] = ((isset($forums[$x]['private_forum']) && $forums[$x]['private_forum']) ? 'lock' : ''); + $forums[$x]['message'] = ((isset($forums[$x]['private_forum']) && $forums[$x]['private_forum']) ? t('Private forum') : t('Public forum')); $forums[$x]['mids'] = json_encode($b64mids); unset($forums[$x]['abook_id']); diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index 0e02d5cc1..a4e632a9f 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -13,6 +13,7 @@ class Notifications { function widget($arr) { $channel = \App::get_channel(); + $notifications = []; if(local_channel()) { $notifications[] = [ diff --git a/include/conversation.php b/include/conversation.php index fe001a79d..7df7b62c2 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -102,28 +102,29 @@ function localize_item(&$item){ logger('localize_item: failed to decode object: ' . print_r($item['obj'],true)); } - if(is_array($obj['author']) && $obj['author']['link']) + if(isset($obj['author']) && isset($obj['author']['link'])) $author_link = get_rel_link($obj['author']['link'],'alternate'); - elseif(is_array($obj['actor']) && $obj['actor']['url']) + elseif(isset($obj['actor']) && isset($obj['actor']['url'])) $author_link = ((is_array($obj['actor']['url'])) ? $obj['actor']['url'][0]['href'] : $obj['actor']['url']); elseif (is_string($obj['actor'])) $author_link = $obj['actor']; else $author_link = ''; - $author_name = (($obj['author'] && $obj['author']['name']) ? $obj['author']['name'] : ''); + $author_name = $obj['author']['name'] ?? ''; if(!$author_name) - $author_name = ((is_array($obj['actor']) && $obj['actor']['name']) ? $obj['actor']['name'] : ''); + $author_name = $obj['actor']['name'] ?? ''; if(!$author_name && is_string($obj['actor'])) { $cached_actor = Activity::get_cached_actor($obj['actor']); if (is_array($cached_actor)) { - $author_name = (($cached_actor['name']) ? $cached_actor['name'] : $cached_actor['preferredUsername']); + $author_name = $cached_actor['name'] ?? $cached_actor['preferredUsername']; } } - if(is_array($obj['link'])) + $item_url = ''; + if(isset($obj['link']) && is_array($obj['link'])) $item_url = get_rel_link($obj['link'],'alternate'); if(!$item_url) @@ -1055,14 +1056,14 @@ function author_is_pmable($xchan, $abook) { function thread_author_menu($item, $mode = '') { $menu = []; - + $channel = []; $local_channel = local_channel(); if($local_channel) { if(! count(App::$contacts)) load_contact_links($local_channel); + $channel = App::get_channel(); - $channel_hash = (($channel) ? $channel['channel_hash'] : ''); } $profile_link = chanlink_hash($item['author_xchan']); @@ -1070,7 +1071,7 @@ function thread_author_menu($item, $mode = '') { $follow_url = ''; - if($channel['channel_hash'] !== $item['author_xchan']) { + if(isset($channel['channel_hash']) && $channel['channel_hash'] !== $item['author_xchan']) { if(App::$contacts && array_key_exists($item['author_xchan'],App::$contacts)) { $contact = App::$contacts[$item['author_xchan']]; } diff --git a/include/event.php b/include/event.php index f62c22792..0805bd2fe 100644 --- a/include/event.php +++ b/include/event.php @@ -28,7 +28,7 @@ function format_event_html($ev) { if(! ((is_array($ev)) && count($ev))) return ''; - $tz = (($ev['timezone']) ? $ev['timezone'] : 'UTC'); + $tz = $ev['timezone'] ?? 'UTC'; $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8:01 AM @@ -39,9 +39,9 @@ function format_event_html($ev) { $o .= '<div class="event-title"><h3><i class="fa fa-calendar"></i> ' . zidify_links(smilies(bbcode($ev['summary']))) . '</h3></div>' . "\r\n"; $o .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span> <span class="dtstart" title="' - . datetime_convert('UTC', 'UTC', $ev['dtstart'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) + . datetime_convert('UTC', 'UTC', $ev['dtstart'], ((isset($ev['adjust']) && $ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) . '" >' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . ((isset($ev['adjust']) && $ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtstart'] , $bd_format))) @@ -49,9 +49,9 @@ function format_event_html($ev) { if(! $ev['nofinish']) $o .= '<div class="event-end" ><span class="event-label">' . t('Finishes:') . '</span> <span class="dtend" title="' - . datetime_convert('UTC','UTC',$ev['dtend'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) + . datetime_convert('UTC','UTC',$ev['dtend'], ((isset($ev['adjust']) && $ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) . '" >' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . ((isset($ev['adjust']) && $ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtend'] , $bd_format ))) @@ -59,7 +59,7 @@ function format_event_html($ev) { $o .= '<div class="event-description">' . zidify_links(smilies(bbcode($ev['description']))) . '</div>' . "\r\n"; - if(strlen($ev['location'])) + if(isset($ev['location']) && $ev['location']) $o .= '<div class="event-location"><span class="event-label"> ' . t('Location:') . '</span> <span class="location">' . zidify_links(smilies(bbcode($ev['location']))) . '</span></div>' . "\r\n"; diff --git a/include/feedutils.php b/include/feedutils.php index 734018922..33bacc2bb 100644 --- a/include/feedutils.php +++ b/include/feedutils.php @@ -270,18 +270,17 @@ function get_atom_author($feed, $item) { $found_author = $item->get_author(); if($found_author) { - /// @FIXME $rawauthor is undefined here + $rawauthor = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); + hz_syslog('rawauthor: ' . print_r($rawauthor, true)); + if($rawauthor) { - if($rawauthor[0]['child'][NAMESPACE_POCO]['displayName'][0]['data']) + if(isset($rawauthor[0]['child'][NAMESPACE_POCO]['displayName'][0]['data'])) $author['full_name'] = unxmlify($rawauthor[0]['child'][NAMESPACE_POCO]['displayName'][0]['data']); } + $author['author_name'] = unxmlify($found_author->get_name()); $author['author_link'] = unxmlify($found_author->get_link()); $author['author_is_feed'] = false; - - $rawauthor = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author'); - //logger('rawauthor: ' . print_r($rawauthor, true)); - } else { $author['author_name'] = unxmlify($feed->get_title()); @@ -497,6 +496,7 @@ function get_atom_elements($feed, $item) { $res['verb'] = unxmlify($rawverb[0]['data']); } + $ostatus_conversation = ''; $rawcnv = $item->get_item_tags(NAMESPACE_OSTATUS, 'conversation'); if($rawcnv) { // new style @@ -1434,9 +1434,9 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { if($author['author_link'] != $contact['xchan_url']) { $name = ''; - if($author['full_name']) { + if(isset($author['full_name'])) { $name = $author['full_name']; - if($author['author_name']) + if(isset($author['author_name'])) $name .= ' (' . $author['author_name'] . ')'; } else { @@ -1468,8 +1468,8 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { // Update content if 'updated' changes if($r) { - if(activity_match($datarray['verb'],ACTIVITY_DELETE) - && $datarray['author_xchan'] === $r[0]['author_xchan']) { + if(isset($datarray['verb']) && activity_match($datarray['verb'], ACTIVITY_DELETE) + && isset($datarray['author_xchan']) && $datarray['author_xchan'] === $r[0]['author_xchan']) { if(! intval($r[0]['item_deleted'])) { logger('deleting item ' . $r[0]['id'] . ' mid=' . $datarray['mid'], LOGGER_DEBUG); drop_item($r[0]['id'],false); @@ -1498,11 +1498,11 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) { $datarray['uid'] = $importer['channel_id']; $datarray['aid'] = $importer['channel_account_id']; - if(! link_compare($author['owner_link'], $contact['xchan_url'])) { + if(isset($author['owner_link']) && !link_compare($author['owner_link'], $contact['xchan_url'])) { logger('Correcting item owner.', LOGGER_DEBUG); - $author['owner_name'] = $contact['name']; - $author['owner_link'] = $contact['url']; - $author['owner_avatar'] = $contact['thumb']; + $author['owner_name'] = $contact['xchan_name']; + $author['owner_link'] = $contact['xchan_url']; + $author['owner_avatar'] = $contact['xchan_photo_m']; } if($importer['channel_system']) { diff --git a/include/items.php b/include/items.php index d4c27ab28..c8b032806 100644 --- a/include/items.php +++ b/include/items.php @@ -1163,8 +1163,7 @@ function encode_item($item,$mirror = false,$zap_compat = false) { if($item['comments_closed'] > NULL_DATE) $x['comments_closed'] = $item['comments_closed']; - $x['public_scope'] = $scope; - + $x['public_scope'] = $item['public_policy']; $x['comment_scope'] = $item['comment_policy']; if(! empty($item['term'])) @@ -2432,17 +2431,14 @@ function send_status_notifications($post_id,$item) { return; // my own post - no notification needed - if($item['author_xchan'] === $r[0]['channel_hash']) + if(isset($item['author_xchan']) && $item['author_xchan'] === $r[0]['channel_hash']) return; - // I'm the owner - notify me - - if($item['owner_hash'] === $r[0]['channel_hash']) + if(isset($item['owner_hash']) && $item['owner_hash'] === $r[0]['channel_hash']) $notify = true; // Was I involved in this conversation? - $x = q("select * from item where parent_mid = '%s' and uid = %d", dbesc($item['parent_mid']), intval($item['uid']) diff --git a/include/nav.php b/include/nav.php index 0097a206b..65d5a3ef6 100644 --- a/include/nav.php +++ b/include/nav.php @@ -416,9 +416,6 @@ function channel_apps($is_owner = false, $nickname = null) { $has_webpages = (($r) ? true : false); - if (x($_GET, 'tab')) - $tab = notags(trim($_GET['tab'])); - $url = z_root() . '/channel/' . $nickname; $pr = z_root() . '/profile/' . $nickname; @@ -524,7 +521,7 @@ function channel_apps($is_owner = false, $nickname = null) { ]; } - $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs]; + $arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tabs' => $tabs]; call_hooks('channel_apps', $arr); diff --git a/include/text.php b/include/text.php index 87aaf7bf8..63b472bbd 100644 --- a/include/text.php +++ b/include/text.php @@ -1836,6 +1836,7 @@ function prepare_body(&$item,$attach = false,$opts = false) { $categories = format_categories($item,$writeable); + $filer = ''; if(local_channel() == $item['uid']) $filer = format_filer($item); |