From eaa58da25b0cc51791c5a4db4fbe013faeca91d1 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 17 Nov 2020 22:33:44 +0000 Subject: [PATCH 01/14] New table "post-user" and more foreign keys --- database.sql | 51 +++++++++++++++---- src/Database/DBStructure.php | 50 +++++++++++++++++++ src/Model/Item.php | 40 ++++++--------- src/Model/Post/User.php | 92 +++++++++++++++++++++++++++++++++++ src/Model/UserItem.php | 4 +- static/dbstructure.config.php | 45 ++++++++++++----- update.php | 38 +++++++++++++++ 7 files changed, 274 insertions(+), 46 deletions(-) create mode 100644 src/Model/Post/User.php diff --git a/database.sql b/database.sql index e2a0f243a1..3e4e76cf0b 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2020.12-dev (Red Hot Poker) --- DB_UPDATE_VERSION 1372 +-- DB_UPDATE_VERSION 1376 -- ------------------------------------------ @@ -135,6 +135,7 @@ CREATE TABLE IF NOT EXISTS `contact` ( INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`), INDEX `uid_lastitem` (`uid`,`last-item`), INDEX `gsid` (`gsid`), + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE, FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='contact table'; @@ -212,7 +213,9 @@ CREATE TABLE IF NOT EXISTS `user` ( `deny_gid` mediumtext COMMENT 'default permission for this user', `openidserver` text COMMENT '', PRIMARY KEY(`uid`), - INDEX `nickname` (`nickname`(32)) + INDEX `nickname` (`nickname`(32)), + INDEX `parent-uid` (`parent-uid`), + FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users'; -- @@ -241,7 +244,8 @@ CREATE TABLE IF NOT EXISTS `permissionset` ( `deny_cid` mediumtext COMMENT 'Access Control - list of denied contact.id', `deny_gid` mediumtext COMMENT 'Access Control - list of denied groups', PRIMARY KEY(`id`), - INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)) + INDEX `uid_allow_cid_allow_gid_deny_cid_deny_gid` (`uid`,`allow_cid`(50),`allow_gid`(30),`deny_cid`(50),`deny_gid`(30)), + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE ) DEFAULT COLLATE utf8mb4_general_ci COMMENT=''; -- @@ -484,6 +488,7 @@ CREATE TABLE IF NOT EXISTS `event` ( PRIMARY KEY(`id`), INDEX `uid_start` (`uid`,`start`), INDEX `cid` (`cid`), + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE, FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Events'; @@ -745,6 +750,7 @@ CREATE TABLE IF NOT EXISTS `item` ( FOREIGN KEY (`parent-uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, FOREIGN KEY (`thr-parent-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, FOREIGN KEY (`causer-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT, + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE, FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Structure for all posts'; @@ -946,7 +952,8 @@ CREATE TABLE IF NOT EXISTS `openwebauth-token` ( `meta` varchar(255) NOT NULL DEFAULT '' COMMENT '', `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'datetime of creation', PRIMARY KEY(`id`), - INDEX `uid` (`uid`) + INDEX `uid` (`uid`), + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Store OpenWebAuth token to verify contacts'; -- @@ -982,11 +989,11 @@ CREATE TABLE IF NOT EXISTS `participation` ( -- TABLE pconfig -- CREATE TABLE IF NOT EXISTS `pconfig` ( - `id` int unsigned NOT NULL auto_increment COMMENT '', + `id` int unsigned NOT NULL auto_increment COMMENT 'Primary key', `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id', - `cat` varbinary(50) NOT NULL DEFAULT '' COMMENT '', - `k` varbinary(100) NOT NULL DEFAULT '' COMMENT '', - `v` mediumtext COMMENT '', + `cat` varchar(50) NOT NULL DEFAULT '' COMMENT 'Category', + `k` varchar(100) NOT NULL DEFAULT '' COMMENT 'Key', + `v` mediumtext COMMENT 'Value', PRIMARY KEY(`id`), UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`), FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE @@ -1029,6 +1036,7 @@ CREATE TABLE IF NOT EXISTS `photo` ( INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`), INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`,`created`), INDEX `resource-id` (`resource-id`), + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE, FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='photo storage'; @@ -1042,7 +1050,9 @@ CREATE TABLE IF NOT EXISTS `post-category` ( `tid` int unsigned NOT NULL DEFAULT 0 COMMENT '', PRIMARY KEY(`uri-id`,`uid`,`type`,`tid`), INDEX `uri-id` (`tid`), + INDEX `uid` (`uid`), FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE, FOREIGN KEY (`tid`) REFERENCES `tag` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to categories'; @@ -1102,6 +1112,28 @@ CREATE TABLE IF NOT EXISTS `post-tag` ( FOREIGN KEY (`cid`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='post relation to tags'; +-- +-- TABLE post-user +-- +CREATE TABLE IF NOT EXISTS `post-user` ( + `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri', + `uid` mediumint unsigned NOT NULL COMMENT 'Owner id which owns this copy of the item', + `contact-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'contact.id', + `unseen` boolean NOT NULL DEFAULT '1' COMMENT 'post has not been seen', + `hidden` boolean NOT NULL DEFAULT '0' COMMENT 'Marker to hide the post from the user', + `notification-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '', + `origin` boolean NOT NULL DEFAULT '0' COMMENT 'item originated at this site', + `psid` int unsigned COMMENT 'ID of the permission set of this post', + PRIMARY KEY(`uid`,`uri-id`), + INDEX `uri-id` (`uri-id`), + INDEX `contact-id` (`contact-id`), + INDEX `psid` (`psid`), + FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE, + FOREIGN KEY (`contact-id`) REFERENCES `contact` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, + FOREIGN KEY (`psid`) REFERENCES `permissionset` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT +) DEFAULT COLLATE utf8mb4_general_ci COMMENT='User specific post data'; + -- -- TABLE process -- @@ -1316,7 +1348,8 @@ CREATE TABLE IF NOT EXISTS `thread` ( INDEX `private_wall_origin_commented` (`private`,`wall`,`origin`,`commented`), INDEX `uri-id` (`uri-id`), FOREIGN KEY (`iid`) REFERENCES `item` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, - FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE + FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, + FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Thread related data'; -- diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index bdd8cc208e..5d0749c583 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -170,6 +170,34 @@ class DBStructure return $definition; } + /** + * Get field data for the given table + * + * @param string $table + * @param array $data data fields + * @return array fields for the given + */ + public static function getFieldsForTable(string $table, array $data = []) + { + $definition = DBStructure::definition('', false); + if (empty($definition[$table])) { + return []; + } + + $fieldnames = array_keys($definition[$table]['fields']); + + $fields = []; + + // Assign all field that are present in the table + foreach ($fieldnames as $field) { + if (isset($data[$field])) { + $fields[$field] = $data[$field]; + } + } + + return $fields; + } + private static function createTable($name, $structure, $verbose, $action) { $r = true; @@ -1073,6 +1101,28 @@ class DBStructure } } + if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) { + $system = User::getSystemAccount(); + $user = [ + "username" => $system['name'], + "nickname" => $system['nick'], + "register_date" => $system['created'], + "pubkey" => $system['pubkey'], + "prvkey" => $system['prvkey'], + "spubkey" => $system['spubkey'], + "sprvkey" => $system['sprvkey'], + "verified" => true, + "page-flags" => User::PAGE_FLAGS_SOAPBOX, + "account-type" => User::ACCOUNT_TYPE_RELAY, + ]; + + DBA::insert('user', $user); + $lastid = DBA::lastInsertId(); + if ($lastid != 0) { + DBA::update('user', ['uid' => 0], ['uid' => $lastid]); + } + } + if (!self::existsForeignKeyForField('tokens', 'client_id')) { $tokens = DBA::p("SELECT `tokens`.`id` FROM `tokens` LEFT JOIN `clients` ON `clients`.`client_id` = `tokens`.`client_id` diff --git a/src/Model/Item.php b/src/Model/Item.php index 0fcb445e0b..f160dec4cc 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -34,7 +34,7 @@ use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Database\DBStructure; use Friendica\DI; -use Friendica\Model\Post\Category; +use Friendica\Model\Post; use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityPub; use Friendica\Protocol\Diaspora; @@ -71,8 +71,6 @@ class Item const PT_FETCHED = 75; const PT_PERSONAL_NOTE = 128; - const LOCK_INSERT = 'item-insert'; - // Field list that is used to display the items const DISPLAY_FIELDLIST = [ 'uid', 'id', 'parent', 'uri-id', 'uri', 'thr-parent', 'parent-uri', 'guid', 'network', 'gravity', @@ -310,7 +308,7 @@ class Item if (!array_key_exists('verb', $row) || in_array($row['verb'], ['', Activity::POST, Activity::SHARE])) { // Build the file string out of the term entries if (array_key_exists('file', $row) && empty($row['file'])) { - $row['file'] = Category::getTextByURIId($row['internal-uri-id'], $row['internal-uid']); + $row['file'] = Post\Category::getTextByURIId($row['internal-uri-id'], $row['internal-uid']); } } @@ -911,6 +909,8 @@ class Item return false; } + $data_fields = $fields; + // To ensure the data integrity we do it in an transaction DBA::transaction(); @@ -967,6 +967,8 @@ class Item $notify_items = []; while ($item = DBA::fetch($items)) { + Post\User::update($item['uri-id'], $item['uid'], $data_fields); + if (empty($content_fields['verb']) || !in_array($content_fields['verb'], self::ACTIVITIES)) { if (!empty($content_fields['body'])) { $content_fields['raw-body'] = trim($content_fields['raw-body'] ?? $content_fields['body']); @@ -996,7 +998,7 @@ class Item } if (!is_null($files)) { - Category::storeTextByURIId($item['uri-id'], $item['uid'], $files); + Post\Category::storeTextByURIId($item['uri-id'], $item['uid'], $files); if (!empty($item['file'])) { DBA::update('item', ['file' => ''], ['id' => $item['id']]); } @@ -1056,8 +1058,10 @@ class Item return; } - $items = self::select(['id', 'uid'], $condition); + $items = self::select(['id', 'uid', 'uri-id'], $condition); while ($item = self::fetch($items)) { + Post\User::update($item['uri-id'], $item['uid'], ['hidden' => true]); + // "Deleting" global items just means hiding them if ($item['uid'] == 0) { DBA::update('user-item', ['hidden' => true], ['iid' => $item['id'], 'uid' => $uid], true); @@ -1158,7 +1162,7 @@ class Item $item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()]; DBA::update('item', $item_fields, ['id' => $item['id']]); - Category::storeTextByURIId($item['uri-id'], $item['uid'], ''); + Post\Category::storeTextByURIId($item['uri-id'], $item['uid'], ''); self::deleteThread($item['id'], $item['parent-uri']); if (!self::exists(["`uri` = ? AND `uid` != 0 AND NOT `deleted`", $item['uri']])) { @@ -1191,6 +1195,7 @@ class Item // send the notification upstream/downstream Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", Delivery::DELETION, intval($item['id'])); } elseif ($item['uid'] != 0) { + Post\User::update($item['uri-id'], $item['uid'], ['hidden' => true]); // When we delete just our local user copy of an item, we have to set a marker to hide it $global_item = self::selectFirst(['id'], ['uri' => $item['uri'], 'uid' => 0, 'deleted' => false]); @@ -1862,7 +1867,7 @@ class Item // Attached file links if (!empty($item['file'])) { - Category::storeTextByURIId($item['uri-id'], $item['uid'], $item['file']); + Post\Category::storeTextByURIId($item['uri-id'], $item['uid'], $item['file']); } unset($item['file']); @@ -1888,16 +1893,9 @@ class Item } } - $locked = DI::lock()->acquire(self::LOCK_INSERT, 0); - - if ($locked || DBA::lock('item')) { + if (Post\User::insert($item['uri-id'], $item['uid'], $item)) { $condition = ['uri-id' => $item['uri-id'], 'uid' => $item['uid'], 'network' => $item['network']]; if (DBA::exists('item', $condition)) { - if ($locked) { - DI::lock()->release(self::LOCK_INSERT); - } else { - DBA::unlock(); - } Logger::notice('Item is already inserted - aborting', $condition); return 0; } @@ -1906,15 +1904,9 @@ class Item // When the item was successfully stored we fetch the ID of the item. $current_post = DBA::lastInsertId(); - if ($locked) { - DI::lock()->release(self::LOCK_INSERT); - } else { - DBA::unlock(); - } } else { - Logger::warning('Item lock had not been acquired'); - $result = false; - $current_post = 0; + Logger::notice('Post-User is already inserted - aborting'); + return 0; } if (empty($current_post) || !DBA::isResult($result)) { diff --git a/src/Model/Post/User.php b/src/Model/Post/User.php new file mode 100644 index 0000000000..69225f0423 --- /dev/null +++ b/src/Model/Post/User.php @@ -0,0 +1,92 @@ +. + * + */ + +namespace Friendica\Model\Post; + +use Friendica\Database\DBA; +use \BadMethodCallException; +use Friendica\Core\Logger; +use Friendica\Database\DBStructure; + +class User +{ + /** + * Insert a new URI user entry + * + * @param integer $uri_id + * @param integer $uid + * @param array $fields + * @return bool + * @throws \Exception + */ + public static function insert(int $uri_id, int $uid, array $data = []) + { + if (empty($uri_id)) { + throw new BadMethodCallException('Empty URI_id'); + } + + if (DBA::exists('post-user', ['uri-id' => $uri_id, 'uid' => $uid])) { + return false; + } + + $fields = DBStructure::getFieldsForTable('post-user', $data); + + // Additionally assign the key fields + $fields['uri-id'] = $uri_id; + $fields['uid'] = $uid; + + // Public posts are always seen + if ($uid == 0) { + $fields['unseen'] = false; + } + + return DBA::insert('post-user', $fields); + } + + /** + * Update a URI user entry + * + * @param integer $uri_id + * @param integer $uid + * @param array $fields + * @return bool + * @throws \Exception + */ + public static function update(int $uri_id, int $uid, array $data = []) + { + if (empty($uri_id)) { + throw new BadMethodCallException('Empty URI_id'); + } + + $fields = DBStructure::getFieldsForTable('post-user', $data); + + // Remove the key fields + unset($fields['uri-id']); + unset($fields['uid']); + + if (empty($fields)) { + return true; + } + +Logger::info('Blubb-Update', ['uri-id' => $uri_id, 'uid' => $uid, 'fields' => $fields]); + return DBA::update('post-user', $fields, ['uri-id' => $uri_id, 'uid' => $uid], true); + } +} diff --git a/src/Model/UserItem.php b/src/Model/UserItem.php index b7dfec4b12..38e9adc6ea 100644 --- a/src/Model/UserItem.php +++ b/src/Model/UserItem.php @@ -156,7 +156,9 @@ class UserItem Logger::info('Set notification', ['iid' => $item['id'], 'uid' => $uid, 'notification-type' => $notification_type]); - DBA::update('user-item', ['notification-type' => $notification_type], ['iid' => $item['id'], 'uid' => $uid], true); + $fields = ['notification-type' => $notification_type]; + Post\User::update($item['uri-id'], $uid, $fields); + DBA::update('user-item', $fields, ['iid' => $item['id'], 'uid' => $uid], true); } /** diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 2905501747..9548e95f37 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -54,7 +54,7 @@ use Friendica\Database\DBA; if (!defined('DB_UPDATE_VERSION')) { - define('DB_UPDATE_VERSION', 1375); + define('DB_UPDATE_VERSION', 1376); } return [ @@ -93,7 +93,7 @@ return [ "comment" => "contact table", "fields" => [ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "Owner User id"], "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => ""], "updated" => ["type" => "datetime", "default" => DBA::NULL_DATETIME, "comment" => "Date of last contact update"], "self" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 if the contact is the user him/her self"], @@ -224,7 +224,7 @@ return [ "comment" => "The local users", "fields" => [ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], - "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], + "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"], "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"], "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"], @@ -273,6 +273,7 @@ return [ "indexes" => [ "PRIMARY" => ["uid"], "nickname" => ["nickname(32)"], + "parent-uid" => ["parent-uid"], ] ], "clients" => [ @@ -294,7 +295,7 @@ return [ "comment" => "", "fields" => [ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id of this permission set"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "Owner id of this permission set"], "allow_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed contact.id '<19><78>'"], "allow_gid" => ["type" => "mediumtext", "comment" => "Access Control - list of allowed groups"], "deny_cid" => ["type" => "mediumtext", "comment" => "Access Control - list of denied contact.id"], @@ -302,7 +303,7 @@ return [ ], "indexes" => [ "PRIMARY" => ["id"], - "uid_allow_cid_allow_gid_deny_cid_deny_gid" => ["allow_cid(50)", "allow_gid(30)", "deny_cid(50)", "deny_gid(30)"], + "uid_allow_cid_allow_gid_deny_cid_deny_gid" => ["uid", "allow_cid(50)", "allow_gid(30)", "deny_cid(50)", "deny_gid(30)"], ] ], // Main tables @@ -529,7 +530,7 @@ return [ "fields" => [ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "guid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "Owner User id"], "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id"], "comment" => "contact_id (ID of the contact in contact table)"], "uri" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], "created" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "creation time"], @@ -734,7 +735,7 @@ return [ "moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], "deleted" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been deleted"], // User specific fields. Eventually they will move to user-item - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"], "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact.id"], "wall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "This item was posted to the wall of uid"], "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item originated at this site"], @@ -1008,7 +1009,7 @@ return [ "comment" => "Store OpenWebAuth token to verify contacts", "fields" => [ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id - currently unused"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "User id - currently unused"], "type" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => "Verify type"], "token" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "A generated token"], "meta" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], @@ -1065,7 +1066,7 @@ return [ "comment" => "photo storage", "fields" => [ "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "Owner User id"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "Owner User id"], "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id", "on delete" => "restrict"], "comment" => "contact.id"], "guid" => ["type" => "char(16)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this photo"], "resource-id" => ["type" => "char(32)", "not null" => "1", "default" => "", "comment" => ""], @@ -1105,13 +1106,14 @@ return [ "comment" => "post relation to categories", "fields" => [ "uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "relation" => ["user" => "uid"], "comment" => "User id"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "foreign" => ["user" => "uid"], "comment" => "User id"], "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "primary" => "1", "comment" => ""], "tid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "foreign" => ["tag" => "id", "on delete" => "restrict"], "comment" => ""], ], "indexes" => [ "PRIMARY" => ["uri-id", "uid", "type", "tid"], - "uri-id" => ["tid"] + "uri-id" => ["tid"], + "uid" => ["uid"], ] ], "post-delivery-data" => [ @@ -1168,6 +1170,25 @@ return [ "cid" => ["cid"] ] ], + "post-user" => [ + "comment" => "User specific post data", + "fields" => [ + "uri-id" => ["type" => "int unsigned", "not null" => "1", "primary" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "primary" => "1", "foreign" => ["user" => "uid"], "comment" => "Owner id which owns this copy of the item"], + "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id"], "comment" => "contact.id"], + "unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "post has not been seen"], + "hidden" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Marker to hide the post from the user"], + "notification-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], + "origin" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item originated at this site"], + "psid" => ["type" => "int unsigned", "foreign" => ["permissionset" => "id", "on delete" => "restrict"], "comment" => "ID of the permission set of this post"], + ], + "indexes" => [ + "PRIMARY" => ["uid", "uri-id"], + "uri-id" => ["uri-id"], + "contact-id" => ["contact-id"], + "psid" => ["psid"], + ], + ], "process" => [ "comment" => "Currently running system processes", "fields" => [ @@ -1345,7 +1366,7 @@ return [ "iid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "primary" => "1", "foreign" => ["item" => "id"], "comment" => "sequential ID"], "uri-id" => ["type" => "int unsigned", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"], - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "relation" => ["user" => "uid"], "comment" => "User id"], + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], "comment" => "User id"], "contact-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => ""], "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item owner"], "author-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "Item author"], diff --git a/update.php b/update.php index 460fad885c..3544275c00 100644 --- a/update.php +++ b/update.php @@ -758,3 +758,41 @@ function update_1375() return Update::SUCCESS; } + +function pre_update_1376() +{ + // Insert a user with uid=0 + DBStructure::checkInitialValues(); + + if (!DBA::e("DELETE FROM `item` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { + return Update::FAILED; + } + + if (!DBA::e("DELETE FROM `event` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { + return Update::FAILED; + } + + if (!DBA::e("DELETE FROM `thread` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { + return Update::FAILED; + } + + if (!DBA::e("DELETE FROM `permissionset` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { + return Update::FAILED; + } + + if (!DBA::e("DELETE FROM `openwebauth-token` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { + return Update::FAILED; + } + + if (!DBA::e("DELETE FROM `post-category` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { + return Update::FAILED; + } + + if (!DBA::e("DELETE FROM `contact` WHERE NOT `uid` IN (SELECT `uid` FROM `user`)")) { + return Update::FAILED; + } + + Photo::delete(["NOT `uid` IN (SELECT `uid` FROM `user`)"]); + + return Update::SUCCESS; +} From 219c651289ee41ad2bce27b022fe368b543ba096 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 17 Nov 2020 22:38:52 +0000 Subject: [PATCH 02/14] Removed test logging --- src/Model/Post/User.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Model/Post/User.php b/src/Model/Post/User.php index 69225f0423..840d020d6e 100644 --- a/src/Model/Post/User.php +++ b/src/Model/Post/User.php @@ -86,7 +86,6 @@ class User return true; } -Logger::info('Blubb-Update', ['uri-id' => $uri_id, 'uid' => $uid, 'fields' => $fields]); return DBA::update('post-user', $fields, ['uri-id' => $uri_id, 'uid' => $uid], true); } } From 7615c022be9f846993942757306e07e650e53f69 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 17 Nov 2020 22:41:53 +0000 Subject: [PATCH 03/14] Improved logging --- src/Model/Item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index f160dec4cc..3ec57f33c6 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1905,7 +1905,7 @@ class Item // When the item was successfully stored we fetch the ID of the item. $current_post = DBA::lastInsertId(); } else { - Logger::notice('Post-User is already inserted - aborting'); + Logger::notice('Post-User is already inserted - aborting', ['uid' => $item['uid'], 'uri-id' => $item['uri-id']]); return 0; } From 5668192f3855c572f569c5fa6503fefd2fcdd7d1 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 17 Nov 2020 22:49:55 +0000 Subject: [PATCH 04/14] Moved table definition --- database.sql | 110 ++++++++++++++++----------------- static/dbstructure.config.php | 112 +++++++++++++++++----------------- 2 files changed, 111 insertions(+), 111 deletions(-) diff --git a/database.sql b/database.sql index 3e4e76cf0b..0542846572 100644 --- a/database.sql +++ b/database.sql @@ -33,6 +33,61 @@ CREATE TABLE IF NOT EXISTS `gserver` ( UNIQUE INDEX `nurl` (`nurl`(190)) ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Global servers'; +-- +-- TABLE user +-- +CREATE TABLE IF NOT EXISTS `user` ( + `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID', + `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user', + `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user', + `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by', + `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password', + `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?', + `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name', + `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address', + `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '', + `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone', + `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language', + `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration', + `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login', + `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location', + `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location', + `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference', + `pubkey` text COMMENT 'RSA public key 4096 bit', + `prvkey` text COMMENT 'RSA private key 4096 bit', + `spubkey` text COMMENT '', + `sprvkey` text COMMENT '', + `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email', + `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked', + `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user', + `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers', + `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user', + `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user', + `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '', + `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options', + `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type', + `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '', + `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '', + `pwdreset` varchar(255) COMMENT 'Password reset request token', + `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request', + `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '', + `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '', + `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed', + `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '', + `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted', + `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration', + `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '', + `allow_cid` mediumtext COMMENT 'default permission for this user', + `allow_gid` mediumtext COMMENT 'default permission for this user', + `deny_cid` mediumtext COMMENT 'default permission for this user', + `deny_gid` mediumtext COMMENT 'default permission for this user', + `openidserver` text COMMENT '', + PRIMARY KEY(`uid`), + INDEX `nickname` (`nickname`(32)), + INDEX `parent-uid` (`parent-uid`), + FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE +) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users'; + -- -- TABLE contact -- @@ -163,61 +218,6 @@ CREATE TABLE IF NOT EXISTS `tag` ( INDEX `url` (`url`) ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='tags and mentions'; --- --- TABLE user --- -CREATE TABLE IF NOT EXISTS `user` ( - `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID', - `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user', - `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user', - `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by', - `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password', - `legacy_password` boolean NOT NULL DEFAULT '0' COMMENT 'Is the password hash double-hashed?', - `nickname` varchar(255) NOT NULL DEFAULT '' COMMENT 'nick- and user name', - `email` varchar(255) NOT NULL DEFAULT '' COMMENT 'the users email address', - `openid` varchar(255) NOT NULL DEFAULT '' COMMENT '', - `timezone` varchar(128) NOT NULL DEFAULT '' COMMENT 'PHP-legal timezone', - `language` varchar(32) NOT NULL DEFAULT 'en' COMMENT 'default language', - `register_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of registration', - `login_date` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last login', - `default-location` varchar(255) NOT NULL DEFAULT '' COMMENT 'Default for item.location', - `allow_location` boolean NOT NULL DEFAULT '0' COMMENT '1 allows to display the location', - `theme` varchar(255) NOT NULL DEFAULT '' COMMENT 'user theme preference', - `pubkey` text COMMENT 'RSA public key 4096 bit', - `prvkey` text COMMENT 'RSA private key 4096 bit', - `spubkey` text COMMENT '', - `sprvkey` text COMMENT '', - `verified` boolean NOT NULL DEFAULT '0' COMMENT 'user is verified through email', - `blocked` boolean NOT NULL DEFAULT '0' COMMENT '1 for user is blocked', - `blockwall` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to post to the profile page of the user', - `hidewall` boolean NOT NULL DEFAULT '0' COMMENT 'Hide profile details from unkown viewers', - `blocktags` boolean NOT NULL DEFAULT '0' COMMENT 'Prohibit contacts to tag the post of this user', - `unkmail` boolean NOT NULL DEFAULT '0' COMMENT 'Permit unknown people to send private mails to this user', - `cntunkmail` int unsigned NOT NULL DEFAULT 10 COMMENT '', - `notify-flags` smallint unsigned NOT NULL DEFAULT 65535 COMMENT 'email notification options', - `page-flags` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'page/profile type', - `account-type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '', - `prvnets` boolean NOT NULL DEFAULT '0' COMMENT '', - `pwdreset` varchar(255) COMMENT 'Password reset request token', - `pwdreset_time` datetime COMMENT 'Timestamp of the last password reset request', - `maxreq` int unsigned NOT NULL DEFAULT 10 COMMENT '', - `expire` int unsigned NOT NULL DEFAULT 0 COMMENT '', - `account_removed` boolean NOT NULL DEFAULT '0' COMMENT 'if 1 the account is removed', - `account_expired` boolean NOT NULL DEFAULT '0' COMMENT '', - `account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp when account expires and will be deleted', - `expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00' COMMENT 'timestamp of last warning of account expiration', - `def_gid` int unsigned NOT NULL DEFAULT 0 COMMENT '', - `allow_cid` mediumtext COMMENT 'default permission for this user', - `allow_gid` mediumtext COMMENT 'default permission for this user', - `deny_cid` mediumtext COMMENT 'default permission for this user', - `deny_gid` mediumtext COMMENT 'default permission for this user', - `openidserver` text COMMENT '', - PRIMARY KEY(`uid`), - INDEX `nickname` (`nickname`(32)), - INDEX `parent-uid` (`parent-uid`), - FOREIGN KEY (`parent-uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE -) DEFAULT COLLATE utf8mb4_general_ci COMMENT='The local users'; - -- -- TABLE clients -- diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 9548e95f37..65d7ce7817 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -89,6 +89,62 @@ return [ "nurl" => ["UNIQUE", "nurl(190)"], ] ], + "user" => [ + "comment" => "The local users", + "fields" => [ + "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], + "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], + "comment" => "The parent user that has full control about this user"], + "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"], + "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"], + "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "encrypted password"], + "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"], + "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "nick- and user name"], + "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "the users email address"], + "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], + "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => "PHP-legal timezone"], + "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => "default language"], + "register_date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp of registration"], + "login_date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp of last login"], + "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Default for item.location"], + "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 allows to display the location"], + "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "user theme preference"], + "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"], + "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"], + "spubkey" => ["type" => "text", "comment" => ""], + "sprvkey" => ["type" => "text", "comment" => ""], + "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "user is verified through email"], + "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 for user is blocked"], + "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to post to the profile page of the user"], + "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide profile details from unkown viewers"], + "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to tag the post of this user"], + "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Permit unknown people to send private mails to this user"], + "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""], + "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => "email notification options"], + "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "page/profile type"], + "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], + "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"], + "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"], + "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""], + "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], + "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if 1 the account is removed"], + "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], + "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp when account expires and will be deleted"], + "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp of last warning of account expiration"], + "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], + "allow_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"], + "allow_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"], + "deny_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"], + "deny_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"], + "openidserver" => ["type" => "text", "comment" => ""], + ], + "indexes" => [ + "PRIMARY" => ["uid"], + "nickname" => ["nickname(32)"], + "parent-uid" => ["parent-uid"], + ] + ], "contact" => [ "comment" => "contact table", "fields" => [ @@ -220,62 +276,6 @@ return [ "url" => ["url"] ] ], - "user" => [ - "comment" => "The local users", - "fields" => [ - "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], - "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], - "comment" => "The parent user that has full control about this user"], - "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"], - "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"], - "password" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "encrypted password"], - "legacy_password" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Is the password hash double-hashed?"], - "nickname" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "nick- and user name"], - "email" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "the users email address"], - "openid" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => ""], - "timezone" => ["type" => "varchar(128)", "not null" => "1", "default" => "", "comment" => "PHP-legal timezone"], - "language" => ["type" => "varchar(32)", "not null" => "1", "default" => "en", "comment" => "default language"], - "register_date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp of registration"], - "login_date" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp of last login"], - "default-location" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Default for item.location"], - "allow_location" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 allows to display the location"], - "theme" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "user theme preference"], - "pubkey" => ["type" => "text", "comment" => "RSA public key 4096 bit"], - "prvkey" => ["type" => "text", "comment" => "RSA private key 4096 bit"], - "spubkey" => ["type" => "text", "comment" => ""], - "sprvkey" => ["type" => "text", "comment" => ""], - "verified" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "user is verified through email"], - "blocked" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "1 for user is blocked"], - "blockwall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to post to the profile page of the user"], - "hidewall" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Hide profile details from unkown viewers"], - "blocktags" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Prohibit contacts to tag the post of this user"], - "unkmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "Permit unknown people to send private mails to this user"], - "cntunkmail" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""], - "notify-flags" => ["type" => "smallint unsigned", "not null" => "1", "default" => "65535", "comment" => "email notification options"], - "page-flags" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "page/profile type"], - "account-type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "prvnets" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "pwdreset" => ["type" => "varchar(255)", "comment" => "Password reset request token"], - "pwdreset_time" => ["type" => "datetime", "comment" => "Timestamp of the last password reset request"], - "maxreq" => ["type" => "int unsigned", "not null" => "1", "default" => "10", "comment" => ""], - "expire" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "account_removed" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "if 1 the account is removed"], - "account_expired" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""], - "account_expires_on" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp when account expires and will be deleted"], - "expire_notification_sent" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "timestamp of last warning of account expiration"], - "def_gid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "comment" => ""], - "allow_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"], - "allow_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"], - "deny_cid" => ["type" => "mediumtext", "comment" => "default permission for this user"], - "deny_gid" => ["type" => "mediumtext", "comment" => "default permission for this user"], - "openidserver" => ["type" => "text", "comment" => ""], - ], - "indexes" => [ - "PRIMARY" => ["uid"], - "nickname" => ["nickname(32)"], - "parent-uid" => ["parent-uid"], - ] - ], "clients" => [ "comment" => "OAuth usage", "fields" => [ From 317921e51c676bf8bdc688bb9c819b34cb958ce8 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 17 Nov 2020 23:45:16 +0000 Subject: [PATCH 05/14] Changed order --- src/Database/DBStructure.php | 44 +++++++++++++++++------------------ static/dbstructure.config.php | 1 + 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 5d0749c583..a59376e0ca 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1054,6 +1054,28 @@ class DBStructure } } + if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) { + $system = User::getSystemAccount(); + $user = [ + "username" => $system['name'], + "nickname" => $system['nick'], + "register_date" => $system['created'], + "pubkey" => $system['pubkey'], + "prvkey" => $system['prvkey'], + "spubkey" => $system['spubkey'], + "sprvkey" => $system['sprvkey'], + "verified" => true, + "page-flags" => User::PAGE_FLAGS_SOAPBOX, + "account-type" => User::ACCOUNT_TYPE_RELAY, + ]; + + DBA::insert('user', $user); + $lastid = DBA::lastInsertId(); + if ($lastid != 0) { + DBA::update('user', ['uid' => 0], ['uid' => $lastid]); + } + } + if (self::existsTable('contact') && !DBA::exists('contact', ['id' => 0])) { DBA::insert('contact', ['nurl' => '']); $lastid = DBA::lastInsertId(); @@ -1101,28 +1123,6 @@ class DBStructure } } - if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) { - $system = User::getSystemAccount(); - $user = [ - "username" => $system['name'], - "nickname" => $system['nick'], - "register_date" => $system['created'], - "pubkey" => $system['pubkey'], - "prvkey" => $system['prvkey'], - "spubkey" => $system['spubkey'], - "sprvkey" => $system['sprvkey'], - "verified" => true, - "page-flags" => User::PAGE_FLAGS_SOAPBOX, - "account-type" => User::ACCOUNT_TYPE_RELAY, - ]; - - DBA::insert('user', $user); - $lastid = DBA::lastInsertId(); - if ($lastid != 0) { - DBA::update('user', ['uid' => 0], ['uid' => $lastid]); - } - } - if (!self::existsForeignKeyForField('tokens', 'client_id')) { $tokens = DBA::p("SELECT `tokens`.`id` FROM `tokens` LEFT JOIN `clients` ON `clients`.`client_id` = `tokens`.`client_id` diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 65d7ce7817..cabb48c58f 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -20,6 +20,7 @@ * Main database structure configuration file. * * Here are described all the tables, fields and indexes Friendica needs to work. + * The entry order is mostly alphabetic - with the exception of tables that are used in foreign keys. * * Syntax (braces indicate optionale values): * "" => [ From fed1ace31110dacafcdf6b6854c78cdd0e0216ec Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 17 Nov 2020 23:59:14 +0000 Subject: [PATCH 06/14] Fix condition --- src/Model/User.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Model/User.php b/src/Model/User.php index 39f9dc2a15..1959e95798 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -215,7 +215,7 @@ class User // List of possible actor names $possible_accounts = ['friendica', 'actor', 'system', 'internal']; foreach ($possible_accounts as $name) { - if (!DBA::exists('user', ['nickname' => $name, 'account_removed' => false, 'expire']) && + if (!DBA::exists('user', ['nickname' => $name, 'account_removed' => false, 'expire' => false]) && !DBA::exists('userd', ['username' => $name])) { DI::config()->set('system', 'actor_name', $name); return $name; From 1e9d3342a3e4e82159823dc8adf97c62032211eb Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 18 Nov 2020 00:13:39 +0000 Subject: [PATCH 07/14] Changed order of inserts --- src/Database/DBStructure.php | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index a59376e0ca..3c443d5371 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1055,6 +1055,22 @@ class DBStructure } if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) { + DBA::insert('user', ['uid' => 0]); + $lastid = DBA::lastInsertId(); + if ($lastid != 0) { + DBA::update('user', ['uid' => 0], ['uid' => $lastid]); + } + } + + if (self::existsTable('contact') && !DBA::exists('contact', ['id' => 0])) { + DBA::insert('contact', ['nurl' => '']); + $lastid = DBA::lastInsertId(); + if ($lastid != 0) { + DBA::update('contact', ['id' => 0], ['id' => $lastid]); + } + } + + if (self::existsTable('user') && DBA::exists('user', ['uid' => 0])) { $system = User::getSystemAccount(); $user = [ "username" => $system['name'], @@ -1069,19 +1085,7 @@ class DBStructure "account-type" => User::ACCOUNT_TYPE_RELAY, ]; - DBA::insert('user', $user); - $lastid = DBA::lastInsertId(); - if ($lastid != 0) { - DBA::update('user', ['uid' => 0], ['uid' => $lastid]); - } - } - - if (self::existsTable('contact') && !DBA::exists('contact', ['id' => 0])) { - DBA::insert('contact', ['nurl' => '']); - $lastid = DBA::lastInsertId(); - if ($lastid != 0) { - DBA::update('contact', ['id' => 0], ['id' => $lastid]); - } + DBA::update('user', $user, ['uid' => 0]); } if (self::existsTable('permissionset')) { From 4c78ac3ce220ded95eb3fb658a5068a39513edd3 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 18 Nov 2020 00:24:38 +0000 Subject: [PATCH 08/14] Avoid foreign key problem --- database.sql | 2 +- static/dbstructure.config.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/database.sql b/database.sql index 0542846572..a4f6aa636c 100644 --- a/database.sql +++ b/database.sql @@ -38,7 +38,7 @@ CREATE TABLE IF NOT EXISTS `gserver` ( -- CREATE TABLE IF NOT EXISTS `user` ( `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID', - `parent-uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'The parent user that has full control about this user', + `parent-uid` mediumint unsigned NOT NULL COMMENT 'The parent user that has full control about this user', `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user', `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by', `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password', diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index cabb48c58f..e726222459 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -94,7 +94,7 @@ return [ "comment" => "The local users", "fields" => [ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], - "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "default" => "0", "foreign" => ["user" => "uid"], + "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "foreign" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"], "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"], "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"], From a2c652bef5510b8bb317b15fd6be66b5facfd57f Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 18 Nov 2020 00:31:05 +0000 Subject: [PATCH 09/14] No "not null" --- database.sql | 2 +- static/dbstructure.config.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/database.sql b/database.sql index a4f6aa636c..e2b333a6da 100644 --- a/database.sql +++ b/database.sql @@ -38,7 +38,7 @@ CREATE TABLE IF NOT EXISTS `gserver` ( -- CREATE TABLE IF NOT EXISTS `user` ( `uid` mediumint unsigned NOT NULL auto_increment COMMENT 'sequential ID', - `parent-uid` mediumint unsigned NOT NULL COMMENT 'The parent user that has full control about this user', + `parent-uid` mediumint unsigned COMMENT 'The parent user that has full control about this user', `guid` varchar(64) NOT NULL DEFAULT '' COMMENT 'A unique identifier for this user', `username` varchar(255) NOT NULL DEFAULT '' COMMENT 'Name that this user is known by', `password` varchar(255) NOT NULL DEFAULT '' COMMENT 'encrypted password', diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index e726222459..e952675fef 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -94,7 +94,7 @@ return [ "comment" => "The local users", "fields" => [ "uid" => ["type" => "mediumint unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], - "parent-uid" => ["type" => "mediumint unsigned", "not null" => "1", "foreign" => ["user" => "uid"], + "parent-uid" => ["type" => "mediumint unsigned", "foreign" => ["user" => "uid"], "comment" => "The parent user that has full control about this user"], "guid" => ["type" => "varchar(64)", "not null" => "1", "default" => "", "comment" => "A unique identifier for this user"], "username" => ["type" => "varchar(255)", "not null" => "1", "default" => "", "comment" => "Name that this user is known by"], From 81a03b137b75fa111c817dec49f2885f75c809af Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 18 Nov 2020 05:04:17 +0000 Subject: [PATCH 10/14] Test: only insert empty user --- src/Database/DBStructure.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 3c443d5371..143526c038 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1070,7 +1070,7 @@ class DBStructure } } - if (self::existsTable('user') && DBA::exists('user', ['uid' => 0])) { +/* if (self::existsTable('user') && DBA::exists('user', ['uid' => 0])) { $system = User::getSystemAccount(); $user = [ "username" => $system['name'], @@ -1087,7 +1087,7 @@ class DBStructure DBA::update('user', $user, ['uid' => 0]); } - +*/ if (self::existsTable('permissionset')) { if (!DBA::exists('permissionset', ['id' => 0])) { DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']); From d7fa58d81cc7d267f15822947ad4416a3d19213f Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 18 Nov 2020 05:24:04 +0000 Subject: [PATCH 11/14] Ensure to never delete the "0" user --- src/Database/DBStructure.php | 7 ++++++- src/Worker/ExpireAndRemoveUsers.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 143526c038..dbe68aca16 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1058,7 +1058,12 @@ class DBStructure DBA::insert('user', ['uid' => 0]); $lastid = DBA::lastInsertId(); if ($lastid != 0) { - DBA::update('user', ['uid' => 0], ['uid' => $lastid]); + $user = [ + "verified" => true, + "page-flags" => User::PAGE_FLAGS_SOAPBOX, + "account-type" => User::ACCOUNT_TYPE_RELAY, + ]; + DBA::update('user', $user, ['uid' => $lastid]); } } diff --git a/src/Worker/ExpireAndRemoveUsers.php b/src/Worker/ExpireAndRemoveUsers.php index c8344b6fd9..f28f410b96 100644 --- a/src/Worker/ExpireAndRemoveUsers.php +++ b/src/Worker/ExpireAndRemoveUsers.php @@ -33,9 +33,14 @@ class ExpireAndRemoveUsers public static function execute() { // expire any expired regular accounts. Don't expire forums. - $condition = ["NOT `account_expired` AND `account_expires_on` > ? AND `account_expires_on` < UTC_TIMESTAMP() AND `page-flags` = 0", DBA::NULL_DATETIME]; + $condition = ["NOT `account_expired` AND `account_expires_on` > ? AND `account_expires_on` < UTC_TIMESTAMP() AND `page-flags` = ? AND `uid` != ?", + DBA::NULL_DATETIME, User::PAGE_FLAGS_NORMAL, 0]; DBA::update('user', ['account_expired' => true], $condition); + // Ensure to never remove the user with uid=0 + DBA::update('user', ['account_expired' => false, 'account_removed' => false, + 'account_expires_on' => DBA::NULL_DATETIME], ['uid' => 0]); + // Remove any freshly expired account $users = DBA::select('user', ['uid'], ['account_expired' => true, 'account_removed' => false]); while ($user = DBA::fetch($users)) { From b09ffa0697c0d500345fd17d33162a02982577a4 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 18 Nov 2020 05:33:17 +0000 Subject: [PATCH 12/14] Relocate system user creation --- src/Database/DBStructure.php | 18 ------------------ src/Model/User.php | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index dbe68aca16..37f55683a1 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1075,24 +1075,6 @@ class DBStructure } } -/* if (self::existsTable('user') && DBA::exists('user', ['uid' => 0])) { - $system = User::getSystemAccount(); - $user = [ - "username" => $system['name'], - "nickname" => $system['nick'], - "register_date" => $system['created'], - "pubkey" => $system['pubkey'], - "prvkey" => $system['prvkey'], - "spubkey" => $system['spubkey'], - "sprvkey" => $system['sprvkey'], - "verified" => true, - "page-flags" => User::PAGE_FLAGS_SOAPBOX, - "account-type" => User::ACCOUNT_TYPE_RELAY, - ]; - - DBA::update('user', $user, ['uid' => 0]); - } -*/ if (self::existsTable('permissionset')) { if (!DBA::exists('permissionset', ['id' => 0])) { DBA::insert('permissionset', ['allow_cid' => '', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '']); diff --git a/src/Model/User.php b/src/Model/User.php index 1959e95798..2b70189505 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -144,6 +144,26 @@ class User $system['sprvkey'] = $system['uprvkey'] = $system['prvkey']; $system['spubkey'] = $system['upubkey'] = $system['pubkey']; $system['nickname'] = $system['nick']; + + // Ensure that the user contains data + $user = DBA::selectFirst('user', ['prvkey'], ['uid' => 0]); + if (empty($user['prvkey'])) { + $fields = [ + 'username' => $system['name'], + 'nickname' => $system['nick'], + 'register_date' => $system['created'], + 'pubkey' => $system['pubkey'], + 'prvkey' => $system['prvkey'], + 'spubkey' => $system['spubkey'], + 'sprvkey' => $system['sprvkey'], + 'verified' => true, + 'page-flags' => User::PAGE_FLAGS_SOAPBOX, + 'account-type' => User::ACCOUNT_TYPE_RELAY, + ]; + + DBA::update('user', $fields, ['uid' => 0]); + } + return $system; } From 4f7d42a0d39279f59e247db6d21d579b14e7bd93 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 18 Nov 2020 05:55:15 +0000 Subject: [PATCH 13/14] Fixed copy&paste error --- src/Database/DBStructure.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 37f55683a1..b1b30171f6 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -1055,15 +1055,15 @@ class DBStructure } if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) { - DBA::insert('user', ['uid' => 0]); + $user = [ + "verified" => true, + "page-flags" => User::PAGE_FLAGS_SOAPBOX, + "account-type" => User::ACCOUNT_TYPE_RELAY, + ]; + DBA::insert('user', $user); $lastid = DBA::lastInsertId(); if ($lastid != 0) { - $user = [ - "verified" => true, - "page-flags" => User::PAGE_FLAGS_SOAPBOX, - "account-type" => User::ACCOUNT_TYPE_RELAY, - ]; - DBA::update('user', $user, ['uid' => $lastid]); + DBA::update('user', ['uid' => 0], ['uid' => $lastid]); } } From f36ecdf6bf189a4a991414890232e20d21e12892 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 18 Nov 2020 09:14:12 +0000 Subject: [PATCH 14/14] Replacing deprecated log calls --- src/Database/DBStructure.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index b1b30171f6..6f3fe5dba5 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -350,7 +350,7 @@ class DBStructure $errors = ''; - Logger::log('updating structure', Logger::DEBUG); + Logger::info('updating structure'); // Get the current structure $database = []; @@ -363,7 +363,7 @@ class DBStructure foreach ($tables AS $table) { $table = current($table); - Logger::log(sprintf('updating structure for table %s ...', $table), Logger::DEBUG); + Logger::info('updating structure', ['table' => $table]); $database[$table] = self::tableStructure($table); } }