Warnings fixed

This commit is contained in:
Michael 2018-07-08 09:37:05 +00:00
parent c25c3b5981
commit 3e797547a3
17 changed files with 55 additions and 45 deletions

View file

@ -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 // $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)) { if (is_null($user) && ($a->argc > (count($called_api) - 1)) && (count($called_api) > 0)) {
$argid = count($called_api); $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)) { if (is_numeric($user)) {
$user = dbesc(api_unique_id_to_nurl(intval($user))); $user = dbesc(api_unique_id_to_nurl(intval($user)));

View file

@ -65,13 +65,13 @@ function display_init(App $a)
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $a->argv[2], 'private' => false, 'uid' => 0]); $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; $a->error = 404;
notice(L10n::t('Item not found.') . EOL); notice(L10n::t('Item not found.') . EOL);
return; 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); logger('Directly serving XML for id '.$item["id"], LOGGER_DEBUG);
displayShowFeed($item["id"], false); displayShowFeed($item["id"], false);
} }
@ -347,19 +347,20 @@ function display_content(App $a, $update = false, $update_uid = 0)
Item::update(['unseen' => false], $condition); 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) { if (!$update) {
$o .= "<script> var netargs = '?f=&item_id=" . $item_id . "'; </script>"; $o .= "<script> var netargs = '?f=&item_id=" . $item_id . "'; </script>";
} }
$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 // Preparing the meta header
$description = trim(HTML::toPlaintext(BBCode::convert($s[0]["body"], false), 0, true)); $description = trim(HTML::toPlaintext(BBCode::convert($items["body"], false), 0, true));
$title = trim(HTML::toPlaintext(BBCode::convert($s[0]["title"], false), 0, true)); $title = trim(HTML::toPlaintext(BBCode::convert($items["title"], false), 0, true));
$author_name = $s[0]["author-name"]; $author_name = $items["author-name"];
$image = $a->remove_baseurl($s[0]["author-thumb"]); $image = $a->remove_baseurl($items["author-thumb"]);
if ($title == "") { if ($title == "") {
$title = $author_name; $title = $author_name;
@ -391,7 +392,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
$a->page['htmlhead'] .= '<meta name="twitter:title" content="'.$title.'" />'."\n"; $a->page['htmlhead'] .= '<meta name="twitter:title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:description" content="'.$description.'" />'."\n"; $a->page['htmlhead'] .= '<meta name="twitter:description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:image" content="'.System::baseUrl().'/'.$image.'" />'."\n"; $a->page['htmlhead'] .= '<meta name="twitter:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$s[0]["plink"].'" />'."\n"; $a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$items["plink"].'" />'."\n";
// Dublin Core // Dublin Core
$a->page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n"; $a->page['htmlhead'] .= '<meta name="DC.title" content="'.$title.'" />'."\n";
@ -401,7 +402,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
$a->page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n"; $a->page['htmlhead'] .= '<meta property="og:type" content="website" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n"; $a->page['htmlhead'] .= '<meta property="og:title" content="'.$title.'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:image" content="'.System::baseUrl().'/'.$image.'" />'."\n"; $a->page['htmlhead'] .= '<meta property="og:image" content="'.System::baseUrl().'/'.$image.'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:url" content="'.$s[0]["plink"].'" />'."\n"; $a->page['htmlhead'] .= '<meta property="og:url" content="'.$items["plink"].'" />'."\n";
$a->page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n"; $a->page['htmlhead'] .= '<meta property="og:description" content="'.$description.'" />'."\n";
$a->page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n"; $a->page['htmlhead'] .= '<meta name="og:article:author" content="'.$author_name.'" />'."\n";
// article:tag // article:tag

View file

@ -11,7 +11,7 @@ use Friendica\Database\DBM;
function friendica_init(App $a) 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']; $register_policy = ['REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN'];
$sql_extra = ''; $sql_extra = '';

View file

@ -699,9 +699,7 @@ function networkThreadedView(App $a, $update, $parent)
$order_mode = 'commented'; $order_mode = 'commented';
} }
if ($sql_order == '') { $sql_order = "$sql_table.$ordering";
$sql_order = "$sql_table.$ordering";
}
if (x($_GET, 'offset')) { if (x($_GET, 'offset')) {
$sql_range = sprintf(" AND $sql_order <= '%s'", dbesc($_GET['offset'])); $sql_range = sprintf(" AND $sql_order <= '%s'", dbesc($_GET['offset']));

View file

@ -130,7 +130,7 @@ function ping_init(App $a)
$condition = ["`unseen` AND `uid` = ? AND `contact-id` != ?", local_user(), local_user()]; $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ?", local_user(), local_user()];
$fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar', $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]]; $params = ['order' => ['created' => true]];
$items = Item::selectForUser(local_user(), $fields, $condition, $params); $items = Item::selectForUser(local_user(), $fields, $condition, $params);
@ -487,7 +487,7 @@ function ping_get_notifications($uid)
if ($notification["visible"] if ($notification["visible"]
&& !$notification["deleted"] && !$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? // Should we condense the notifications or show them all?
if (PConfig::get(local_user(), 'system', 'detailed_notif')) { if (PConfig::get(local_user(), 'system', 'detailed_notif')) {

View file

@ -43,9 +43,7 @@ function receive_post(App $a)
logger('mod-diaspora: receiving post', LOGGER_DEBUG); logger('mod-diaspora: receiving post', LOGGER_DEBUG);
$xml = urldecode($_POST['xml']); if (empty($_POST['xml'])) {
if (!$xml) {
$postdata = file_get_contents("php://input"); $postdata = file_get_contents("php://input");
if ($postdata == '') { if ($postdata == '') {
System::httpExit(500); System::httpExit(500);
@ -54,6 +52,8 @@ function receive_post(App $a)
logger('mod-diaspora: message is in the new format', LOGGER_DEBUG); logger('mod-diaspora: message is in the new format', LOGGER_DEBUG);
$msg = Diaspora::decodeRaw($importer, $postdata); $msg = Diaspora::decodeRaw($importer, $postdata);
} else { } else {
$xml = urldecode($_POST['xml']);
logger('mod-diaspora: decode message in the old format', LOGGER_DEBUG); logger('mod-diaspora: decode message in the old format', LOGGER_DEBUG);
$msg = Diaspora::decode($importer, $xml); $msg = Diaspora::decode($importer, $xml);

View file

@ -571,9 +571,9 @@ class BBCode extends BaseObject
$return = sprintf('<div class="type-%s">', $data["type"]); $return = sprintf('<div class="type-%s">', $data["type"]);
} }
if ($data["image"] != "") { if (!empty($data["image"])) {
$return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]); $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-image" /></a><br />', $data["url"], self::proxyUrl($data["image"], $simplehtml), $data["title"]);
} elseif ($data["preview"] != "") { } elseif (!empty($data["preview"])) {
$return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]); $return .= sprintf('<a href="%s" target="_blank"><img src="%s" alt="" title="%s" class="attachment-preview" /></a><br />', $data["url"], self::proxyUrl($data["preview"], $simplehtml), $data["title"]);
} }

View file

@ -144,6 +144,10 @@ class L10n
{ {
$a = get_app(); $a = get_app();
if (empty($s)) {
return '';
}
if (x($a->strings, $s)) { if (x($a->strings, $s)) {
$t = $a->strings[$s]; $t = $a->strings[$s];
$s = is_array($t) ? $t[0] : $t; $s = is_array($t) ? $t[0] : $t;

View file

@ -152,12 +152,8 @@ EOT;
if (isset($description["title"])) { if (isset($description["title"])) {
$tpl = get_markup_template('http_status.tpl'); $tpl = get_markup_template('http_status.tpl');
echo replace_macros( echo replace_macros($tpl, ['$title' => $description["title"],
$tpl, '$description' => defaults($description, 'description', '')]);
[
'$title' => $description["title"],
'$description' => $description["description"]]
);
} }
killme(); killme();

View file

@ -662,6 +662,11 @@ class GContact
$last_failure_str = ''; $last_failure_str = '';
$last_contact_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])) { if (in_array($contact["network"], [NETWORK_PHANTOM])) {
logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG); logger("Invalid network for contact url ".$contact["url"]." - Called by: ".System::callstack(), LOGGER_DEBUG);
return false; return false;

View file

@ -1030,10 +1030,8 @@ class Item extends BaseObject
private static function guid($item, $notify) private static function guid($item, $notify)
{ {
$guid = notags(trim($item['guid'])); if (!empty($item['guid'])) {
return notags(trim($item['guid']));
if (!empty($guid)) {
return $guid;
} }
if ($notify) { if ($notify) {

View file

@ -356,8 +356,8 @@ class Post extends BaseObject
'guid' => urlencode($item['guid']), 'guid' => urlencode($item['guid']),
'isevent' => $isevent, 'isevent' => $isevent,
'attend' => $attend, 'attend' => $attend,
'linktitle' => L10n::t('View %s\'s profile @ %s', $profile_name, defaults($item, 'author-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()), defaults($item, 'owner-link', $item['url'])), 'olinktitle' => L10n::t('View %s\'s profile @ %s', htmlentities($this->getOwnerName()), $item['owner-link']),
'to' => L10n::t('to'), 'to' => L10n::t('to'),
'via' => L10n::t('via'), 'via' => L10n::t('via'),
'wall' => L10n::t('Wall-to-Wall'), 'wall' => L10n::t('Wall-to-Wall'),

View file

@ -952,10 +952,10 @@ class DFRN
if (isset($parent_item)) { if (isset($parent_item)) {
$conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]); $conversation = dba::selectFirst('conversation', ['conversation-uri', 'conversation-href'], ['item-uri' => $item['parent-uri']]);
if (DBM::is_result($conversation)) { if (DBM::is_result($conversation)) {
if ($r['conversation-uri'] != '') { if ($conversation['conversation-uri'] != '') {
$conversation_uri = $conversation['conversation-uri']; $conversation_uri = $conversation['conversation-uri'];
} }
if ($r['conversation-href'] != '') { if ($conversation['conversation-href'] != '') {
$conversation_href = $conversation['conversation-href']; $conversation_href = $conversation['conversation-href'];
} }
} }

View file

@ -1349,7 +1349,7 @@ class Diaspora
$author = ""; $author = "";
// Fetch the author - for the old and the new Diaspora version // 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; $author = (string)$source_xml->post->status_message->diaspora_handle;
} elseif ($source_xml->author && ($source_xml->getName() == "status_message")) { } elseif ($source_xml->author && ($source_xml->getName() == "status_message")) {
$author = (string)$source_xml->author; $author = (string)$source_xml->author;
@ -2165,7 +2165,7 @@ class Diaspora
} }
// Send all existing comments and likes to the requesting server // 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)) { while ($comment = Item::fetch($comments)) {
if ($comment['id'] == $comment['parent']) { if ($comment['id'] == $comment['parent']) {
continue; continue;

View file

@ -1173,12 +1173,12 @@ class OStatus
$guid = ""; $guid = "";
preg_match("/guid='(.*?)'/ism", $attributes, $matches); preg_match("/guid='(.*?)'/ism", $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$guid = $matches[1]; $guid = $matches[1];
} }
preg_match('/guid="(.*?)"/ism', $attributes, $matches); preg_match('/guid="(.*?)"/ism', $attributes, $matches);
if ($matches[1] != "") { if (!empty($matches[1])) {
$guid = $matches[1]; $guid = $matches[1];
} }

View file

@ -61,7 +61,7 @@ class Delivery extends BaseObject
$condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false]; $condition = ['id' => [$item_id, $parent_id], 'visible' => true, 'moderated' => false];
$params = ['order' => ['id']]; $params = ['order' => ['id']];
$itemdata = Item::select([], $condition, $params); $itemdata = Item::select(Item::ITEM_FIELDLIST, $condition, $params);
$items = []; $items = [];
while ($item = Item::fetch($itemdata)) { while ($item = Item::fetch($itemdata)) {
@ -259,6 +259,10 @@ class Delivery extends BaseObject
return; 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 // Set the user id. This is important if this is a public contact
$target_importer['importer_uid'] = $target_uid; $target_importer['importer_uid'] = $target_uid;
DFRN::import($atom, $target_importer); DFRN::import($atom, $target_importer);

View file

@ -29,10 +29,12 @@ function vier_init(App $a)
$a->set_template_engine('smarty3'); $a->set_template_engine('smarty3');
if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) { if (!empty($a->argv[0]) && !empty($a->argv[1])) {
vier_community_info(); if ($a->argv[0].$a->argv[1] === "profile".$a->user['nickname'] || $a->argv[0] === "network" && local_user()) {
vier_community_info();
$a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n"; $a->page['htmlhead'] .= "<link rel='stylesheet' type='text/css' href='view/theme/vier/wide.css' media='screen and (min-width: 1300px)'/>\n";
}
} }
if ($a->is_mobile || $a->is_tablet) { if ($a->is_mobile || $a->is_tablet) {
@ -104,7 +106,7 @@ EOT;
// Hide the left menu bar // Hide the left menu bar
/// @TODO maybe move this static array out where it should belong? /// @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"])) { "probe", "webfinger", "login", "invite", "credits"])) {
$a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />"; $a->page['htmlhead'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
} }