From 266c4bad25e8632f723153c111bd637037879004 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Wed, 22 Feb 2023 15:06:54 +0100 Subject: [PATCH] Cleanup after 2.0 (#3868) * removed duration_only mode * cleanup database * remove deleted user preference keys --- UPGRADING.md | 2 +- migrations/Version20230126002049.php | 2 +- migrations/Version20230126002050.php | 73 +++++++++++++++++ src/Entity/User.php | 2 - .../TrackingMode/DurationOnlyMode.php | 82 ------------------- translations/system-configuration.uk.xlf | 4 - 6 files changed, 75 insertions(+), 90 deletions(-) create mode 100644 migrations/Version20230126002050.php delete mode 100644 src/Timesheet/TrackingMode/DurationOnlyMode.php diff --git a/UPGRADING.md b/UPGRADING.md index ee27fa1b..c97be09d 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -23,7 +23,7 @@ Developer read the full documentation at [https://www.kimai.org/documentation/mi - dashboard default config - removed: theme.branding.translation - removed: kimai.plugin_dir -- Time-tracking mode `duration_only` was removed, existing installations will be switched to `default` +- Time-tracking mode `duration_only` was removed, existing installations will be switched to `duration_fixed_begin` - Removed Twig filters. You might have to replace them in your custom export/invoice templates: - `date_full` => `date_time` - `duration_decimal` => `duration(true)` diff --git a/migrations/Version20230126002049.php b/migrations/Version20230126002049.php index 9f600553..5adfd095 100644 --- a/migrations/Version20230126002049.php +++ b/migrations/Version20230126002049.php @@ -121,7 +121,7 @@ final class Version20230126002049 extends AbstractMigration } $this->addSql("UPDATE kimai2_user_preferences SET `name` = 'theme.collapsed_sidebar' WHERE `name` = 'collapsed_sidebar'"); - $this->addSql("UPDATE kimai2_user_preferences SET `name` = 'theme.layout' WHERE `name` = 'theme_layout'"); + $this->addSql("UPDATE kimai2_user_preferences SET `name` = 'theme.layout' WHERE `name` = 'layout'"); $this->addSql("UPDATE kimai2_user_preferences SET `name` = 'calendar.initial_view' WHERE `name` = 'calendar_initial_view'"); $this->addSql("UPDATE kimai2_user_preferences SET `name` = 'login.initial_view' WHERE `name` = 'login_initial_view'"); $this->addSql("UPDATE kimai2_user_preferences SET `name` = 'timesheet.daily_stats' WHERE `name` = 'timesheet_daily_stats'"); diff --git a/migrations/Version20230126002050.php b/migrations/Version20230126002050.php new file mode 100644 index 00000000..5e89b3a5 --- /dev/null +++ b/migrations/Version20230126002050.php @@ -0,0 +1,73 @@ +addSql("UPDATE kimai2_user_preferences SET `value` = 'en_GB' WHERE `value` = 'en'"); + $this->addSql("UPDATE kimai2_user_preferences p0 LEFT JOIN kimai2_user_preferences p1 ON p0.user_id = p1.user_id SET p0.`value` = 'en' WHERE p0.`value` = 'en_GB' AND p0.`name` = 'language' AND p1.`value` = '0' AND p1.`name` = 'hours_24'"); + + $this->addSql("DELETE FROM kimai2_user_preferences WHERE `name` = 'theme.collapsed_sidebar'"); + $this->addSql("DELETE FROM kimai2_user_preferences WHERE `name` = 'collapsed_sidebar'"); + $this->addSql("DELETE FROM kimai2_roles_permissions WHERE `permission` LIKE 'comments_create%'"); + + $this->addSql("DELETE FROM kimai2_user_preferences where `name` = 'theme.layout'"); // cleanup for weird cases, was renamed to + $this->addSql("DELETE FROM kimai2_user_preferences where `name` = 'theme_layout'"); + $this->addSql("DELETE FROM kimai2_user_preferences where `name` = 'layout'"); + + $this->addSql("DELETE FROM kimai2_user_preferences where `name` = 'reporting.initial_view'"); + $this->addSql("DELETE FROM kimai2_user_preferences where `name` = 'hours_24'"); + $this->addSql("UPDATE kimai2_user_preferences SET `value` = 'default' WHERE `name` = 'skin' AND `value` NOT IN ('default', 'dark')"); + + $this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'timesheet.active_entries.soft_limit'"); + $this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'theme.autocomplete_chars'"); + $this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'theme.tags_create'"); + $this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'theme.branding.mini'"); + $this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'theme.branding.title'"); + $this->addSql("UPDATE kimai2_configuration SET `value` = 'duration_fixed_begin' WHERE `name` = 'timesheet.mode' AND `value` = 'duration_only'"); + $this->addSql("UPDATE kimai2_configuration SET `value` = 'default' WHERE `name` = 'defaults.user.theme' AND `value` NOT IN ('default', 'dark')"); + + $templates = $schema->getTable('kimai2_invoice_templates'); + $templates->dropColumn('decimal_duration'); + + // cannot be moved to the earlier migration, because of the execution order of schema changes and SQL statements + $templates->getColumn('language')->setNotnull(true); + } + + public function down(Schema $schema): void + { + $templates = $schema->getTable('kimai2_invoice_templates'); + + $templates->addColumn('decimal_duration', 'boolean', ['notnull' => true, 'default' => false]); + $templates->getColumn('language')->setNotnull(false); + + $this->addSql("UPDATE kimai2_user_preferences SET `value` = 'fixed' WHERE `name` = 'layout' and `value` IN ('default', 'dark')"); + + // rollback makes it impossible to choose the correct one + $this->addSql("DELETE FROM kimai2_user_preferences WHERE `name` = 'skin'"); + $this->addSql("DELETE FROM kimai2_configuration WHERE `name` = 'defaults.user.theme'"); + } +} diff --git a/src/Entity/User.php b/src/Entity/User.php index 9acbd5a2..cadc7883 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -322,8 +322,6 @@ class User implements UserInterface, EquatableInterface, ThemeUserInterface, Pas UserPreference::SKIN, 'calendar_initial_view', 'login_initial_view', - 'collapsed_sidebar', // TODO @2.1 removed with 2.0, can be deleted with 2.1 - 'layout', // TODO @2.1 removed with 2.0, can be deleted with 2.1 'update_browser_title', 'daily_stats', 'export_decimal', diff --git a/src/Timesheet/TrackingMode/DurationOnlyMode.php b/src/Timesheet/TrackingMode/DurationOnlyMode.php deleted file mode 100644 index 2f174297..00000000 --- a/src/Timesheet/TrackingMode/DurationOnlyMode.php +++ /dev/null @@ -1,82 +0,0 @@ -getBegin()) { - $timesheet->setBegin(new DateTime('now', $this->getTimezone($timesheet))); - } - - $this->rounding->roundBegin($timesheet); - - if (null !== $timesheet->getEnd()) { - $this->rounding->roundEnd($timesheet); - - if (null !== $timesheet->getDuration()) { - $this->rounding->roundDuration($timesheet); - } - } - } -} diff --git a/translations/system-configuration.uk.xlf b/translations/system-configuration.uk.xlf index bb68102e..700cb78e 100644 --- a/translations/system-configuration.uk.xlf +++ b/translations/system-configuration.uk.xlf @@ -34,10 +34,6 @@ timesheet.mode_default [Типово] час початку та закінчення можна редагувати - - timesheet.mode_duration_only - [Тривалість] замінює час закінчення на поле введення тривалості - timesheet.mode_duration_fixed_begin [Тривалість] конфігурований фіксований час запуску, можна змінити лише тривалість