diff --git a/src/Model/Item.php b/src/Model/Item.php index dec3716d01..75c3d08384 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1385,6 +1385,19 @@ class Item return false; } + if (!empty($item['uid'])) { + $owner = User::getOwnerDataById($item['uid'], false); + if (!$owner) { + Logger::notice('Missing item user owner data', ['uid' => $item['uid']]); + return false; + } + + if ($owner['account_expired'] || $owner['account_removed']) { + Logger::notice('Item user has been deleted/expired/removed', ['uid' => $item['uid'], 'deleted' => $owner['deleted'], 'account_expired' => $owner['account_expired'], 'account_removed' => $owner['account_removed']]); + return false; + } + } + if (!empty($item['author-id']) && Contact::isBlocked($item['author-id'])) { Logger::notice('Author is blocked node-wide', ['author-link' => $item['author-link'], 'item-uri' => $item['uri']]); return false; diff --git a/src/Model/User.php b/src/Model/User.php index bcd555a0ec..d3f3dfd1a9 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -370,12 +370,12 @@ class User /** * Get owner data by user id * - * @param int $uid - * @param boolean $check_valid Test if data is invalid and correct it + * @param int $uid + * @param boolean $repairMissing Repair the owner data if it's missing * @return boolean|array * @throws Exception */ - public static function getOwnerDataById(int $uid, bool $check_valid = true) + public static function getOwnerDataById(int $uid, bool $repairMissing = true) { if ($uid == 0) { return self::getSystemAccount(); @@ -387,7 +387,7 @@ class User $owner = DBA::selectFirst('owner-view', [], ['uid' => $uid]); if (!DBA::isResult($owner)) { - if (!DBA::exists('user', ['uid' => $uid]) || !$check_valid) { + if (!DBA::exists('user', ['uid' => $uid]) || !$repairMissing) { return false; } Contact::createSelfFromUserId($uid); @@ -398,7 +398,7 @@ class User return false; } - if (!$check_valid) { + if (!$repairMissing) { return $owner; }