From 4002bd9b97df79eb153dc101056c8c6d6655cce6 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 22 Jan 2021 08:16:41 +0000 Subject: [PATCH] Don't create a user-item entry on default --- src/Model/Item.php | 4 +++- src/Model/Post/User.php | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 828bc3210..7d2e363fb 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -321,7 +321,9 @@ class Item $items = Post::select(['id', 'uid', 'uri-id'], $condition); while ($item = Post::fetch($items)) { - Post\User::update($item['uri-id'], $item['uid'], ['hidden' => true]); + if (in_array($item['uid'], [$uid, 0])) { + Post\User::update($item['uri-id'], $uid, ['hidden' => true], true); + } // "Deleting" global items just means hiding them if ($item['uid'] == 0) { diff --git a/src/Model/Post/User.php b/src/Model/Post/User.php index c3ca5de1d..e5fe96cfb 100644 --- a/src/Model/Post/User.php +++ b/src/Model/Post/User.php @@ -66,11 +66,12 @@ class User * * @param integer $uri_id * @param integer $uid - * @param array $fields + * @param array $data + * @param bool $insert_if_missing * @return bool * @throws \Exception */ - public static function update(int $uri_id, int $uid, array $data = []) + public static function update(int $uri_id, int $uid, array $data = [], bool $insert_if_missing = false) { if (empty($uri_id)) { throw new BadMethodCallException('Empty URI_id'); @@ -86,6 +87,6 @@ class User return true; } - return DBA::update('post-user', $fields, ['uri-id' => $uri_id, 'uid' => $uid], true); + return DBA::update('post-user', $fields, ['uri-id' => $uri_id, 'uid' => $uid], $insert_if_missing ? true : []); } }