From 7faa42882b32bbce311e23f5e38e1c6d5a1ba6d2 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 2 Feb 2024 07:05:39 +0000 Subject: [PATCH] language field renamed to "language" --- database.sql | 4 ++-- doc/database/db_post-engagement.md | 2 +- doc/database/db_post-searchindex.md | 2 +- src/Database/PostUpdate.php | 2 +- src/Model/Post/Engagement.php | 2 +- src/Model/Post/SearchIndex.php | 2 +- src/Module/Conversation/Timeline.php | 4 ++-- static/dbstructure.config.php | 4 ++-- update.php | 13 ++++++++++++- 9 files changed, 23 insertions(+), 12 deletions(-) diff --git a/database.sql b/database.sql index 871651bdb7..c8ab483b44 100644 --- a/database.sql +++ b/database.sql @@ -1346,7 +1346,7 @@ CREATE TABLE IF NOT EXISTS `post-engagement` ( `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner', `contact-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Person, organisation, news, community, relay', `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio', - `iso-639-1` char(2) COMMENT 'Language information about this post in the ISO 639-1 format', + `language` char(2) COMMENT 'Language information about this post in the ISO 639-1 format', `searchtext` mediumtext COMMENT 'Simplified text for the full text search', `size` int unsigned COMMENT 'Body size', `created` datetime COMMENT '', @@ -1469,7 +1469,7 @@ CREATE TABLE IF NOT EXISTS `post-searchindex` ( `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri', `owner-id` int unsigned NOT NULL DEFAULT 0 COMMENT 'Item owner', `media-type` tinyint NOT NULL DEFAULT 0 COMMENT 'Type of media in a bit array (1 = image, 2 = video, 4 = audio', - `iso-639-1` char(2) COMMENT 'Language information about this post in the ISO 639-1 format', + `language` char(2) COMMENT 'Language information about this post in the ISO 639-1 format', `searchtext` mediumtext COMMENT 'Simplified text for the full text search', `size` int unsigned COMMENT 'Body size', `created` datetime COMMENT '', diff --git a/doc/database/db_post-engagement.md b/doc/database/db_post-engagement.md index 2166702040..c82c62b863 100644 --- a/doc/database/db_post-engagement.md +++ b/doc/database/db_post-engagement.md @@ -12,7 +12,7 @@ Fields | owner-id | Item owner | int unsigned | NO | | 0 | | | contact-type | Person, organisation, news, community, relay | tinyint | NO | | 0 | | | media-type | Type of media in a bit array (1 = image, 2 = video, 4 = audio | tinyint | NO | | 0 | | -| iso-639-1 | Language information about this post in the ISO 639-1 format | char(2) | YES | | NULL | | +| language | Language information about this post in the ISO 639-1 format | char(2) | YES | | NULL | | | searchtext | Simplified text for the full text search | mediumtext | YES | | NULL | | | size | Body size | int unsigned | YES | | NULL | | | created | | datetime | YES | | NULL | | diff --git a/doc/database/db_post-searchindex.md b/doc/database/db_post-searchindex.md index 18efd607fc..c6504a7ed3 100644 --- a/doc/database/db_post-searchindex.md +++ b/doc/database/db_post-searchindex.md @@ -11,7 +11,7 @@ Fields | uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | PRI | NULL | | | owner-id | Item owner | int unsigned | NO | | 0 | | | media-type | Type of media in a bit array (1 = image, 2 = video, 4 = audio | tinyint | NO | | 0 | | -| iso-639-1 | Language information about this post in the ISO 639-1 format | char(2) | YES | | NULL | | +| language | Language information about this post in the ISO 639-1 format | char(2) | YES | | NULL | | | searchtext | Simplified text for the full text search | mediumtext | YES | | NULL | | | size | Body size | int unsigned | YES | | NULL | | | created | | datetime | YES | | NULL | | diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php index bad13ad4a9..c82fd090c8 100644 --- a/src/Database/PostUpdate.php +++ b/src/Database/PostUpdate.php @@ -1376,7 +1376,7 @@ class PostUpdate return true; } - $engagements = DBA::select('post-engagement', ['uri-id'], ["`iso-639-1` IS NULL"], ['order' => ['uri-id' => true], 'limit' => 1000]); + $engagements = DBA::select('post-engagement', ['uri-id'], ["`language` IS NULL"], ['order' => ['uri-id' => true], 'limit' => 1000]); while ($engagement = DBA::fetch($engagements)) { $item = Post::selectFirst([], ['uri-id' => $engagement['uri-id']]); if (empty($item)) { diff --git a/src/Model/Post/Engagement.php b/src/Model/Post/Engagement.php index 3841a55bd9..213550f9c6 100644 --- a/src/Model/Post/Engagement.php +++ b/src/Model/Post/Engagement.php @@ -104,7 +104,7 @@ class Engagement 'owner-id' => $parent['owner-id'], 'contact-type' => $parent['contact-contact-type'], 'media-type' => $mediatype, - 'iso-639-1' => $language, + 'language' => $language, 'searchtext' => $searchtext, 'size' => self::getContentSize($parent), 'created' => $parent['created'], diff --git a/src/Model/Post/SearchIndex.php b/src/Model/Post/SearchIndex.php index 042f800d46..98a82cae63 100644 --- a/src/Model/Post/SearchIndex.php +++ b/src/Model/Post/SearchIndex.php @@ -53,7 +53,7 @@ class SearchIndex 'uri-id' => $uri_id, 'owner-id' => $item['owner-id'], 'media-type' => Engagement::getMediaType($uri_id), - 'iso-639-1' => !empty($item['language']) ? (array_key_first(json_decode($item['language'], true)) ?? L10n::UNDETERMINED_LANGUAGE) : L10n::UNDETERMINED_LANGUAGE, + 'language' => !empty($item['language']) ? (array_key_first(json_decode($item['language'], true)) ?? L10n::UNDETERMINED_LANGUAGE) : L10n::UNDETERMINED_LANGUAGE, 'searchtext' => Post\Engagement::getSearchTextForUriId($uri_id, $refresh), 'size' => Engagement::getContentSize($item), 'created' => $item['created'], diff --git a/src/Module/Conversation/Timeline.php b/src/Module/Conversation/Timeline.php index 311a48a204..eb14b2ffc4 100644 --- a/src/Module/Conversation/Timeline.php +++ b/src/Module/Conversation/Timeline.php @@ -324,7 +324,7 @@ class Timeline extends BaseModule } elseif ($this->selectedTab == ChannelEntity::AUDIO) { $condition = ["`media-type` & ?", 4]; } elseif ($this->selectedTab == ChannelEntity::LANGUAGE) { - $condition = ["`iso-639-1` = ?", User::getLanguageCode($uid)]; + $condition = ["`language` = ?", User::getLanguageCode($uid)]; } elseif (is_numeric($this->selectedTab)) { $condition = $this->getUserChannelConditions($this->selectedTab, $uid); } @@ -450,7 +450,7 @@ class Timeline extends BaseModule $conditions = []; $languages = $languages ?: User::getWantedLanguages($uid); foreach ($languages as $language) { - $conditions[] = "`iso-639-1` = ?"; + $conditions[] = "`language` = ?"; $condition[] = $language; } if (!empty($conditions)) { diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 3dc1d4d38c..e9082efc66 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -1367,7 +1367,7 @@ return [ "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id"], "comment" => "Item owner"], "contact-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Person, organisation, news, community, relay"], "media-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Type of media in a bit array (1 = image, 2 = video, 4 = audio"], - "iso-639-1" => ["type" => "char(2)", "comment" => "Language information about this post in the ISO 639-1 format"], + "language" => ["type" => "char(2)", "comment" => "Language information about this post in the ISO 639-1 format"], "searchtext" => ["type" => "mediumtext", "comment" => "Simplified text for the full text search"], "size" => ["type" => "int unsigned", "comment" => "Body size"], "created" => ["type" => "datetime", "comment" => ""], @@ -1488,7 +1488,7 @@ return [ "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"], "owner-id" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "foreign" => ["contact" => "id"], "comment" => "Item owner"], "media-type" => ["type" => "tinyint", "not null" => "1", "default" => "0", "comment" => "Type of media in a bit array (1 = image, 2 = video, 4 = audio"], - "iso-639-1" => ["type" => "char(2)", "comment" => "Language information about this post in the ISO 639-1 format"], + "language" => ["type" => "char(2)", "comment" => "Language information about this post in the ISO 639-1 format"], "searchtext" => ["type" => "mediumtext", "comment" => "Simplified text for the full text search"], "size" => ["type" => "int unsigned", "comment" => "Body size"], "created" => ["type" => "datetime", "comment" => ""], diff --git a/update.php b/update.php index 0e655e83db..74a8ad7015 100644 --- a/update.php +++ b/update.php @@ -1410,4 +1410,15 @@ function update_1539() DBA::close($users); return Update::SUCCESS; -} \ No newline at end of file +} + +function pre_update_1550() +{ + if (DBStructure::existsTable('post-engagement') && DBStructure::existsColumn('post-engagement', ['language'])) { + DBA::e("ALTER TABLE `post-engagement` DROP `language`"); + } + if (DBStructure::existsTable('post-searchindex') && DBStructure::existsColumn('post-searchindex', ['network'])) { + DBA::e("ALTER TABLE `post-searchindex` DROP `network`, DROP `private`"); + } + return Update::SUCCESS; +}