]> git.mxchange.org Git - friendica.git/commitdiff
Fix more undefined variable/index notice in tests
authorHypolite Petovan <mrpetovan@gmail.com>
Sun, 1 Jul 2018 08:03:57 +0000 (04:03 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Mon, 2 Jul 2018 11:45:25 +0000 (07:45 -0400)
include/api.php
include/text.php
mod/item.php
mod/wall_upload.php
src/Model/Conversation.php
src/Model/Item.php
tests/ApiTest.php

index a9a1800af17cf8772297a13f9460e83b9219163e..85f489b7994b73d49031682aa4dc792876ad0fe7 100644 (file)
@@ -1482,7 +1482,7 @@ function api_users_lookup($type)
 {
        $users = [];
 
-       if (x($_REQUEST['user_id'])) {
+       if (!empty($_REQUEST['user_id'])) {
                foreach (explode(',', $_REQUEST['user_id']) as $id) {
                        if (!empty($id)) {
                                $users[] = api_get_user(get_app(), $id);
index 04bbb672446646eaf49ee1da1431b106f40cae32..0066e188145deb1c11d8158433162a08df28c419 100644 (file)
@@ -1156,7 +1156,7 @@ function put_item_in_cache(&$item, $update = false)
        $rendered_html = defaults($item, 'rendered-html', '');
 
        if ($rendered_hash == ''
-               || $item["rendered-html"] == ""
+               || $rendered_html == ""
                || $rendered_hash != hash("md5", $item["body"])
                || Config::get("system", "ignore_cache")
        ) {
@@ -1176,7 +1176,7 @@ function put_item_in_cache(&$item, $update = false)
                        $update = true;
                }
 
-               if ($update && ($item["id"] > 0)) {
+               if ($update && !empty($item["id"])) {
                        Item::update(['rendered-html' => $item["rendered-html"], 'rendered-hash' => $item["rendered-hash"]],
                                        ['id' => $item["id"]]);
                }
index be9fa09c478985c2496525ede78ca73fa2c03ce7..95eaa9d78c59051f6365807a460157d03008deaf 100644 (file)
@@ -178,6 +178,8 @@ function item_post(App $a) {
                return;
        }
 
+       $categories = '';
+
        if ($orig_post) {
                $str_group_allow   = $orig_post['allow_gid'];
                $str_contact_allow = $orig_post['allow_cid'];
@@ -223,13 +225,13 @@ function item_post(App $a) {
                        $str_contact_deny  = perms2str($_REQUEST['contact_deny']);
                }
 
-               $title             = notags(trim($_REQUEST['title']));
-               $location          = notags(trim($_REQUEST['location']));
-               $coord             = notags(trim($_REQUEST['coord']));
-               $verb              = notags(trim($_REQUEST['verb']));
-               $emailcc           = notags(trim($_REQUEST['emailcc']));
-               $body              = escape_tags(trim($_REQUEST['body']));
-               $network           = notags(trim(defaults($_REQUEST, 'network', NETWORK_DFRN)));
+               $title             =      notags(trim(defaults($_REQUEST, 'title'   , '')));
+               $location          =      notags(trim(defaults($_REQUEST, 'location', '')));
+               $coord             =      notags(trim(defaults($_REQUEST, 'coord'   , '')));
+               $verb              =      notags(trim(defaults($_REQUEST, 'verb'    , '')));
+               $emailcc           =      notags(trim(defaults($_REQUEST, 'emailcc' , '')));
+               $body              = escape_tags(trim(defaults($_REQUEST, 'body'    , '')));
+               $network           =      notags(trim(defaults($_REQUEST, 'network' , NETWORK_DFRN)));
                $guid              = get_guid(32);
 
                $postopts = defaults($_REQUEST, 'postopts', '');
@@ -279,15 +281,15 @@ function item_post(App $a) {
                }
        }
 
-       if (strlen($categories)) {
+       if (!empty($categories)) {
                // get the "fileas" tags for this post
                $filedas = file_tag_file_to_list($categories, 'file');
        }
        // save old and new categories, so we can determine what needs to be deleted from pconfig
        $categories_old = $categories;
-       $categories = file_tag_list_to_file(trim($_REQUEST['category']), 'category');
+       $categories = file_tag_list_to_file(trim(defaults($_REQUEST, 'category', '')), 'category');
        $categories_new = $categories;
-       if (strlen($filedas)) {
+       if (!empty($filedas)) {
                // append the fileas stuff to the new categories list
                $categories .= file_tag_list_to_file($filedas, 'file');
        }
index 7067077eb72236711a5b5d6189a780000655001f..8bf2966152957943c93655cde47df9eb42d9eac4 100644 (file)
@@ -125,28 +125,36 @@ function wall_upload_post(App $a, $desktopmode = true)
                $filetype = $_FILES['userfile']['type'];
 
        } elseif (x($_FILES, 'media')) {
-               if (is_array($_FILES['media']['tmp_name'])) {
-                       $src = $_FILES['media']['tmp_name'][0];
-               } else {
-                       $src = $_FILES['media']['tmp_name'];
+               if (!empty($_FILES['media']['tmp_name'])) {
+                       if (is_array($_FILES['media']['tmp_name'])) {
+                               $src = $_FILES['media']['tmp_name'][0];
+                       } else {
+                               $src = $_FILES['media']['tmp_name'];
+                       }
                }
 
-               if (is_array($_FILES['media']['name'])) {
-                       $filename = basename($_FILES['media']['name'][0]);
-               } else {
-                       $filename = basename($_FILES['media']['name']);
+               if (!empty($_FILES['media']['name'])) {
+                       if (is_array($_FILES['media']['name'])) {
+                               $filename = basename($_FILES['media']['name'][0]);
+                       } else {
+                               $filename = basename($_FILES['media']['name']);
+                       }
                }
 
-               if (is_array($_FILES['media']['size'])) {
-                       $filesize = intval($_FILES['media']['size'][0]);
-               } else {
-                       $filesize = intval($_FILES['media']['size']);
+               if (!empty($_FILES['media']['size'])) {
+                       if (is_array($_FILES['media']['size'])) {
+                               $filesize = intval($_FILES['media']['size'][0]);
+                       } else {
+                               $filesize = intval($_FILES['media']['size']);
+                       }
                }
 
-               if (is_array($_FILES['media']['type'])) {
-                       $filetype = $_FILES['media']['type'][0];
-               } else {
-                       $filetype = $_FILES['media']['type'];
+               if (!empty($_FILES['media']['type'])) {
+                       if (is_array($_FILES['media']['type'])) {
+                               $filetype = $_FILES['media']['type'][0];
+                       } else {
+                               $filetype = $_FILES['media']['type'];
+                       }
                }
        }
 
index 17f151fe03ba9cb771bb501c14ef8828620c5e40..69bbc3bb6dd4b4718d03ac51ebad98d3b497d8fd 100644 (file)
@@ -61,7 +61,7 @@ class Conversation
                                        unset($old_conv['source']);
                                }
                                // Update structure data all the time but the source only when its from a better protocol.
-                               if (($old_conv['protocol'] < $conversation['protocol']) && ($old_conv['protocol'] != 0)) {
+                               if (isset($conversation['protocol']) && isset($conversation['source']) && ($old_conv['protocol'] < $conversation['protocol']) && ($old_conv['protocol'] != 0)) {
                                        unset($conversation['protocol']);
                                        unset($conversation['source']);
                                }
index 9fbe973eeddda1225a5c1cd0d91439cc72125cf9..5d858fa72b0cdf436651ee2df6d0cdbe4a59e9c2 100644 (file)
@@ -1989,7 +1989,7 @@ class Item extends BaseObject
                        Contact::unmarkForArchival($contact);
                }
 
-               $update = (!$arr['private'] && (($arr["author-link"] === $arr["owner-link"]) || ($arr["parent-uri"] === $arr["uri"])));
+               $update = (!$arr['private'] && ((defaults($arr, 'author-link', '') === defaults($arr, 'owner-link', '')) || ($arr["parent-uri"] === $arr["uri"])));
 
                // Is it a forum? Then we don't care about the rules from above
                if (!$update && ($arr["network"] == NETWORK_DFRN) && ($arr["parent-uri"] === $arr["uri"])) {
index 0d9e0b538b8a059e72a7508a434f3356e2dbbf1c..f1857ad27269c15482efb6f8b37ce7865f607854 100644 (file)
@@ -1110,6 +1110,7 @@ class ApiTest extends DatabaseTest
                                'width' => 666,
                                'height' => 666,
                                'tmp_name' => $this->getTempImage(),
+                               'name' => 'spacer.png',
                                'type' => 'image/png'
                        ]
                ];
@@ -1217,6 +1218,7 @@ class ApiTest extends DatabaseTest
                                'width' => 666,
                                'height' => 666,
                                'tmp_name' => $this->getTempImage(),
+                               'name' => 'spacer.png',
                                'type' => 'image/png'
                        ]
                ];