language field renamed to "language"
authorMichael <heluecht@pirati.ca>
Fri, 2 Feb 2024 07:05:39 +0000 (07:05 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 2 Feb 2024 07:05:39 +0000 (07:05 +0000)
database.sql
doc/database/db_post-engagement.md
doc/database/db_post-searchindex.md
src/Database/PostUpdate.php
src/Model/Post/Engagement.php
src/Model/Post/SearchIndex.php
src/Module/Conversation/Timeline.php
static/dbstructure.config.php
update.php

index 871651b..c8ab483 100644 (file)
@@ -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 '',
index 2166702..c82c62b 100644 (file)
@@ -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    |       |
index 18efd60..c6504a7 100644 (file)
@@ -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    |       |
index bad13ad..c82fd09 100644 (file)
@@ -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)) {
index 3841a55..213550f 100644 (file)
@@ -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'],
index 042f800..98a82ca 100644 (file)
@@ -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'],
index 311a48a..eb14b2f 100644 (file)
@@ -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)) {
index 3dc1d4d..e9082ef 100644 (file)
@@ -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" => ""],
index 0e655e8..74a8ad7 100644 (file)
@@ -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;
+}