From c2a796b6ea4a8af23494e72e6c446ea847bf9627 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 3 Nov 2022 11:57:35 +0000 Subject: rename variable and warning fixes --- Zotlabs/Lib/Activity.php | 10 +++------ Zotlabs/Lib/Enotify.php | 2 +- Zotlabs/Lib/Libzot.php | 56 +++++++++++++++++++++++++--------------------- Zotlabs/Module/Acl.php | 2 +- Zotlabs/Module/Pconfig.php | 3 ++- 5 files changed, 37 insertions(+), 36 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index 1a34fdae6..180c533ef 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -2280,10 +2280,10 @@ class Activity { $mention = self::get_actor_bbmention($obj_actor['id']); if ($act->type === 'Like') { - $content['content'] = sprintf(t('Likes %1$s\'s %2$s'), $mention, $act->obj['type']) . "\n\n" . $content['content']; + $content['content'] = sprintf(t('Likes %1$s\'s %2$s'), $mention, $act->obj['type']) . "\n\n" . $content['content'] ?? ''; } if ($act->type === 'Dislike') { - $content['content'] = sprintf(t('Doesn\'t like %1$s\'s %2$s'), $mention, $act->obj['type']) . "\n\n" . $content['content']; + $content['content'] = sprintf(t('Doesn\'t like %1$s\'s %2$s'), $mention, $act->obj['type']) . "\n\n" . $content['content'] ?? ''; } // handle event RSVPs @@ -2791,11 +2791,7 @@ class Activity { call_hooks('decode_note', $hookinfo); - $s = $hookinfo['s']; - - - - return $s; + return $hookinfo['s']; } diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 67efe5e9d..2015b260d 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -869,7 +869,7 @@ class Enotify { $x = array( 'notify_link' => $item['llink'], 'name' => $item[$who]['xchan_name'], - 'addr' => (($item[$who]['xchan_addr']) ? $item[$who]['xchan_addr'] : $item[$who]['xchan_url']), + 'addr' => $item[$who]['xchan_addr'] ?? $item[$who]['xchan_url'], 'url' => $item[$who]['xchan_url'], 'photo' => $item[$who]['xchan_photo_s'], 'when' => (($edit) ? datetime_convert('UTC', date_default_timezone_get(), $item['edited']) : datetime_convert('UTC', date_default_timezone_get(), $item['created'])), diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php index 6a6e1c0e2..7adc56ae6 100644 --- a/Zotlabs/Lib/Libzot.php +++ b/Zotlabs/Lib/Libzot.php @@ -1148,7 +1148,7 @@ class Libzot { $result = null; - logger('Notify: ' . print_r($env, true), LOGGER_DATA, LOG_DEBUG); + hz_syslog('Notify: ' . print_r($env, true), LOGGER_DATA, LOG_DEBUG); if (!is_array($env)) { logger('decode error'); @@ -1172,10 +1172,14 @@ class Libzot { return; } if (is_array($AS->obj)) { - $arr = Activity::decode_note($AS); + $item = Activity::decode_note($AS); + if (!$item) { + logger('Could not decode activity: ' . print_r($AS, true)); + return; + } } else { - $arr = []; + $item = []; } logger($AS->debug(), LOGGER_DATA); @@ -1260,15 +1264,15 @@ class Libzot { if ($r) { $r = self::zot_record_preferred($r); - $arr['author_xchan'] = $r['hubloc_hash']; + $item['author_xchan'] = $r['hubloc_hash']; } - if (! $arr['author_xchan']) { + if (! $item['author_xchan']) { logger('No author!'); return; } - $arr['owner_xchan'] = $env['sender']; + $item['owner_xchan'] = $env['sender']; if(filter_var($env['sender'], FILTER_VALIDATE_URL)) { // in individual delivery, change owner if needed @@ -1277,67 +1281,67 @@ class Libzot { ); if ($s) { - $arr['owner_xchan'] = $s[0]['hubloc_hash']; + $item['owner_xchan'] = $s[0]['hubloc_hash']; } } - if (! $arr['owner_xchan']) { + if (! $item['owner_xchan']) { logger('No owner!'); return; } - if ($private && (!intval($arr['item_private']))) { - $arr['item_private'] = 1; + if ($private && (!intval($item['item_private']))) { + $item['item_private'] = 1; } - if ($arr['mid'] === $arr['parent_mid']) { + if ($item['mid'] === $item['parent_mid']) { if (is_array($AS->obj) && array_key_exists('commentPolicy', $AS->obj)) { $p = strstr($AS->obj['commentPolicy'], 'until='); if ($p !== false) { $comments_closed_at = datetime_convert('UTC', 'UTC', substr($p, 6)); - if ($comments_closed_at === $arr['created']) { - $arr['item_nocomment'] = 1; + if ($comments_closed_at === $item['created']) { + $item['item_nocomment'] = 1; } else { - $arr['comments_closed'] = $comments_closed_at; - $arr['comment_policy'] = trim(str_replace($p, '', $AS->obj['commentPolicy'])); + $item['comments_closed'] = $comments_closed_at; + $aritemr['comment_policy'] = trim(str_replace($p, '', $AS->obj['commentPolicy'])); } } else { - $arr['comment_policy'] = $AS->obj['commentPolicy']; + $item['comment_policy'] = $AS->obj['commentPolicy']; } } } if (isset($AS->meta['hubloc']) && $AS->meta['hubloc']) { - $arr['item_verified'] = true; + $item['item_verified'] = true; } - if (!array_key_exists('comment_policy', $arr)) { - $arr['comment_policy'] = 'authenticated'; + if (!array_key_exists('comment_policy', $item)) { + $item['comment_policy'] = 'authenticated'; } if (isset($AS->meta['signed_data']) && $AS->meta['signed_data']) { - IConfig::Set($arr, 'activitypub', 'signed_data', $AS->meta['signed_data'], false); + IConfig::Set($item, 'activitypub', 'signed_data', $AS->meta['signed_data'], false); } - logger('Activity received: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG); + logger('Activity received: ' . print_r($item, true), LOGGER_DATA, LOG_DEBUG); logger('Activity recipients: ' . print_r($deliveries, true), LOGGER_DATA, LOG_DEBUG); $relay = (($env['type'] === 'response') ? true : false); - $result = self::process_delivery($env['sender'], $AS, $arr, $deliveries, $relay, false, $message_request); + $result = self::process_delivery($env['sender'], $AS, $item, $deliveries, $relay, false, $message_request); } elseif ($env['type'] === 'sync') { - // $arr = get_channelsync_elements($data); + // $item = get_channelsync_elements($data); - $arr = json_decode($data, true); + $item = json_decode($data, true); - logger('Channel sync received: ' . print_r($arr, true), LOGGER_DATA, LOG_DEBUG); + logger('Channel sync received: ' . print_r($item, true), LOGGER_DATA, LOG_DEBUG); logger('Channel sync recipients: ' . print_r($deliveries, true), LOGGER_DATA, LOG_DEBUG); if ($env['encoding'] === 'hz') { - $result = Libsync::process_channel_sync_delivery($env['sender'], $arr, $deliveries); + $result = Libsync::process_channel_sync_delivery($env['sender'], $item, $deliveries); } else { logger('sync packet type not supported.'); diff --git a/Zotlabs/Module/Acl.php b/Zotlabs/Module/Acl.php index f8c6232c5..bcd79c873 100644 --- a/Zotlabs/Module/Acl.php +++ b/Zotlabs/Module/Acl.php @@ -304,7 +304,7 @@ class Acl extends \Zotlabs\Web\Controller { } elseif($type == 'a') { - $r = q("SELECT abook_id as id, xchan_name as name, xchan_network as net, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url, xchan_addr as attag , abook_their_perms FROM abook left join xchan on abook_xchan = xchan_hash + $r = q("SELECT abook_id as id, xchan_name as name, xchan_network as net, xchan_hash as hash, xchan_addr as nick, xchan_photo_s as micro, xchan_url as url, xchan_addr as attag, abook_their_perms, abook_self FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and xchan_deleted = 0 $sql_extra3 diff --git a/Zotlabs/Module/Pconfig.php b/Zotlabs/Module/Pconfig.php index 62d17e694..106254050 100644 --- a/Zotlabs/Module/Pconfig.php +++ b/Zotlabs/Module/Pconfig.php @@ -13,8 +13,9 @@ class Pconfig extends \Zotlabs\Web\Controller { return; - if(isset($_SESSION['delegate'])) + if(isset($_SESSION['delegate'])) { return; + } check_form_security_token_redirectOnErr('/pconfig', 'pconfig'); -- cgit v1.2.3