From be394b573dbdbd098cfca2d2349896fd08477b50 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 14 Oct 2023 18:39:35 +0000 Subject: [PATCH 1/2] Channels: Larger fields, better error handling --- database.sql | 8 +++---- doc/database/db_channel.md | 6 ++--- src/Content/Conversation/Factory/Timeline.php | 2 -- src/Module/Conversation/Network.php | 22 +++++++++++-------- src/Module/Conversation/Timeline.php | 4 ++++ src/Module/Settings/Channels.php | 10 ++++----- static/dbstructure.config.php | 8 +++---- view/lang/C/messages.po | 19 ++++++++++------ view/templates/settings/channels.tpl | 12 +++++----- 9 files changed, 51 insertions(+), 40 deletions(-) diff --git a/database.sql b/database.sql index ec7adc5c7a..05fbe131f7 100644 --- a/database.sql +++ b/database.sql @@ -1,6 +1,6 @@ -- ------------------------------------------ -- Friendica 2023.09-rc (Giant Rhubarb) --- DB_UPDATE_VERSION 1536 +-- DB_UPDATE_VERSION 1537 -- ------------------------------------------ @@ -502,9 +502,9 @@ CREATE TABLE IF NOT EXISTS `channel` ( `description` varchar(64) COMMENT 'Channel description', `circle` int COMMENT 'Circle or channel that this channel is based on', `access-key` varchar(1) COMMENT 'Access key', - `include-tags` varchar(255) COMMENT 'Comma separated list of tags that will be included in the channel', - `exclude-tags` varchar(255) COMMENT 'Comma separated list of tags that aren\'t allowed in the channel', - `full-text-search` varchar(255) COMMENT 'Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode', + `include-tags` varchar(1023) COMMENT 'Comma separated list of tags that will be included in the channel', + `exclude-tags` varchar(1023) COMMENT 'Comma separated list of tags that aren\'t allowed in the channel', + `full-text-search` varchar(1023) COMMENT 'Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode', `media-type` smallint unsigned COMMENT 'Filtered media types', PRIMARY KEY(`id`), INDEX `uid` (`uid`), diff --git a/doc/database/db_channel.md b/doc/database/db_channel.md index e37aa93d11..9b9486fa32 100644 --- a/doc/database/db_channel.md +++ b/doc/database/db_channel.md @@ -14,9 +14,9 @@ Fields | description | Channel description | varchar(64) | YES | | NULL | | | circle | Circle or channel that this channel is based on | int | YES | | NULL | | | access-key | Access key | varchar(1) | YES | | NULL | | -| include-tags | Comma separated list of tags that will be included in the channel | varchar(255) | YES | | NULL | | -| exclude-tags | Comma separated list of tags that aren't allowed in the channel | varchar(255) | YES | | NULL | | -| full-text-search | Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode | varchar(255) | YES | | NULL | | +| include-tags | Comma separated list of tags that will be included in the channel | varchar(1023) | YES | | NULL | | +| exclude-tags | Comma separated list of tags that aren't allowed in the channel | varchar(1023) | YES | | NULL | | +| full-text-search | Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode | varchar(1023) | YES | | NULL | | | media-type | Filtered media types | smallint unsigned | YES | | NULL | | Indexes diff --git a/src/Content/Conversation/Factory/Timeline.php b/src/Content/Conversation/Factory/Timeline.php index a726762fd5..233488c281 100644 --- a/src/Content/Conversation/Factory/Timeline.php +++ b/src/Content/Conversation/Factory/Timeline.php @@ -21,8 +21,6 @@ namespace Friendica\Content\Conversation\Factory; -use Friendica\Capabilities\ICanCreateFromTableRow; -use Friendica\Content\Conversation\Entity\Timeline as TimelineEntity; use Friendica\Content\Conversation\Repository\UserDefinedChannel; use Friendica\Core\Config\Capability\IManageConfigValues; use Friendica\Core\L10n; diff --git a/src/Module/Conversation/Network.php b/src/Module/Conversation/Network.php index 24e3e57891..5be78fc11e 100644 --- a/src/Module/Conversation/Network.php +++ b/src/Module/Conversation/Network.php @@ -139,14 +139,6 @@ class Network extends Timeline $o = ''; - if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { - $items = $this->getChannelItems(); - } elseif ($this->community->isTimeline($this->selectedTab)) { - $items = $this->getCommunityItems(); - } else { - $items = $this->getItems(); - } - $this->page['aside'] .= Circle::sidebarWidget($module, $module . '/circle', 'standard', $this->circleId); $this->page['aside'] .= GroupManager::widget($module . '/group', $this->session->getLocalUserId(), $this->groupContactId); $this->page['aside'] .= Widget::postedByYear($module . '/archive', $this->session->getLocalUserId(), false); @@ -244,7 +236,19 @@ class Network extends Timeline $o .= Profile::getEventsReminderHTML(); } - $o .= $this->conversation->render($items, Conversation::MODE_NETWORK, false, false, $this->getOrder(), $this->session->getLocalUserId()); + try { + if ($this->channel->isTimeline($this->selectedTab) || $this->userDefinedChannel->isTimeline($this->selectedTab, $this->session->getLocalUserId())) { + $items = $this->getChannelItems(); + } elseif ($this->community->isTimeline($this->selectedTab)) { + $items = $this->getCommunityItems(); + } else { + $items = $this->getItems(); + } + + $o .= $this->conversation->render($items, Conversation::MODE_NETWORK, false, false, $this->getOrder(), $this->session->getLocalUserId()); + } catch (\Exception $e) { + $o .= $this->l10n->t('Error %d (%s) while fetching the timeline.', $e->getCode(), $e->getMessage()); + } if ($this->pConfig->get($this->session->getLocalUserId(), 'system', 'infinite_scroll')) { $o .= HTML::scrollLoader(); diff --git a/src/Module/Conversation/Timeline.php b/src/Module/Conversation/Timeline.php index eb362eba7b..d15fefe3e0 100644 --- a/src/Module/Conversation/Timeline.php +++ b/src/Module/Conversation/Timeline.php @@ -346,6 +346,10 @@ class Timeline extends BaseModule $items = []; $result = $this->database->select('post-engagement', ['uri-id', 'created', 'owner-id', 'comments', 'activities'], $condition, $params); + if ($this->database->errorNo()) { + throw new \Exception($this->database->errorMessage(), $this->database->errorNo()); + } + while ($item = $this->database->fetch($result)) { $items[$item['uri-id']] = $item; } diff --git a/src/Module/Settings/Channels.php b/src/Module/Settings/Channels.php index 55938e06f9..112f064922 100644 --- a/src/Module/Settings/Channels.php +++ b/src/Module/Settings/Channels.php @@ -71,7 +71,7 @@ class Channels extends BaseSettings 'circle' => (int)$request['new_circle'], 'include-tags' => $this->cleanTags($request['new_include_tags']), 'exclude-tags' => $this->cleanTags($request['new_exclude_tags']), - 'full-text-search' => $this->cleanTags($request['new_text_search']), + 'full-text-search' => $request['new_text_search'], 'media-type' => ($request['new_image'] ? 1 : 0) | ($request['new_video'] ? 2 : 0) | ($request['new_audio'] ? 4 : 0), ]); $saved = $this->channel->save($channel); @@ -95,7 +95,7 @@ class Channels extends BaseSettings 'circle' => (int)$request['circle'][$id], 'include-tags' => $this->cleanTags($request['include_tags'][$id]), 'exclude-tags' => $this->cleanTags($request['exclude_tags'][$id]), - 'full-text-search' => $this->cleanTags($request['text_search'][$id]), + 'full-text-search' => $request['text_search'][$id], 'media-type' => ($request['image'][$id] ? 1 : 0) | ($request['video'][$id] ? 2 : 0) | ($request['audio'][$id] ? 4 : 0), ]); $saved = $this->channel->save($channel); @@ -131,8 +131,8 @@ class Channels extends BaseSettings 'description' => ["description[$channel->code]", $this->t("Description"), $channel->description], 'access_key' => ["access_key[$channel->code]", $this->t("Access Key"), $channel->accessKey], 'circle' => ["circle[$channel->code]", $this->t('Circle/Channel'), $channel->circle, '', $circles], - 'include_tags' => ["include_tags[$channel->code]", $this->t("Include Tags"), $channel->includeTags], - 'exclude_tags' => ["exclude_tags[$channel->code]", $this->t("Exclude Tags"), $channel->excludeTags], + 'include_tags' => ["include_tags[$channel->code]", $this->t("Include Tags"), str_replace(',', ', ', $channel->includeTags)], + 'exclude_tags' => ["exclude_tags[$channel->code]", $this->t("Exclude Tags"), str_replace(',', ', ', $channel->excludeTags)], 'text_search' => ["text_search[$channel->code]", $this->t("Full Text Search"), $channel->fullTextSearch], 'image' => ["image[$channel->code]", $this->t("Images"), $channel->mediaType & 1], 'video' => ["video[$channel->code]", $this->t("Videos"), $channel->mediaType & 2], @@ -180,7 +180,7 @@ class Channels extends BaseSettings foreach ($tagitems as $tag) { $tag = trim($tag, '# '); if (!empty($tag)) { - $tags[] = $tag; + $tags[] = preg_replace('#\s#u', '', $tag); } } return implode(',', $tags); diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 3439b901d3..b7a37708cd 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', 1536); + define('DB_UPDATE_VERSION', 1537); } return [ @@ -560,9 +560,9 @@ return [ "description" => ["type" => "varchar(64)", "comment" => "Channel description"], "circle" => ["type" => "int", "comment" => "Circle or channel that this channel is based on"], "access-key" => ["type" => "varchar(1)", "comment" => "Access key"], - "include-tags" => ["type" => "varchar(255)", "comment" => "Comma separated list of tags that will be included in the channel"], - "exclude-tags" => ["type" => "varchar(255)", "comment" => "Comma separated list of tags that aren't allowed in the channel"], - "full-text-search" => ["type" => "varchar(255)", "comment" => "Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode"], + "include-tags" => ["type" => "varchar(1023)", "comment" => "Comma separated list of tags that will be included in the channel"], + "exclude-tags" => ["type" => "varchar(1023)", "comment" => "Comma separated list of tags that aren't allowed in the channel"], + "full-text-search" => ["type" => "varchar(1023)", "comment" => "Full text search pattern, see https://mariadb.com/kb/en/full-text-index-overview/#in-boolean-mode"], "media-type" => ["type" => "smallint unsigned", "comment" => "Filtered media types"], ], "indexes" => [ diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 2a478519d8..df6411a9ff 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2023.09-rc\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-10-11 20:35+0000\n" +"POT-Creation-Date: 2023-10-14 18:38+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2205,11 +2205,11 @@ msgstr "" msgid "Encrypted content" msgstr "" -#: src/Content/Text/BBCode.php:1957 +#: src/Content/Text/BBCode.php:1953 msgid "Invalid source protocol" msgstr "" -#: src/Content/Text/BBCode.php:1976 +#: src/Content/Text/BBCode.php:1972 msgid "Invalid link protocol" msgstr "" @@ -5961,7 +5961,7 @@ msgid "Contact not found." msgstr "" #: src/Module/Circle.php:102 src/Module/Contact/Contacts.php:66 -#: src/Module/Conversation/Network.php:240 +#: src/Module/Conversation/Network.php:232 msgid "Invalid contact." msgstr "" @@ -6747,16 +6747,21 @@ msgstr "" msgid "Not available." msgstr "" -#: src/Module/Conversation/Network.php:226 +#: src/Module/Conversation/Network.php:218 msgid "No such circle" msgstr "" -#: src/Module/Conversation/Network.php:230 +#: src/Module/Conversation/Network.php:222 #, php-format msgid "Circle: %s" msgstr "" -#: src/Module/Conversation/Network.php:325 +#: src/Module/Conversation/Network.php:250 +#, php-format +msgid "Error %d (%s) while fetching the timeline." +msgstr "" + +#: src/Module/Conversation/Network.php:329 msgid "Network feed not available." msgstr "" diff --git a/view/templates/settings/channels.tpl b/view/templates/settings/channels.tpl index 16bb510d6c..27defffdb0 100644 --- a/view/templates/settings/channels.tpl +++ b/view/templates/settings/channels.tpl @@ -8,9 +8,9 @@ {{include file="field_input.tpl" field=$description}} {{include file="field_input.tpl" field=$access_key}} {{include file="field_select.tpl" field=$circle}} - {{include file="field_input.tpl" field=$include_tags}} - {{include file="field_input.tpl" field=$exclude_tags}} - {{include file="field_input.tpl" field=$text_search}} + {{include file="field_textarea.tpl" field=$include_tags}} + {{include file="field_textarea.tpl" field=$exclude_tags}} + {{include file="field_textarea.tpl" field=$text_search}} {{include file="field_checkbox.tpl" field=$image}} {{include file="field_checkbox.tpl" field=$video}} {{include file="field_checkbox.tpl" field=$audio}} @@ -28,9 +28,9 @@ {{include file="field_input.tpl" field=$e.description}} {{include file="field_input.tpl" field=$e.access_key}} {{include file="field_select.tpl" field=$e.circle}} - {{include file="field_input.tpl" field=$e.include_tags}} - {{include file="field_input.tpl" field=$e.exclude_tags}} - {{include file="field_input.tpl" field=$e.text_search}} + {{include file="field_textarea.tpl" field=$e.include_tags}} + {{include file="field_textarea.tpl" field=$e.exclude_tags}} + {{include file="field_textarea.tpl" field=$e.text_search}} {{include file="field_checkbox.tpl" field=$e.image}} {{include file="field_checkbox.tpl" field=$e.video}} {{include file="field_checkbox.tpl" field=$e.audio}} From b1cf8ee4df2421b340d8b1afbbd9be4020f5466f Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 14 Oct 2023 19:09:45 +0000 Subject: [PATCH 2/2] Updated messages.po --- view/lang/C/messages.po | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 11b8d09c7c..0588c4a635 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2023.09-rc\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-10-14 18:38+0000\n" +"POT-Creation-Date: 2023-10-14 19:09+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2725,8 +2725,8 @@ msgstr "" #: src/Core/Installer.php:519 msgid "" -"The web installer needs to be able to create a file called \"local.config." -"php\" in the \"config\" folder of your web server and it is unable to do so." +"The web installer needs to be able to create a file called \"local.config.php" +"\" in the \"config\" folder of your web server and it is unable to do so." msgstr "" #: src/Core/Installer.php:520 @@ -5357,9 +5357,9 @@ msgstr "" #: src/Module/Admin/Summary.php:98 msgid "" -"The last update failed. Please run \"php bin/console.php dbstructure " -"update\" from the command line and have a look at the errors that might " -"appear. (Some of the errors are possibly inside the logfile.)" +"The last update failed. Please run \"php bin/console.php dbstructure update" +"\" from the command line and have a look at the errors that might appear. " +"(Some of the errors are possibly inside the logfile.)" msgstr "" #: src/Module/Admin/Summary.php:102 @@ -5510,8 +5510,8 @@ msgstr "" #, php-format msgid "" "Show some informations regarding the needed information to operate the node " -"according e.g. to EU-GDPR." +"according e.g. to EU-GDPR." msgstr "" #: src/Module/Admin/Tos.php:81 @@ -8844,8 +8844,8 @@ msgstr "" #: src/Module/Profile/Profile.php:158 #, php-format msgid "" -"You're currently viewing your profile as %s Cancel" +"You're currently viewing your profile as %s Cancel" msgstr "" #: src/Module/Profile/Profile.php:167 @@ -9393,8 +9393,8 @@ msgstr "" #: src/Module/Security/TwoFactor/Verify.php:100 #, php-format msgid "" -"If you do not have access to your authentication code you can use a two-factor recovery code." +"If you do not have access to your authentication code you can use a two-factor recovery code." msgstr "" #: src/Module/Security/TwoFactor/Verify.php:101 @@ -11045,8 +11045,8 @@ msgstr "" #: src/Module/Settings/TwoFactor/Verify.php:149 #, php-format msgid "" -"

Or you can open the following URL in your mobile device:

%s

" +"

Or you can open the following URL in your mobile device:

%s

" msgstr "" #: src/Module/Settings/TwoFactor/Verify.php:156 @@ -11155,9 +11155,9 @@ msgstr "" msgid "" "At any point in time a logged in user can export their account data from the " "account settings. If the user wants " -"to delete their account they can do so at %1$s/settings/removeme. The deletion of the account will be " -"permanent. Deletion of the data will also be requested from the nodes of the " +"to delete their account they can do so at " +"%1$s/settings/removeme. The deletion of the account will be permanent. " +"Deletion of the data will also be requested from the nodes of the " "communication partners." msgstr ""