femanager
femanager copied to clipboard
Exception when image manipulation
Hello there
I got a TYPO3 exception when trying to change an image.
Situation:
- We have user data but no image. User wants to upload a picture.
- User chooses a picture and tries to submit (action: update)
- Validation error occurs because user forgot to set password. Password is mandatory.
- User tries again, the uploaded picture is visible, so user doesn't change the picture (no touch), user set password and tries to submit
- 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
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.
I can confirm this, plus:
- for me image uploading only worked when plugin.tx_femanager.settings.misc.uploadAmount = 1 is set and I have made the code changes above. Without both it also did not work (without code changes I got message file filepath/xyz.jpg/ does not exists).
- it works now, but it always uploads the files to „files/user_upload/file.jpg“. But I have set constant plugin.tx_femanager.settings.uploadFolder = files/anotherfolder/Staff (files is my default storage, not fileadmin)
Any news here?