]> git.mxchange.org Git - friendica.git/commitdiff
Warnings fixed
authorMichael <heluecht@pirati.ca>
Sun, 8 Jul 2018 09:37:05 +0000 (09:37 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 8 Jul 2018 09:37:05 +0000 (09:37 +0000)
17 files changed:
include/api.php
mod/display.php
mod/friendica.php
mod/network.php
mod/ping.php
mod/receive.php
src/Content/Text/BBCode.php
src/Core/L10n.php
src/Core/System.php
src/Model/GContact.php
src/Model/Item.php
src/Object/Post.php
src/Protocol/DFRN.php
src/Protocol/Diaspora.php
src/Protocol/OStatus.php
src/Worker/Delivery.php
view/theme/vier/theme.php

index ad991485a4da241e0c536d0746f2e85f98c8fd0c..42868aa9eb81566c5f2587dafcdca9f3b2db4158 100644 (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
        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)));
 
index 920cb454f9fa959533107f0a35cfa665c4cfa46d..10862d57cca3ebef241741cac968ccd4baadc73f 100644 (file)
@@ -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 .= "<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
-       $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'] .= '<meta name="twitter:title" content="'.$title.'" />'."\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:url" content="'.$s[0]["plink"].'" />'."\n";
+       $a->page['htmlhead'] .= '<meta name="twitter:url" content="'.$items["plink"].'" />'."\n";
 
        // Dublin Core
        $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:title" content="'.$title.'" />'."\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 name="og:article:author" content="'.$author_name.'" />'."\n";
        // article:tag
index 1929150f27beb626ae4baad195798e807b578eb4..e75e9cebaeda19828c79a9df552eaa656d8e5336 100644 (file)
@@ -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 = '';
index 7c1ff0afa4ccb450f634210ea5972df551c14006..98ffd741f91eda204f60f81da82e4f39d24c1b26 100644 (file)
@@ -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']));
index 8028d69ed268be7bcda84be3a3aa1299472675b5..cbd280f5348446a89847f89364eb98ccf0ae3226 100644 (file)
@@ -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')) {
index 41f2225cb4d3a54b4f072d13eedb509f7b434d69..adb758e384451386158d16727b1717b23fb26233 100644 (file)
@@ -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);
 
index 33b3503eca4ab0e4999a911b3a7a76807eff17f9..b4270fec66dd5c7f5bd466d6645d0318e6b1f4f0 100644 (file)
@@ -571,9 +571,9 @@ class BBCode extends BaseObject
                                        $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"]);
-                               } 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"]);
                                }
 
index 277b3401df270437680e1f6f2fb158aa62265332..24be0109554b2e4ba0a02e98502ffbddc4a83e2a 100644 (file)
@@ -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;
index abc39e5a2a7650baa62136685c3ecf451e2ffab2..84a64ab9a8f4ee0d24d842eeb25d586c12bb49d1 100644 (file)
@@ -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();
index c413bef4fa9ebde5d1a5cf95aab08c663a6f1dd2..48843533119150e72ad46fd433888cbed86e6d55 100644 (file)
@@ -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;
index 162387185ee09a9e9fb8b9ad5084836d277a3773..05254b8eb12427d12142eda71f1237ecdd69a8b7 100644 (file)
@@ -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) {
index 216008974ab9525f4e7115ccd2d78421bab85ad8..f9da142fec245c6753afca7e952aaa5eb658147d 100644 (file)
@@ -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'),
index 72ab89d925992ac04f2e37b2f4ed466dc6fc243e..6525601feb2590d13e09d9e7760c7d4e26e6c8f5 100644 (file)
@@ -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'];
                                }
                        }
index d567be144d64599012ab8b6c7067d2b45d4ae31d..2ce54317eba82db136ed2beac6b423b8088c1a1f 100644 (file)
@@ -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;
index 4ef80ddca06f168daaaa459280aa48b0ffd2150c..40218b0dfd8b8de5cd0dd0784779a6598c84eb1d 100644 (file)
@@ -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];
                }
 
index 0c8ff27faf894d576303bba0a30decf2d61e8ce3..4e76c68f7955d40be8112b21748b561493ee82cc 100644 (file)
@@ -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);
index cc08a7d71fa442c39b8cf5de51bc0ee5de4f5217..b99433f81b3de12d1ed0f94ee86eb0397a581705 100644 (file)
@@ -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'] .= "<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) {
@@ -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'] .= "<link rel='stylesheet' href='view/theme/vier/hide.css' />";
        }