From 342b9af73431aeda10b331f36e13bf5e69a2d58d Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Mon, 12 Feb 2018 16:08:28 +0100 Subject: [PATCH 1/3] fix undeclared variables or wrong variable names (/src) --- src/Content/Text/BBCode.php | 2 +- src/Content/Widget.php | 2 +- src/Model/Conversation.php | 2 +- src/Model/Item.php | 2 ++ src/Model/Profile.php | 1 + src/Util/DateTimeFormat.php | 8 ++++---- src/Util/Network.php | 3 +++ src/Util/Temporal.php | 2 ++ 8 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index bd2a73472..14f98202e 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -1115,7 +1115,7 @@ class BBCode $text = $preshare . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . ' ' . $userid_compact . ":
" . $share[3]; break; case 3: // Diaspora - $headline .= '' . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . $userid . ':
'; + $headline = '' . html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8') . $userid . ':
'; $text = trim($share[1]); diff --git a/src/Content/Widget.php b/src/Content/Widget.php index c66a4ea9d..d25724298 100644 --- a/src/Content/Widget.php +++ b/src/Content/Widget.php @@ -51,7 +51,7 @@ class Widget if ($x || is_site_admin()) { $a->page['aside'] .= '' . $inv; + . ''; } } diff --git a/src/Model/Conversation.php b/src/Model/Conversation.php index 3f9b3c7e5..cd51a537e 100644 --- a/src/Model/Conversation.php +++ b/src/Model/Conversation.php @@ -66,7 +66,7 @@ class Conversation unset($conversation['source']); } if (!dba::update('conversation', $conversation, ['item-uri' => $conversation['item-uri']], $old_conv)) { - logger('Conversation: update for '.$conversation['item-uri'].' from '.$conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG); + logger('Conversation: update for '.$conversation['item-uri'].' from '.$old_conv['protocol'].' to '.$conversation['protocol'].' failed', LOGGER_DEBUG); } } else { if (!dba::insert('conversation', $conversation, true)) { diff --git a/src/Model/Item.php b/src/Model/Item.php index d09681579..400bc549b 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -263,6 +263,7 @@ class Item extends BaseObject } $arr['guid'] = notags(trim(defaults($arr, 'guid', get_guid(32, $guid_prefix)))); + /// @todo Declare $uid variable - Rabuzarus - 2018-02-12. $arr['uri'] = notags(trim(defaults($arr, 'uri', item_new_uri($a->get_hostname(), $uid, $arr['guid'])))); // Store conversation data @@ -1294,6 +1295,7 @@ class Item extends BaseObject return; } + /// @todo Declare $r or lets remove it - Rabuzarus - 2018-02-12. $arr = ['item' => $item, 'user' => $u[0], 'contact' => $r[0]]; Addon::callHooks('tagged', $arr); diff --git a/src/Model/Profile.php b/src/Model/Profile.php index 002b647ff..f79b89014 100644 --- a/src/Model/Profile.php +++ b/src/Model/Profile.php @@ -625,6 +625,7 @@ class Profile require_once 'include/bbcode.php'; $a = get_app(); + $o = ''; if (!local_user() || $a->is_mobile || $a->is_tablet) { return $o; diff --git a/src/Util/DateTimeFormat.php b/src/Util/DateTimeFormat.php index b039ff80a..31876d742 100644 --- a/src/Util/DateTimeFormat.php +++ b/src/Util/DateTimeFormat.php @@ -90,12 +90,12 @@ class DateTimeFormat { // Defaults to UTC if nothing is set, but throws an exception if set to empty string. // Provide some sane defaults regardless. - if ($from === '') { - $from = 'UTC'; + if ($tz_from === '') { + $tz_from = 'UTC'; } - if ($to === '') { - $to = 'UTC'; + if ($tz_to === '') { + $tz_to = 'UTC'; } if (($s === '') || (!is_string($s))) { diff --git a/src/Util/Network.php b/src/Util/Network.php index 85880a949..c9955f800 100644 --- a/src/Util/Network.php +++ b/src/Util/Network.php @@ -370,6 +370,9 @@ class Network if ($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) { $matches = []; + $new_location_info = @parse_url($curl_info['redirect_url']); + $old_location_info = @parse_url($curl_info['url']); + preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches); $newurl = trim(array_pop($matches)); diff --git a/src/Util/Temporal.php b/src/Util/Temporal.php index 3c898ce4c..1ed08ed1d 100644 --- a/src/Util/Temporal.php +++ b/src/Util/Temporal.php @@ -127,6 +127,8 @@ class Temporal */ public static function getDateofBirthField($dob) { + $a = get_app(); + list($year, $month, $day) = sscanf($dob, '%4d-%2d-%2d'); if ($dob < '0000-01-01') { From 58b41690976e1c46f19a84d599d4b19af1a906da Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Mon, 12 Feb 2018 16:56:52 +0100 Subject: [PATCH 2/3] fix undeclared $uid variables in Item::insert() --- src/Model/Item.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 400bc549b..40c898024 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -263,8 +263,7 @@ class Item extends BaseObject } $arr['guid'] = notags(trim(defaults($arr, 'guid', get_guid(32, $guid_prefix)))); - /// @todo Declare $uid variable - Rabuzarus - 2018-02-12. - $arr['uri'] = notags(trim(defaults($arr, 'uri', item_new_uri($a->get_hostname(), $uid, $arr['guid'])))); + $arr['uri'] = notags(trim(defaults($arr, 'uri', item_new_uri($a->get_hostname(), $arr['uid'], $arr['guid'])))); // Store conversation data $arr = Conversation::insert($arr); From af3a57376a2d79455aa8d767b18e48a2b25ee2aa Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Mon, 12 Feb 2018 17:05:01 +0100 Subject: [PATCH 3/3] Item::tagDeliver(): remove contact as array key for hooks because it was never declared --- doc/Addons.md | 2 ++ src/Model/Item.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/Addons.md b/doc/Addons.md index 5d1310776..dadf76abd 100644 --- a/doc/Addons.md +++ b/doc/Addons.md @@ -471,3 +471,5 @@ mod/cb.php: Addon::callHooks('cb_afterpost'); mod/cb.php: Addon::callHooks('cb_content', $o); mod/directory.php: Addon::callHooks('directory_item', $arr); + +src/Model/Item.php Addon::callHooks('tagged', $arr); diff --git a/src/Model/Item.php b/src/Model/Item.php index 40c898024..fae3394bc 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1294,8 +1294,7 @@ class Item extends BaseObject return; } - /// @todo Declare $r or lets remove it - Rabuzarus - 2018-02-12. - $arr = ['item' => $item, 'user' => $u[0], 'contact' => $r[0]]; + $arr = ['item' => $item, 'user' => $u[0]]; Addon::callHooks('tagged', $arr);