From 810c108297519746bfcd5b81991d3db0ab2306e9 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 4 Aug 2018 16:06:36 +0200 Subject: [PATCH] Fix: Notes can be posted again. Never use "defaults" with "false" (#5551) --- mod/item.php | 15 +++++++++++++-- src/Database/DBA.php | 7 ++++++- view/theme/frio/templates/jot.tpl | 1 + view/theme/quattro/templates/jot.tpl | 3 --- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/mod/item.php b/mod/item.php index afb119c8af..ca0e5e1904 100644 --- a/mod/item.php +++ b/mod/item.php @@ -135,7 +135,13 @@ function item_post(App $a) { $app = strip_tags(defaults($_REQUEST, 'source', '')); $extid = strip_tags(defaults($_REQUEST, 'extid', '')); $object = defaults($_REQUEST, 'object', ''); - $wall = intval(defaults($_REQUEST, 'wall', 1)); + + // Don't use "defaults" here. It would turn 0 to 1 + if (!isset($_REQUEST['wall'])) { + $wall = 1; + } else { + $wall = $_REQUEST['wall']; + } // Ensure that the user id in a thread always stay the same if (!is_null($parent_user) && in_array($parent_user, [local_user(), 0])) { @@ -560,7 +566,12 @@ function item_post(App $a) { // even if the post arrived via API we are considering that it // originated on this site by default for determining relayability. - $origin = intval(defaults($_REQUEST, 'origin', 1)); + // Don't use "defaults" here. It would turn 0 to 1 + if (!isset($_REQUEST['origin'])) { + $origin = 1; + } else { + $origin = $_REQUEST['origin']; + } $notify_type = ($parent ? 'comment-new' : 'wall-new'); diff --git a/src/Database/DBA.php b/src/Database/DBA.php index 902efda1fa..c0b783c29d 100644 --- a/src/Database/DBA.php +++ b/src/Database/DBA.php @@ -1058,7 +1058,12 @@ class DBA $commands[$key] = ['table' => $table, 'conditions' => $conditions]; - $cascade = defaults($options, 'cascade', true); + // Don't use "defaults" here, since it would set "false" to "true" + if (isset($options['cascade'])) { + $cascade = $options['cascade']; + } else { + $cascade = true; + } // To speed up the whole process we cache the table relations if ($cascade && count(self::$relation) == 0) { diff --git a/view/theme/frio/templates/jot.tpl b/view/theme/frio/templates/jot.tpl index 260d4c18e4..423be5a5d9 100644 --- a/view/theme/frio/templates/jot.tpl +++ b/view/theme/frio/templates/jot.tpl @@ -70,6 +70,7 @@ {{* The hidden input fields which submit important values with the post *}} + diff --git a/view/theme/quattro/templates/jot.tpl b/view/theme/quattro/templates/jot.tpl index 48c084ca0a..bdf21b8f74 100644 --- a/view/theme/quattro/templates/jot.tpl +++ b/view/theme/quattro/templates/jot.tpl @@ -6,9 +6,6 @@ {{/if}}
- - -