From 56406b99101b6f8a45ffc910b353c52bf77c5523 Mon Sep 17 00:00:00 2001 From: Jonny Tischbein Date: Sat, 17 Nov 2018 13:22:32 +0100 Subject: [PATCH] Fix SQL Error if no items where found + Fix setting to null --- mod/network.php | 13 ++++++++++++- src/Model/FileTag.php | 6 +++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mod/network.php b/mod/network.php index 37c7b45286..bfd5e9e872 100644 --- a/mod/network.php +++ b/mod/network.php @@ -346,7 +346,11 @@ function networkConversation(App $a, $items, Pager $pager, $mode, $update, $orde // Set this so that the conversation function can find out contact info for our wall-wall items $a->page_contact = $a->contact; - $items = (empty($items) ? [] : $items); + if (!is_array($items)){ + Logger::log("Expecting items to be an array. Got " . print_r($items, true)); + $items = []; + } + $o = conversation($a, $items, $pager, $mode, $update, false, $ordering, local_user()); if (!$update) { @@ -390,6 +394,10 @@ function network_content(App $a, $update = 0, $parent = 0) $o = networkThreadedView($a, $update, $parent); } + if ($o === ''){ + info("No items found"); + } + return $o; } @@ -464,6 +472,9 @@ function networkFlatView(App $a, $update = 0) } DBA::close($result); + if (count($posts) == 0){ + return ''; + } $condition = ['uid' => local_user(), 'id' => $posts]; } else { $condition = ['uid' => local_user()]; diff --git a/src/Model/FileTag.php b/src/Model/FileTag.php index b5c4cf2aef..403cbd233e 100644 --- a/src/Model/FileTag.php +++ b/src/Model/FileTag.php @@ -290,7 +290,11 @@ class FileTag return false; } - $fields = ['file' => str_replace($pattern, null, $item['file'])]; + $fields = ['file' => str_replace($pattern, '', $item['file'])]; + if ($fields === '') { + $fields = null; + } + Item::update($fields, ['id' => $item_id]); $r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",