Merge pull request #5719 from annando/notices-yeah
authorHypolite Petovan <mrpetovan@eml.cc>
Tue, 4 Sep 2018 23:09:11 +0000 (19:09 -0400)
committerGitHub <noreply@github.com>
Tue, 4 Sep 2018 23:09:11 +0000 (19:09 -0400)
Good news, everyone - again somce notices removed

mod/events.php
mod/notifications.php
mod/unfollow.php
src/App.php
src/Util/HTTPSignature.php

index 9147402..c4d4025 100644 (file)
@@ -54,11 +54,11 @@ function events_post(App $a) {
        $cid = (x($_POST, 'cid') ? intval($_POST['cid']) : 0);
        $uid = local_user();
 
-       $start_text  = escape_tags($_REQUEST['start_text']);
-       $finish_text = escape_tags($_REQUEST['finish_text']);
+       $start_text  = escape_tags(defaults($_REQUEST, 'start_text', ''));
+       $finish_text = escape_tags(defaults($_REQUEST, 'finish_text', ''));
 
-       $adjust   = intval($_POST['adjust']);
-       $nofinish = intval($_POST['nofinish']);
+       $adjust   = intval(defaults($_POST, 'adjust', 0));
+       $nofinish = intval(defaults($_POST, 'nofinish', 0));
 
        // The default setting for the `private` field in event_store() is false, so mirror that
        $private_event = false;
@@ -91,9 +91,9 @@ function events_post(App $a) {
        // and we'll waste a bunch of time responding to it. Time that
        // could've been spent doing something else.
 
-       $summary  = escape_tags(trim($_POST['summary']));
-       $desc     = escape_tags(trim($_POST['desc']));
-       $location = escape_tags(trim($_POST['location']));
+       $summary  = escape_tags(trim(defaults($_POST, 'summary', '')));
+       $desc     = escape_tags(trim(defaults($_POST, 'desc', '')));
+       $location = escape_tags(trim(defaults($_POST, 'location', '')));
        $type     = 'event';
 
        $action = ($event_id == '') ? 'new' : "event/" . $event_id;
@@ -117,7 +117,7 @@ function events_post(App $a) {
                goaway($onerror_url);
        }
 
-       $share = (intval($_POST['share']) ? intval($_POST['share']) : 0);
+       $share = intval(defaults($_POST, 'share', 0));
 
        $c = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
                intval(local_user())
@@ -482,8 +482,10 @@ function events_content(App $a) {
 
                $perms = ACL::getDefaultUserPermissions($orig_event);
 
-               if ($mode === 'new' || $mode === 'copy') {
-                       $acl = ($cid ? '' : ACL::getFullSelectorHTML($a->user, false, $orig_event));
+               if (!$cid && in_array($mode, ['new', 'copy'])) {
+                       $acl = ACL::getFullSelectorHTML($a->user, false, $orig_event);
+               } else {
+                       $acl = '';
                }
 
                // If we copy an old event, we need to remove the ID and URI
index bc581b6..091323d 100644 (file)
@@ -87,10 +87,11 @@ function notifications_content(App $a)
        $perpage = 20;
        $startrec = ($page * $perpage) - $perpage;
 
+       $notif_header = L10n::t('Notifications');
+
        // Get introductions
        if ((($a->argc > 1) && ($a->argv[1] == 'intros')) || (($a->argc == 1))) {
                Nav::setSelected('introductions');
-               $notif_header = L10n::t('Notifications');
 
                $all = (($a->argc > 2) && ($a->argv[2] == 'all'));
 
@@ -132,12 +133,8 @@ function notifications_content(App $a)
 
        $notif_tpl = get_markup_template('notifications.tpl');
 
-       if (!isset($notifs['ident'])) {
-               logger('Missing data in notifs: ' . json_encode($a->argv), LOGGER_DEBUG);
-       }
-
        // Process the data for template creation
-       if ($notifs['ident'] === 'introductions') {
+       if (defaults($notifs, 'ident', '') === 'introductions') {
                $sugg = get_markup_template('suggestions.tpl');
                $tpl = get_markup_template("intros.tpl");
 
@@ -280,7 +277,7 @@ function notifications_content(App $a)
                }
 
        // Normal notifications (no introductions)
-       } else {
+       } elseif (!empty($notifs['notifications'])) {
                // The template files we need in different cases for formatting the content
                $tpl_item_like = 'notifications_likes_item.tpl';
                $tpl_item_dislike = 'notifications_dislikes_item.tpl';
index 0af16ec..956b6fb 100644 (file)
@@ -22,7 +22,7 @@ function unfollow_post()
                // NOTREACHED
        }
 
-       if ($_REQUEST['cancel']) {
+       if (!empty($_REQUEST['cancel'])) {
                goaway($return_url);
        }
 
index 2a5fba8..488c230 100644 (file)
@@ -1074,7 +1074,11 @@ class App
 
                $meminfo = [];
                foreach ($memdata as $line) {
-                       list($key, $val) = explode(':', $line);
+                       $data = explode(':', $line);
+                       if (count($data) != 2) {
+                               continue;
+                       }
+                       list($key, $val) = $data;
                        $meminfo[$key] = (int) trim(str_replace('kB', '', $val));
                        $meminfo[$key] = (int) ($meminfo[$key] / 1024);
                }
index f88b042..911de43 100644 (file)
@@ -125,6 +125,8 @@ class HTTPSignature
                        $key = $key($sig_block['keyId']);
                }
 
+               logger('Got keyID ' . $sig_block['keyId']);
+
                // We don't use Activity Pub at the moment.
 //             if (!$key) {
 //                     $result['signer'] = $sig_block['keyId'];