Browse Source

Merge pull request #9849 from annando/user-item

Don't create a user-item entry on default
pull/9850/head
Hypolite Petovan 2 years ago committed by GitHub
parent
commit
cb24e8987c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Model/Item.php
  2. 7
      src/Model/Post/User.php

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

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

Loading…
Cancel
Save