in2code-de / femanager

Modern TYPO3 Frontend User RegistrationTYPO3 Frontend User Registration and Management based on Extbase and Fluid and on TYPO3 8 and the possibility to extend it to your needs. Extension basicly works like sr_feuser_register
https://www.in2code.de/agentur/typo3-extensions/femanager/
48 stars 118 forks source link

Exception when image manipulation #98

Open Footrotflat opened 6 years ago

Footrotflat commented 6 years ago

Hello there

I got a TYPO3 exception when trying to change an image.

Situation:

  1. We have user data but no image. User wants to upload a picture.
  2. User chooses a picture and tries to submit (action: update)
  3. Validation error occurs because user forgot to set password. Password is mandatory.
  4. User tries again, the uploaded picture is visible, so user doesn't change the picture (no touch), user set password and tries to submit
  5. Now exception occurs

If user dosn't forget to set the password from the beginning (no validation error), no exception occurs, everything fine.

TYPO3 8.7.17 femanager 4.2.2

May be you are interessted to knwo.

Cheers Patrick

Core: Exception handler (WEB): Uncaught TYPO3 Exception: Argument 1 passed to In2code\Femanager\DataProcessor\ImageManipulation::getNewImageName() must be of the type array, string given, called in /home/xyz/www/xyz.ch/typo38/typo3conf/ext/femanager/Classes/DataProcessor/ImageManipulation.php on line 37 | TypeError thrown in file /home/xyz/www/xyz.ch/typo38/typo3conf/ext/femanager/Classes/DataProcessor/ImageManipulation.php in line 107. Requested URL: https://xyz.ch/typo38/xyz/xyz/?tx_femanager_pi1%5Baction%5D=update&tx_femanager_pi1%5Bcontroller%5D=Edit&cHash=xyz

mediaessenz commented 5 years ago

Could it be, that you have set the uploadAmount to 1, like me:

plugin.tx_femanager.settings.misc.uploadAmount = 1

In this case, the $arguments['user'][$property] of the foreach loop seems to be a single dimension array with upload properties like "name" and "tmp_name". In other cases it's a multidimension array, where each value contains an array with the mentioned properties. A possible solution to fix this is to change line 32/33 of EXT:femanager/Classes/DataProcessor/ImageManipulation.php:

// file upload given
                foreach ((array)$arguments['user'][$property] as $fileItem) {

to:

// file upload given
                $fileItems = (array)$arguments['user'][$property];
                if ((int)ConfigurationUtility::getConfiguration('misc.uploadAmount') === 1) { 
                    $fileItems = [$fileItems];
                }
                foreach ($fileItems as $fileItem) {

In general, I think, the current configuration possibilities for image/file uploads are not the best. It is e.g. not possible to define different upload amounts for different upload fields. Additionally the file reference uids will be written to the user image (or whatever) field and not the number of relations, which would be correct.

klodeckl commented 5 years ago

I can confirm this, plus:

klodeckl commented 3 years ago

Any news here?