]> git.mxchange.org Git - friendica.git/commitdiff
Prevents 4 E_NOTICEs when POST fields are not set. (#5458)
authorRoland Häder <Quix0r@users.noreply.github.com>
Sun, 22 Jul 2018 23:49:16 +0000 (01:49 +0200)
committerHypolite Petovan <mrpetovan@eml.cc>
Sun, 22 Jul 2018 23:49:16 +0000 (19:49 -0400)
* Prevents 4 E_NOTICEs when POST fields are not set.

* Don't use x().

* Replaced usage of x() which is deprecated with !isset().

* Use empty() according to MrPetovan

mod/photos.php

index 07916c5871b4cf61aa0d55d81c8e4a838c434589..c65610ca361bb5108c8dc0821cfc3adf9a6db860 100644 (file)
@@ -348,15 +348,16 @@ function photos_post(App $a)
        }
 
        if ($a->argc > 2 && (x($_POST, 'desc') !== false || x($_POST, 'newtag') !== false || x($_POST, 'albname') !== false)) {
-               $desc        = x($_POST, 'desc')      ? notags(trim($_POST['desc']))      : '';
-               $rawtags     = x($_POST, 'newtag')    ? notags(trim($_POST['newtag']))    : '';
-               $item_id     = x($_POST, 'item_id')   ? intval($_POST['item_id'])         : 0;
-               $albname     = x($_POST, 'albname')   ? notags(trim($_POST['albname']))   : '';
-               $origaname   = x($_POST, 'origaname') ? notags(trim($_POST['origaname'])) : '';
-               $str_group_allow   = perms2str($_POST['group_allow']);
-               $str_contact_allow = perms2str($_POST['contact_allow']);
-               $str_group_deny    = perms2str($_POST['group_deny']);
-               $str_contact_deny  = perms2str($_POST['contact_deny']);
+               $desc        = !empty($_POST['desc'])      ? notags(trim($_POST['desc']))      : '';
+               $rawtags     = !empty($_POST['newtag'])    ? notags(trim($_POST['newtag']))    : '';
+               $item_id     = !empty($_POST['item_id'])   ? intval($_POST['item_id'])         : 0;
+               $albname     = !empty($_POST['albname'])   ? notags(trim($_POST['albname']))   : '';
+               $origaname   = !empty($_POST['origaname']) ? notags(trim($_POST['origaname'])) : '';
+
+               $str_group_allow   = !empty($_POST['group_allow'])   ? perms2str($_POST['group_allow'])   : '';
+               $str_contact_allow = !empty($_POST['contact_allow']) ? perms2str($_POST['contact_allow']) : '';
+               $str_group_deny    = !empty($_POST['group_deny'])    ? perms2str($_POST['group_deny'])    : '';
+               $str_contact_deny  = !empty($_POST['contact_deny'])  ? perms2str($_POST['contact_deny'])  : '';
 
                $resource_id = $a->argv[2];
 
@@ -703,13 +704,14 @@ function photos_post(App $a)
                dbesc($album),
                intval($page_owner_uid)
        );
+
        if (!DBM::is_result($r) || ($album == L10n::t('Profile Photos'))) {
                $visible = 1;
        } else {
                $visible = 0;
        }
 
-       if (x($_REQUEST, 'not_visible') && $_REQUEST['not_visible'] !== 'false') {
+       if (!empty($_REQUEST['not_visible']) && $_REQUEST['not_visible'] !== 'false') {
                $visible = 0;
        }
 
@@ -920,7 +922,7 @@ function photos_content(App $a)
        require_once 'include/security.php';
        require_once 'include/conversation.php';
 
-       if (!x($a->data,'user')) {
+       if (empty($a->data['user'])) {
                notice(L10n::t('No photos selected') . EOL);
                return;
        }
@@ -1609,6 +1611,7 @@ function photos_content(App $a)
                dbesc('Contact Photos'),
                dbesc(L10n::t('Contact Photos'))
        );
+
        if (DBM::is_result($r)) {
                $a->set_pager_total(count($r));
                $a->set_pager_itemspage(20);