diff --git a/.github_changelog_generator b/.github_changelog_generator index 23e4c06d..91ab889c 100644 --- a/.github_changelog_generator +++ b/.github_changelog_generator @@ -1,5 +1,5 @@ unreleased=true -future-release=1.7 +future-release=1.8 exclude-labels=duplicate,question,invalid,wontfix,release enhancement_labels=>enhancement,Enhancement,feature request,translation i18n,technical debt issues-wo-labels=false diff --git a/CHANGELOG.md b/CHANGELOG.md index 70be6d58..ca57e4c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## [1.8](https://github.com/kevinpapst/kimai2/tree/1.8) +[Full Changelog](https://github.com/kevinpapst/kimai2/compare/1.7...1.8) + +Release notes including the changelog can be found [here](https://github.com/kevinpapst/kimai2/releases/tag/1.8) + ## [1.7](https://github.com/kevinpapst/kimai2/tree/1.7) [Full Changelog](https://github.com/kevinpapst/kimai2/compare/1.6.2...1.7) diff --git a/config/validator/validation.yaml b/config/validator/validation.yaml index 8bd3c07d..f0ed76fb 100644 --- a/config/validator/validation.yaml +++ b/config/validator/validation.yaml @@ -4,7 +4,7 @@ App\Entity\User: - App\Validator\Constraints\Role: ~ username: - NotBlank: ~ - - Length: { min: 3, max: 60 } + - Length: { min: 2, max: 60 } email: - NotBlank: ~ - Email: ~ diff --git a/src/Command/ReloadCommand.php b/src/Command/ReloadCommand.php new file mode 100644 index 00000000..713a52f5 --- /dev/null +++ b/src/Command/ReloadCommand.php @@ -0,0 +1,138 @@ +setName('kimai:reload') + ->setDescription('Reload Kimai caches') + ->setHelp('This command will validate the configurations and translations and then clear and rebuild the application cache.') + ; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int|null + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $io = new SymfonyStyle($input, $output); + + $io->title('Reloading configurations ...'); + + try { + $command = $this->getApplication()->find('lint:yaml'); + $cmdInput = new StringInput('lint:yaml --parse-tags config'); + $cmdInput->setInteractive(false); + if (0 !== $command->run($cmdInput, $output)) { + throw new \RuntimeException('Config file seems to be invalid'); + } + + $io->writeln(''); + } catch (\Exception $ex) { + $io->error($ex->getMessage()); + + return self::ERROR_LINT_CONFIG; + } + + try { + $command = $this->getApplication()->find('lint:xliff'); + $cmdInput = new StringInput('lint:xliff translations'); + $cmdInput->setInteractive(false); + if (0 !== $command->run($cmdInput, $output)) { + throw new \RuntimeException('Translation files seem to be invalid'); + } + + $io->writeln(''); + } catch (\Exception $ex) { + $io->error($ex->getMessage()); + + return self::ERROR_LINT_TRANSLATIONS; + } + + $environment = getenv('APP_ENV'); + if ($input->hasArgument('env')) { + $environment = $input->getArgument('env'); + } + + // flush the cache, in case values from the database are cached + $cacheResult = $this->rebuildCaches($environment, $io, $input, $output); + + if ($cacheResult !== 0) { + $io->warning( + [ + 'Cache could not be rebuilt.', + 'Please run the cache commands manually:', + 'bin/console cache:clear --env=' . $environment . PHP_EOL . + 'bin/console cache:warmup --env=' . $environment + ] + ); + } else { + $io->success( + sprintf('Kimai config was reloaded') + ); + } + + return 0; + } + + protected function rebuildCaches(string $environment, SymfonyStyle $io, InputInterface $input, OutputInterface $output) + { + $io->text('Rebuilding your cache, please be patient ...'); + + $command = $this->getApplication()->find('cache:clear'); + try { + if (0 !== $command->run(new ArrayInput(['--env' => $environment]), $output)) { + throw new \RuntimeException('Could not clear cache, missing permissions?'); + } + } catch (\Exception $ex) { + $io->error($ex->getMessage()); + + return self::ERROR_CACHE_CLEAN; + } + + $command = $this->getApplication()->find('cache:warmup'); + try { + if (0 !== $command->run(new ArrayInput(['--env' => $environment]), $output)) { + throw new \RuntimeException('Could not warmup cache, missing permissions?'); + } + } catch (\Exception $ex) { + $io->error($ex->getMessage()); + + return self::ERROR_CACHE_WARMUP; + } + + return 0; + } +} diff --git a/src/Constants.php b/src/Constants.php index fe31acc9..8d22452c 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -21,7 +21,7 @@ class Constants /** * The current release status, either "stable" or "dev" */ - public const STATUS = 'dev'; + public const STATUS = 'stable'; /** * The software name */ diff --git a/tests/Controller/SecurityControllerTest.php b/tests/Controller/SecurityControllerTest.php index 838fbcf9..0429930b 100644 --- a/tests/Controller/SecurityControllerTest.php +++ b/tests/Controller/SecurityControllerTest.php @@ -62,7 +62,7 @@ class SecurityControllerTest extends ControllerBaseTest $this->assertStringContainsString('assertStringContainsString('id="fos_user_registration_form_email" name="fos_user_registration_form[email]" required="required"', $content); $this->assertStringContainsString('assertStringContainsString('id="fos_user_registration_form_username" name="fos_user_registration_form[username]" required="required" maxlength="60" pattern=".{3,}"', $content); + $this->assertStringContainsString('id="fos_user_registration_form_username" name="fos_user_registration_form[username]" required="required" maxlength="60" pattern=".{2,}"', $content); $this->assertStringContainsString('assertStringContainsString('id="fos_user_registration_form_plainPassword_first" name="fos_user_registration_form[plainPassword][first]" required="required"', $content); $this->assertStringContainsString('id="fos_user_registration_form_plainPassword_second" name="fos_user_registration_form[plainPassword][second]" required="required"', $content); diff --git a/tests/Controller/UserControllerTest.php b/tests/Controller/UserControllerTest.php index 534435bf..7ba53411 100644 --- a/tests/Controller/UserControllerTest.php +++ b/tests/Controller/UserControllerTest.php @@ -211,7 +211,7 @@ class UserControllerTest extends ControllerBaseTest [ [ 'user_create' => [ - 'username' => 'xx', + 'username' => 'x', 'plainPassword' => ['first' => 'sdfsdf', 'second' => 'sdfxxx'], 'alias' => 'ycvyxcb', 'title' => '34rtwrtewrt', diff --git a/tests/Entity/UserValidationTest.php b/tests/Entity/UserValidationTest.php index ae2299f6..3fe04145 100644 --- a/tests/Entity/UserValidationTest.php +++ b/tests/Entity/UserValidationTest.php @@ -25,7 +25,7 @@ class UserValidationTest extends KernelTestCase return [ ['', ''], [null, null], - ['xx', 'test@'], // too short username + ['x', 'test@'], // too short username [str_pad('#', 61, '-'), 'test@x.'], // too long username [str_pad('#', 61, '-'), 'test@x.', ['xxxxx']], // too short password and invalid role ];