From 0a0ffb172dd4f46bc52b52e574653e5b119fd8ae Mon Sep 17 00:00:00 2001 From: Stefan Busemann Date: Tue, 5 Nov 2024 21:40:05 +0100 Subject: [PATCH] [BUGFIX] changing image only resolves #535 --- Classes/Controller/EditController.php | 2 +- Classes/Utility/ObjectUtility.php | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Classes/Controller/EditController.php b/Classes/Controller/EditController.php index 9b9cf4e59d..fc82137b7b 100644 --- a/Classes/Controller/EditController.php +++ b/Classes/Controller/EditController.php @@ -220,7 +220,7 @@ public function deleteAction(User $user) */ protected function redirectIfNoChangesOnObject(User $user) { - if (!ObjectUtility::isDirtyObject($user)) { + if (!ObjectUtility::isDirtyObject($user, $this->request)) { $this->addFlashMessage(LocalizationUtility::translate('noChanges'), '', ContextualFeedbackSeverity::NOTICE); return $this->redirect('edit'); } diff --git a/Classes/Utility/ObjectUtility.php b/Classes/Utility/ObjectUtility.php index d583556e23..bed5e9ddce 100644 --- a/Classes/Utility/ObjectUtility.php +++ b/Classes/Utility/ObjectUtility.php @@ -7,6 +7,7 @@ use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Mvc\RequestInterface; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; use TYPO3\CMS\Extbase\Reflection\Exception\PropertyNotAccessibleException; use TYPO3\CMS\Extbase\Reflection\ObjectAccess; @@ -34,9 +35,10 @@ public static function getContentObject(): ContentObjectRenderer * Checks if object was changed or not * * @param object $object + * @param RequestInterface $request * @codeCoverageIgnore */ - public static function isDirtyObject($object): bool + public static function isDirtyObject($object, RequestInterface $request): bool { foreach (array_keys($object->_getProperties()) as $propertyName) { try { @@ -63,6 +65,15 @@ public static function isDirtyObject($object): bool return true; } } + + /** check if there is an uploaded image */ + $uploadedFiles = $request->getUploadedFiles(); + if ( + count($uploadedFiles) > 0 + && !empty($uploadedFiles['image']) + ) { + return true; + } } return false; }