diff --git a/.env b/.env index 32ed0b4e..c17108e2 100644 --- a/.env +++ b/.env @@ -64,7 +64,7 @@ IR_DRIVER=gd MESSENGER_TRANSPORT_DSN=redis://redis:6379/messages ###< symfony/messenger ### -TRUSTED_PROXIES=127.0.0.1,172.19.0.1,172.19.0.2,REMOTE_ADDR +TRUSTED_PROXIES=REMOTE_ADDR ###> sentry/sentry-symfony ### SENTRY_DSN= diff --git a/CHANGELOG.md b/CHANGELOG.md index d63d5e74..9379b318 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to Roadiz will be documented in this file. +## [2.3.10](https://github.com/roadiz/core-bundle-dev-app/compare/v2.3.9...v2.3.10) - 2024-06-14 + +### Bug Fixes + +- Pass FormInterface to `bulkAction` to update bulk item with a form field data. - ([8d46507](https://github.com/roadiz/core-bundle-dev-app/commit/8d4650767dcaa183c135c4043ffd1cfea4dc64d6)) + ## [2.3.9](https://github.com/roadiz/core-bundle-dev-app/compare/v2.3.8...v2.3.9) - 2024-06-13 ### Features diff --git a/docker/php82-fpm-alpine/docker-php-entrypoint b/docker/php82-fpm-alpine/docker-php-entrypoint index 433251b9..d05496f4 100755 --- a/docker/php82-fpm-alpine/docker-php-entrypoint +++ b/docker/php82-fpm-alpine/docker-php-entrypoint @@ -12,10 +12,10 @@ set -e /bin/chown -R www-data:www-data /var/www/html/config || true; # Print local env vars to .env.xxx.php file for performances and crontab jobs -/usr/bin/sudo -u www-data -- bash -c "/var/www/html/bin/console cache:clear -n" -/usr/bin/sudo -u www-data -- bash -c "/var/www/html/bin/console cache:pool:clear cache.global_clearer -n" -/usr/bin/sudo -u www-data -- bash -c "/var/www/html/bin/console assets:install -n" -/usr/bin/sudo -u www-data -- bash -c "/var/www/html/bin/console themes:assets:install -n Rozier --relative --symlink" +/usr/bin/sudo -E -u www-data -- bash -c "/var/www/html/bin/console cache:clear -n" +/usr/bin/sudo -E -u www-data -- bash -c "/var/www/html/bin/console cache:pool:clear cache.global_clearer -n" +/usr/bin/sudo -E -u www-data -- bash -c "/var/www/html/bin/console assets:install -n" +/usr/bin/sudo -E -u www-data -- bash -c "/var/www/html/bin/console themes:assets:install -n Rozier --relative --symlink" # # Wait for database to be ready for next commands and migrations diff --git a/lib/RoadizCoreBundle/config/services.yaml b/lib/RoadizCoreBundle/config/services.yaml index 2a784a1b..eb48f24e 100644 --- a/lib/RoadizCoreBundle/config/services.yaml +++ b/lib/RoadizCoreBundle/config/services.yaml @@ -1,6 +1,6 @@ --- parameters: - roadiz_core.cms_version: '2.3.9' + roadiz_core.cms_version: '2.3.10' roadiz_core.cms_version_prefix: 'main' env(APP_NAMESPACE): "roadiz" env(APP_VERSION): "0.1.0" diff --git a/lib/Rozier/src/Controllers/AbstractAdminWithBulkController.php b/lib/Rozier/src/Controllers/AbstractAdminWithBulkController.php index b47db87f..1efa45a5 100644 --- a/lib/Rozier/src/Controllers/AbstractAdminWithBulkController.php +++ b/lib/Rozier/src/Controllers/AbstractAdminWithBulkController.php @@ -81,13 +81,36 @@ protected function parseFormBulkIds(?FormInterface $form): array if (null === $form) { return []; } - $ids = \json_decode($form->getData() ?? '[]'); + if (!$form->isSubmitted() || !$form->isValid()) { + return []; + } + $json = $form->getData(); + if (is_string($json)) { + $json = stripslashes(trim($json, '"')); + } else { + return []; + } + $ids = \json_decode($json, true); + return \array_filter($ids, function ($id) { // Allow int or UUID identifiers return is_numeric($id) || is_string($id); }); } + /** + * @param Request $request + * @param string $requiredRole + * @param FormInterface $bulkForm + * @param FormInterface $form + * @param callable(string): FormInterface $createBulkFormWithIds + * @param string $templatePath + * @param string $confirmMessageTemplate + * @param callable(PersistableInterface, FormInterface): void $alterItemCallable + * @param string $bulkFormName + * @return Response + * @throws \Twig\Error\RuntimeError + */ protected function bulkAction( Request $request, string $requiredRole, @@ -111,7 +134,7 @@ protected function bulkAction( $items = $this->getRepository()->findBy([ 'id' => $ids, ]); - $formWithIds = $createBulkFormWithIds(json_encode($ids)); + $formWithIds = $createBulkFormWithIds(\json_encode($ids, JSON_THROW_ON_ERROR)); if (!$formWithIds instanceof FormInterface) { throw new \RuntimeException('Invalid form returned.'); } @@ -132,7 +155,7 @@ protected function bulkAction( ]); foreach ($items as $item) { if ($this->supports($item)) { - $alterItemCallable($item); + $alterItemCallable($item, $form); $updateEvent = $this->createUpdateEvent($item); if (null !== $updateEvent) { $this->dispatchSingleOrMultipleEvent($updateEvent); diff --git a/lib/Rozier/src/Controllers/Users/UsersController.php b/lib/Rozier/src/Controllers/Users/UsersController.php index 589af201..a2ded208 100644 --- a/lib/Rozier/src/Controllers/Users/UsersController.php +++ b/lib/Rozier/src/Controllers/Users/UsersController.php @@ -278,7 +278,10 @@ function (string $ids) { }, $this->getTemplateFolder() . '/bulk_enable.html.twig', '%namespace%.%item%.was_enabled', - function (User $item) { + function (PersistableInterface $item) { + if (!$item instanceof User) { + throw new \RuntimeException('Invalid item type.'); + } $item->setEnabled(true); }, 'bulkEnableForm' @@ -299,7 +302,10 @@ function (string $ids) { }, $this->getTemplateFolder() . '/bulk_disable.html.twig', '%namespace%.%item%.was_disabled', - function (User $item) { + function (PersistableInterface $item) { + if (!$item instanceof User) { + throw new \RuntimeException('Invalid item type.'); + } $item->setEnabled(false); }, 'bulkDisableForm' diff --git a/lib/Rozier/src/Resources/translations/messages.en.xlf b/lib/Rozier/src/Resources/translations/messages.en.xlf index 256bf4e9..c4378271 100644 --- a/lib/Rozier/src/Resources/translations/messages.en.xlf +++ b/lib/Rozier/src/Resources/translations/messages.en.xlf @@ -2530,7 +2530,7 @@ are_you_sure.delete.customFormAnswer - Are you sure you want to delete delete this answer + Are you sure you want to delete this custom-form answer? delete.customFormAnswer.%name% @@ -4876,6 +4876,10 @@ sort_attributes_by_weight_for_this_type If node-type is attributable, this option enforce attribute sorting by weight instead of manual position. + + ip_address + IP address + diff --git a/lib/Rozier/src/Resources/translations/messages.fr.xlf b/lib/Rozier/src/Resources/translations/messages.fr.xlf index baf07260..1142ebc5 100644 --- a/lib/Rozier/src/Resources/translations/messages.fr.xlf +++ b/lib/Rozier/src/Resources/translations/messages.fr.xlf @@ -2530,7 +2530,7 @@ are_you_sure.delete.customFormAnswer - Êtes-vous sûr(e) de vouloir supprimer ce formulaire personnalisé ? + Êtes-vous sûr(e) de vouloir supprimer cette réponse de formulaire personnalisé ? delete.customFormAnswer.%name% @@ -4876,6 +4876,10 @@ sort_attributes_by_weight_for_this_type Si le type de nœud accepte les attributs, cette option force le tri des attributs par poids plutôt que par position manuelle. + + ip_address + Adresse IP + diff --git a/lib/Rozier/src/Resources/translations/messages.xlf b/lib/Rozier/src/Resources/translations/messages.xlf index 60686bd0..e2b993d9 100644 --- a/lib/Rozier/src/Resources/translations/messages.xlf +++ b/lib/Rozier/src/Resources/translations/messages.xlf @@ -1373,6 +1373,7 @@ sortingAttributesByWeight sort_attributes_by_weight_for_this_type + ip_address diff --git a/lib/Rozier/src/Resources/views/panels/user_panel.html.twig b/lib/Rozier/src/Resources/views/panels/user_panel.html.twig index 051a886a..e787e198 100644 --- a/lib/Rozier/src/Resources/views/panels/user_panel.html.twig +++ b/lib/Rozier/src/Resources/views/panels/user_panel.html.twig @@ -58,7 +58,7 @@ {% if (is_granted('ROLE_ACCESS_DOCTRINE_CACHE_DELETE')) %} {% trans %}delete.caches{% endtrans %} {% endif %} {% if (is_granted('ROLE_ACCESS_DOCTRINE_CACHE_DELETE')) %} diff --git a/lib/Rozier/src/Resources/views/users/edit.html.twig b/lib/Rozier/src/Resources/views/users/edit.html.twig index 1c86e4ec..9aacebf2 100644 --- a/lib/Rozier/src/Resources/views/users/edit.html.twig +++ b/lib/Rozier/src/Resources/views/users/edit.html.twig @@ -42,6 +42,12 @@ {% trans %}updated.at{% endtrans %} {{ item.updatedAt|format_datetime('long', locale=app.request.locale) }} + {% if item.id == app.user.id %} + + {% trans %}ip_address{% endtrans %} + {{ app.request.clientIp }} + + {% endif %}