From b0aa4eb4b759668bf413a9198133ea362887ee99 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 8 Jan 2023 18:59:07 +0000 Subject: [PATCH] Update routine to transfer the blockem list to collapsed --- database.sql | 2 +- static/dbstructure.config.php | 2 +- update.php | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/database.sql b/database.sql index 9ffa3544a..e06454b11 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2023.03-dev (Giant Rhubarb) --- DB_UPDATE_VERSION 1509 +-- DB_UPDATE_VERSION 1510 -- ------------------------------------------ diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 848da0404..d25d9cc3f 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -55,7 +55,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1509); + define('DB_UPDATE_VERSION', 1510); } return [ diff --git a/update.php b/update.php index 0491e4a92..951f54a3b 100644 --- a/update.php +++ b/update.php @@ -1213,3 +1213,18 @@ function update_1509() return Update::SUCCESS; } + +function update_1510() +{ + $blocks = DBA::select('pconfig', ['uid', 'v'], ['cat' => 'blockem', 'k' => 'words']); + while ($block = DBA::fetch($blocks)) { + foreach (explode(',', $block['v']) as $account) { + $id = Contact::getIdForURL(trim($account), 0, false); + if (empty($id)) { + continue; + } + Contact\User::setCollapsed($id, $block['uid'], true); + } + } + return Update::SUCCESS; +}