Skip to content

Commit

Permalink
[BUGFIX] changing image only
Browse files Browse the repository at this point in the history
resolves #535
  • Loading branch information
sbusemann committed Nov 5, 2024
1 parent 1cb23b8 commit 0a0ffb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Classes/Controller/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
13 changes: 12 additions & 1 deletion Classes/Utility/ObjectUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}
Expand Down

0 comments on commit 0a0ffb1

Please sign in to comment.