diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 5464a8e3..8bbddda4 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -18,8 +18,7 @@ exclude-labels: - 'wontfix' exclude-contributors: - 'dependabot' - - 'weblate' -change-template: '- $TITLE (#$NUMBER) @$AUTHOR' +change-template: '- $TITLE (#$NUMBER)' change-title-escapes: '\<*_&`#@' version-resolver: major: @@ -35,12 +34,14 @@ version-resolver: - 'translation' default: patch template: | - [Upgrade Kimai](https://www.kimai.org/documentation/updates.html) - [Install Kimai](https://www.kimai.org/documentation/installation.html) - [Docker](https://tobybatch.github.io/kimai2/) & [Hub](https://hub.docker.com/r/kimai/kimai2) + [Upgrade Kimai](https://www.kimai.org/documentation/updates.html) - [Install Kimai](https://www.kimai.org/documentation/installation.html) - [Docker](https://tobybatch.github.io/kimai2/) **PHP Version compatibility:** - PHP 7.3 is [end-of-life](https://www.php.net/supported-versions.php): you need to update now - PHP 7.4, PHP 8 and PHP 8.1 are supported - + $CHANGES - Thanks to $CONTRIBUTORS \ No newline at end of file + Thanks to all contributors ❤️ + + Involved in this release: $CONTRIBUTORS \ No newline at end of file diff --git a/src/Activity/ActivityService.php b/src/Activity/ActivityService.php index 09c3b434..cfcf2bde 100644 --- a/src/Activity/ActivityService.php +++ b/src/Activity/ActivityService.php @@ -101,4 +101,9 @@ class ActivityService return $activity; } + + public function findActivityByName(string $name, ?Project $project = null): ?Activity + { + return $this->repository->findOneBy(['project' => $project, 'name' => $name]); + } } diff --git a/src/Command/KimaiImporterCommand.php b/src/Command/KimaiImporterCommand.php index c87551fc..ae832dd8 100755 --- a/src/Command/KimaiImporterCommand.php +++ b/src/Command/KimaiImporterCommand.php @@ -386,7 +386,7 @@ final class KimaiImporterCommand extends Command } $io->success('Fetched Kimai v1 data, validating now'); - $validationMessages = $this->validateKimai1Data($options, $users, $customer, $projects, $rates); + $validationMessages = $this->validateKimai1Data($options, $users, $customer, $projects, $activities, $rates); if (!empty($validationMessages)) { foreach ($validationMessages as $errorMessage) { $io->error($errorMessage); @@ -484,7 +484,7 @@ final class KimaiImporterCommand extends Command return 0; } - private function validateKimai1Data(array $options, array $users, array $customer, array $projects, array $rates): array + private function validateKimai1Data(array $options, array $users, array $customer, array $projects, array $activities, array $rates): array { $validationMessages = []; @@ -523,6 +523,14 @@ final class KimaiImporterCommand extends Command $customerIds = []; foreach ($customer as $oldCustomer) { $customerIds[] = $oldCustomer['customerID']; + if (($customerNameLength = mb_strlen($oldCustomer['name'])) > 150) { + $validationMessages[] = sprintf( + 'Customer name "%s" (ID %s) is too long. Max. 150 character are allowed, found %s.', + $oldCustomer['name'], + $oldCustomer['customerID'], + $customerNameLength + ); + } } foreach ($projects as $oldProject) { @@ -534,6 +542,25 @@ final class KimaiImporterCommand extends Command $oldProject['customerID'] ); } + if (($projectNameLength = mb_strlen($oldProject['name'])) > 150) { + $validationMessages[] = sprintf( + 'Project name "%s" (ID %s) is too long. Max. 150 character are allowed, found %s.', + $oldProject['name'], + $oldProject['projectID'], + $projectNameLength + ); + } + } + + foreach ($activities as $oldActivity) { + if (($activityNameLength = mb_strlen($oldActivity['name'])) > 150) { + $validationMessages[] = sprintf( + 'Activity name "%s" (ID %s) is too long. Max. 150 character are allowed, found %s.', + $oldActivity['name'], + $oldActivity['activityID'], + $activityNameLength + ); + } } if (!$options['skip-error-rates']) { @@ -664,6 +691,10 @@ final class KimaiImporterCommand extends Command foreach ($listeners as $hash => $object) { if ($object instanceof TimesheetSubscriber) { $connection->getEventManager()->removeEventListener([$event], $object); + /* @phpstan-ignore-next-line */ + } elseif ($object instanceof \KimaiPlugin\AuditTrailBundle\Doctrine\MetadataSubscriber) { + // deactivate audit plugin listener + $connection->getEventManager()->removeEventListener([$event], $object); } } } @@ -2017,6 +2048,7 @@ final class KimaiImporterCommand extends Command private function fixEncoding(): void { + // https://onlineasciitools.com/convert-ascii-to-utf8 $searchReplace = [ 'ä' => 'ä', 'Ä' => 'Ä', @@ -2025,6 +2057,7 @@ final class KimaiImporterCommand extends Command 'ö' => 'ö', 'Ö' => 'Ö', 'ß' => 'ß', + '⦁' => '-', ]; $tablesColumns = [ diff --git a/src/Constants.php b/src/Constants.php index 58a18b68..90815e2c 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -17,11 +17,11 @@ class Constants /** * The current release version */ - public const VERSION = '1.21'; + public const VERSION = '1.22.0'; /** * The current release: major * 10000 + minor * 100 + patch */ - public const VERSION_ID = 12100; + public const VERSION_ID = 12200; /** * The current release status, either "stable" or "dev" */ diff --git a/tests/Twig/LocaleFormatExtensionsTest.php b/tests/Twig/LocaleFormatExtensionsTest.php index c649ebe7..ea5515fb 100644 --- a/tests/Twig/LocaleFormatExtensionsTest.php +++ b/tests/Twig/LocaleFormatExtensionsTest.php @@ -126,11 +126,13 @@ class LocaleFormatExtensionsTest extends TestCase public function getDateShortData() { + $timezone = new \DateTimeZone('Europe/Vienna'); + return [ - ['en', new \DateTime('7 January 2010'), '2010-01-07'], - ['en', new \DateTime('2016-06-23'), '2016-06-23'], - ['de', new \DateTime('1980-12-14'), '14.12.1980'], - ['ru', new \DateTime('1980-12-14'), '14.12.1980'], + ['en', new \DateTime('7 January 2010', $timezone), '2010-01-07'], + ['en', new \DateTime('2016-06-23', $timezone), '2016-06-23'], + ['de', new \DateTime('1980-12-14', $timezone), '14.12.1980'], + ['ru', new \DateTime('1980-12-14', $timezone), '14.12.1980'], ['ru', '1980-12-14', '14.12.1980'], ['ru', 1.2345, 1.2345], ]; @@ -153,9 +155,11 @@ class LocaleFormatExtensionsTest extends TestCase public function getDateTimeData() { + $timezone = new \DateTimeZone('Europe/Vienna'); + return [ - ['en', new \DateTime('7 January 2010'), '2010-01-07 12:01 AM'], - ['de', (new \DateTime('1980-12-14'))->setTime(13, 27, 55), '14.12.1980 13:27:55'], + ['en', new \DateTime('7 January 2010', $timezone), '2010-01-07 12:01 AM'], + ['de', (new \DateTime('1980-12-14', $timezone))->setTime(13, 27, 55), '14.12.1980 13:27:55'], ['de', '1980-12-14 13:27:55', '14.12.1980 13:27:55'], ['de', 1.2345, 1.2345], ];