Merge pull request #9849 from annando/user-item

Don't create a user-item entry on default
This commit is contained in:
Hypolite Petovan 2021-01-22 07:23:46 -05:00 committed by GitHub
commit cb24e8987c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -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) {

View file

@ -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 : []);
}
}