diff --git a/include/api.php b/include/api.php
index ad991485a..42868aa9e 100644
--- a/include/api.php
+++ b/include/api.php
@@ -579,7 +579,9 @@ function api_get_user(App $a, $contact_id = null)
// $called_api is the API path exploded on / and is expected to have at least 2 elements
if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api);
- list($user, $null) = explode(".", $a->argv[$argid]);
+ if (!empty($a->argv[$argid])) {
+ list($user, $null) = explode(".", $a->argv[$argid]);
+ }
if (is_numeric($user)) {
$user = dbesc(api_unique_id_to_nurl(intval($user)));
diff --git a/mod/display.php b/mod/display.php
index 920cb454f..10862d57c 100644
--- a/mod/display.php
+++ b/mod/display.php
@@ -65,13 +65,13 @@ function display_init(App $a)
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $a->argv[2], 'private' => false, 'uid' => 0]);
}
- if (!DBM::is_result($item) || $item['deleted']) {
+ if (!DBM::is_result($item)) {
$a->error = 404;
notice(L10n::t('Item not found.') . EOL);
return;
}
- if (strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
+ if (!empty($_SERVER['HTTP_ACCEPT']) && strstr($_SERVER['HTTP_ACCEPT'], 'application/atom+xml')) {
logger('Directly serving XML for id '.$item["id"], LOGGER_DEBUG);
displayShowFeed($item["id"], false);
}
@@ -347,19 +347,20 @@ function display_content(App $a, $update = false, $update_uid = 0)
Item::update(['unseen' => false], $condition);
}
- $items = conv_sort(Item::inArray($items_obj), "`commented`");
+ $items = Item::inArray($items_obj);
+ $conversation_items = conv_sort($items, "`commented`");
if (!$update) {
$o .= "";
}
- $o .= conversation($a, $items, 'display', $update_uid, false, 'commented', local_user());
+ $o .= conversation($a, $conversation_items, 'display', $update_uid, false, 'commented', local_user());
// Preparing the meta header
- $description = trim(HTML::toPlaintext(BBCode::convert($s[0]["body"], false), 0, true));
- $title = trim(HTML::toPlaintext(BBCode::convert($s[0]["title"], false), 0, true));
- $author_name = $s[0]["author-name"];
+ $description = trim(HTML::toPlaintext(BBCode::convert($items["body"], false), 0, true));
+ $title = trim(HTML::toPlaintext(BBCode::convert($items["title"], false), 0, true));
+ $author_name = $items["author-name"];
- $image = $a->remove_baseurl($s[0]["author-thumb"]);
+ $image = $a->remove_baseurl($items["author-thumb"]);
if ($title == "") {
$title = $author_name;
@@ -391,7 +392,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
$a->page['htmlhead'] .= ''."\n";
$a->page['htmlhead'] .= ''."\n";
$a->page['htmlhead'] .= ''."\n";
- $a->page['htmlhead'] .= ''."\n";
+ $a->page['htmlhead'] .= ''."\n";
// Dublin Core
$a->page['htmlhead'] .= ''."\n";
@@ -401,7 +402,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
$a->page['htmlhead'] .= ''."\n";
$a->page['htmlhead'] .= ''."\n";
$a->page['htmlhead'] .= ''."\n";
- $a->page['htmlhead'] .= ''."\n";
+ $a->page['htmlhead'] .= ''."\n";
$a->page['htmlhead'] .= ''."\n";
$a->page['htmlhead'] .= ''."\n";
// article:tag
diff --git a/mod/friendica.php b/mod/friendica.php
index 1929150f2..e75e9ceba 100644
--- a/mod/friendica.php
+++ b/mod/friendica.php
@@ -11,7 +11,7 @@ use Friendica\Database\DBM;
function friendica_init(App $a)
{
- if ($a->argv[1] == "json") {
+ if (!empty($a->argv[1]) && ($a->argv[1] == "json")) {
$register_policy = ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'];
$sql_extra = '';
diff --git a/mod/network.php b/mod/network.php
index 7c1ff0afa..98ffd741f 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -699,9 +699,7 @@ function networkThreadedView(App $a, $update, $parent)
$order_mode = 'commented';
}
- if ($sql_order == '') {
- $sql_order = "$sql_table.$ordering";
- }
+ $sql_order = "$sql_table.$ordering";
if (x($_GET, 'offset')) {
$sql_range = sprintf(" AND $sql_order <= '%s'", dbesc($_GET['offset']));
diff --git a/mod/ping.php b/mod/ping.php
index 8028d69ed..cbd280f53 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -130,7 +130,7 @@ function ping_init(App $a)
$condition = ["`unseen` AND `uid` = ? AND `contact-id` != ?", local_user(), local_user()];
$fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
- 'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid'];
+ 'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall'];
$params = ['order' => ['created' => true]];
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
@@ -487,7 +487,7 @@ function ping_get_notifications($uid)
if ($notification["visible"]
&& !$notification["deleted"]
- && !(x($result, $notification["parent"]) && is_array($result[$notification["parent"]]))
+ && !(x($result, $notification["parent"]) && !empty($result[$notification["parent"]]))
) {
// Should we condense the notifications or show them all?
if (PConfig::get(local_user(), 'system', 'detailed_notif')) {
diff --git a/mod/receive.php b/mod/receive.php
index 41f2225cb..adb758e38 100644
--- a/mod/receive.php
+++ b/mod/receive.php
@@ -43,9 +43,7 @@ function receive_post(App $a)
logger('mod-diaspora: receiving post', LOGGER_DEBUG);
- $xml = urldecode($_POST['xml']);
-
- if (!$xml) {
+ if (empty($_POST['xml'])) {
$postdata = file_get_contents("php://input");
if ($postdata == '') {
System::httpExit(500);
@@ -54,6 +52,8 @@ function receive_post(App $a)
logger('mod-diaspora: message is in the new format', LOGGER_DEBUG);
$msg = Diaspora::decodeRaw($importer, $postdata);
} else {
+ $xml = urldecode($_POST['xml']);
+
logger('mod-diaspora: decode message in the old format', LOGGER_DEBUG);
$msg = Diaspora::decode($importer, $xml);
diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php
index 33b3503ec..b4270fec6 100644
--- a/src/Content/Text/BBCode.php
+++ b/src/Content/Text/BBCode.php
@@ -571,9 +571,9 @@ class BBCode extends BaseObject
$return = sprintf('
', $data["type"]);
}
- if ($data["image"] != "") {
+ if (!empty($data["image"])) {
$return .= sprintf('
', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
- } elseif ($data["preview"] != "") {
+ } elseif (!empty($data["preview"])) {
$return .= sprintf('
', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]);
}
diff --git a/src/Core/L10n.php b/src/Core/L10n.php
index 277b3401d..24be01095 100644
--- a/src/Core/L10n.php
+++ b/src/Core/L10n.php
@@ -144,6 +144,10 @@ class L10n
{
$a = get_app();
+ if (empty($s)) {
+ return '';
+ }
+
if (x($a->strings, $s)) {
$t = $a->strings[$s];
$s = is_array($t) ? $t[0] : $t;
diff --git a/src/Core/System.php b/src/Core/System.php
index abc39e5a2..84a64ab9a 100644
--- a/src/Core/System.php
+++ b/src/Core/System.php
@@ -152,12 +152,8 @@ EOT;
if (isset($description["title"])) {
$tpl = get_markup_template('http_status.tpl');
- echo replace_macros(
- $tpl,
- [
- '$title' => $description["title"],
- '$description' => $description["description"]]
- );
+ echo replace_macros($tpl, ['$title' => $description["title"],
+ '$description' => defaults($description, 'description', '')]);
}
killme();
diff --git a/src/Model/GContact.php b/src/Model/GContact.php
index c413bef4f..488435331 100644
--- a/src/Model/GContact.php
+++ b/src/Model/GContact.php
@@ -662,6 +662,11 @@ class GContact
$last_failure_str = '';
$last_contact_str = '';
+ if (empty($contact["network"])) {
+ logger("Empty network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
+ return false;
+ }
+
if (in_array($contact["network"], [NETWORK_PHANTOM])) {
logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
return false;
diff --git a/src/Model/Item.php b/src/Model/Item.php
index 162387185..05254b8eb 100644
--- a/src/Model/Item.php
+++ b/src/Model/Item.php
@@ -1030,10 +1030,8 @@ class Item extends BaseObject
private static function guid($item, $notify)
{
- $guid = notags(trim($item['guid']));
-
- if (!empty($guid)) {
- return $guid;
+ if (!empty($item['guid'])) {
+ return notags(trim($item['guid']));
}
if ($notify) {
diff --git a/src/Object/Post.php b/src/Object/Post.php
index 216008974..f9da142fe 100644
--- a/src/Object/Post.php
+++ b/src/Object/Post.php
@@ -356,8 +356,8 @@ class Post extends BaseObject
'guid' => urlencode($item['guid']),
'isevent' => $isevent,
'attend' => $attend,
- 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, defaults($item, 'author-link', $item['url'])),
- 'olinktitle' => L10n::t('View %s\'s profile @ %s', htmlentities($this->getOwnerName()), defaults($item, 'owner-link', $item['url'])),
+ 'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, $item['author-link']),
+ 'olinktitle' => L10n::t('View %s\'s profile @ %s', htmlentities($this->getOwnerName()), $item['owner-link']),
'to' => L10n::t('to'),
'via' => L10n::t('via'),
'wall' => L10n::t('Wall-to-Wall'),
diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php
index 72ab89d92..6525601fe 100644
--- a/src/Protocol/DFRN.php
+++ b/src/Protocol/DFRN.php
@@ -952,10 +952,10 @@ class DFRN
if (isset($parent_item)) {
$conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]);
if (DBM::is_result($conversation)) {
- if ($r['conversation-uri'] != '') {
+ if ($conversation['conversation-uri'] != '') {
$conversation_uri = $conversation['conversation-uri'];
}
- if ($r['conversation-href'] != '') {
+ if ($conversation['conversation-href'] != '') {
$conversation_href = $conversation['conversation-href'];
}
}
diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php
index d567be144..2ce54317e 100644
--- a/src/Protocol/Diaspora.php
+++ b/src/Protocol/Diaspora.php
@@ -1349,7 +1349,7 @@ class Diaspora
$author = "";
// Fetch the author - for the old and the new Diaspora version
- if ($source_xml->post->status_message->diaspora_handle) {
+ if ($source_xml->post->status_message && $source_xml->post->status_message->diaspora_handle) {
$author = (string)$source_xml->post->status_message->diaspora_handle;
} elseif ($source_xml->author && ($source_xml->getName() == "status_message")) {
$author = (string)$source_xml->author;
@@ -2165,7 +2165,7 @@ class Diaspora
}
// Send all existing comments and likes to the requesting server
- $comments = Item::select(['id', 'verb', 'self'], ['parent' => $item['id']]);
+ $comments = Item::select(['id', 'parent', 'verb', 'self'], ['parent' => $item['id']]);
while ($comment = Item::fetch($comments)) {
if ($comment['id'] == $comment['parent']) {
continue;
diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php
index 4ef80ddca..40218b0df 100644
--- a/src/Protocol/OStatus.php
+++ b/src/Protocol/OStatus.php
@@ -1173,12 +1173,12 @@ class OStatus
$guid = "";
preg_match("/guid='(.*?)'/ism", $attributes, $matches);
- if ($matches[1] != "") {
+ if (!empty($matches[1])) {
$guid = $matches[1];
}
preg_match('/guid="(.*?)"/ism', $attributes, $matches);
- if ($matches[1] != "") {
+ if (!empty($matches[1])) {
$guid = $matches[1];
}
diff --git a/src/Worker/Delivery.php b/src/Worker/Delivery.php
index 0c8ff27fa..4e76c68f7 100644
--- a/src/Worker/Delivery.php
+++ b/src/Worker/Delivery.php
@@ -61,7 +61,7 @@ class Delivery extends BaseObject
$condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false];
$params = ['order' => ['id']];
- $itemdata = Item::select([], $condition, $params);
+ $itemdata = Item::select(Item::ITEM_FIELDLIST, $condition, $params);
$items = [];
while ($item = Item::fetch($itemdata)) {
@@ -259,6 +259,10 @@ class Delivery extends BaseObject
return;
}
+ $user = dba::selectFirst('user', [], ['uid' => $target_uid]);
+
+ $target_importer = array_merge($target_importer, $user);
+
// Set the user id. This is important if this is a public contact
$target_importer['importer_uid'] = $target_uid;
DFRN::import($atom, $target_importer);
diff --git a/view/theme/vier/theme.php b/view/theme/vier/theme.php
index cc08a7d71..b99433f81 100644
--- a/view/theme/vier/theme.php
+++ b/view/theme/vier/theme.php
@@ -29,10 +29,12 @@ function vier_init(App $a)
$a->set_template_engine('smarty3');
- if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
- vier_community_info();
+ if (!empty($a->argv[0]) && !empty($a->argv[1])) {
+ if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
+ vier_community_info();
- $a->page['htmlhead'] .= "
\n";
+ $a->page['htmlhead'] .= "
\n";
+ }
}
if ($a->is_mobile || $a->is_tablet) {
@@ -104,7 +106,7 @@ EOT;
// Hide the left menu bar
/// @TODO maybe move this static array out where it should belong?
- if (($a->page['aside'] == "") && in_array($a->argv[0], ["community", "events", "help", "manage", "notifications",
+ if (empty($a->page['aside']) && in_array($a->argv[0], ["community", "events", "help", "manage", "notifications",
"probe", "webfinger", "login", "invite", "credits"])) {
$a->page['htmlhead'] .= "
";
}