Fix SQL Error if no items where found + Fix setting to null

This commit is contained in:
Jonny Tischbein 2018-11-17 13:22:32 +01:00
parent 52eb2281e4
commit 56406b9910
2 changed files with 17 additions and 2 deletions

View File

@ -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 // Set this so that the conversation function can find out contact info for our wall-wall items
$a->page_contact = $a->contact; $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()); $o = conversation($a, $items, $pager, $mode, $update, false, $ordering, local_user());
if (!$update) { if (!$update) {
@ -390,6 +394,10 @@ function network_content(App $a, $update = 0, $parent = 0)
$o = networkThreadedView($a, $update, $parent); $o = networkThreadedView($a, $update, $parent);
} }
if ($o === ''){
info("No items found");
}
return $o; return $o;
} }
@ -464,6 +472,9 @@ function networkFlatView(App $a, $update = 0)
} }
DBA::close($result); DBA::close($result);
if (count($posts) == 0){
return '';
}
$condition = ['uid' => local_user(), 'id' => $posts]; $condition = ['uid' => local_user(), 'id' => $posts];
} else { } else {
$condition = ['uid' => local_user()]; $condition = ['uid' => local_user()];

View File

@ -290,7 +290,11 @@ class FileTag
return false; 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]); Item::update($fields, ['id' => $item_id]);
$r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d", $r = q("SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d",