diff --git a/database.sql b/database.sql index e9003baa39..a504b9f74e 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2024.06-dev (Yellow Archangel) --- DB_UPDATE_VERSION 1563 +-- DB_UPDATE_VERSION 1564 -- ------------------------------------------ diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 3ea78a3895..5cd77048c9 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -626,11 +626,8 @@ class Contact */ public static function getPublicIdByUserId(int $uid) { - $self = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]); - if (!DBA::isResult($self)) { - return false; - } - return self::getIdForURL($self['url']); + $self = self::selectFirstAccountUser(['pid'], ['self' => true, 'uid' => $uid]); + return $self['pid'] ?? false; } /** diff --git a/src/Model/User.php b/src/Model/User.php index 3728458258..0701df4a26 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -1492,6 +1492,12 @@ class User */ public static function block(int $uid, bool $block = true): bool { + $self = Contact::getPublicIdByUserId($uid); + if ($block) { + Contact::block($self['id']); + } else { + Contact::unblock($self['id']); + } return DBA::update('user', ['blocked' => $block], ['uid' => $uid]); } diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 71a555eafa..f88e60eae9 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -56,7 +56,7 @@ use Friendica\Database\DBA; // This file is required several times during the test in DbaDefinition which justifies this condition if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1563); + define('DB_UPDATE_VERSION', 1564); } return [ diff --git a/update.php b/update.php index 03a95fb145..228e454e6d 100644 --- a/update.php +++ b/update.php @@ -1466,4 +1466,15 @@ function update_1560() SELECT `id`, `uri-id`, `uid`, `parent-uri-id`, `thr-parent-id`, `created`, `received`, `gravity`, `vid`, `private`, `wall` FROM `post-user` WHERE `post-user`.`origin` AND `post-user`.`uid` != ?", 0)) { return Update::FAILED; } +} + +function update_1564() +{ + $users = DBA::select('user', ['uid'], ['blocked' => true]); + while ($user = DBA::fetch($users)) { + User::block($user['uid']); + } + DBA::close($users); + + return Update::SUCCESS; } \ No newline at end of file