#90214TCA maxitems is ignored
Description
Hi,
When setting TCA maxitems to 1 for INLINE relations, and update the record from FE form, maxitems is ignored, many relations are created in sys_file_reference where there should be only one.
New relation is inserted but old relation is not deleted.
Sample TCA :
'cv' => [
'exclude' => false,
'label' => 'cv',
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig(
'cv',
[
'minitems' => 0,
'maxitems' => 1,
'foreign_match_fields' => [
'fieldname' => 'cv',
'tablenames' => 'fe_users',
'table_local' => 'sys_file',
]
],
'pdf'
),
]
And update with :
$this->userRepository->update($user);
The bug appeared in Typo3 9.5.13 but wasn’t present in previous V9 versions (don’t know exactly which one).
Florian
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
Files 1
History 9
-
Florian Rival changed category 01/27/20, 13:04
-
Alexander Schnitzler changed assigned to Alexander Schnitzler 04/16/20, 19:20
-
Alexander Schnitzler commented and changed status
NewNeeds Feedback 04/16/20, 20:05 -
Florian Rival commented 04/17/20, 09:42
Hi Alexander,
The use case is :
- I have a record with a file attached (a user with a CV for example, look sample TCA in bug description)
- In FE, I want to edit informations for this record with actions : editAction() and updateAction()
function editAction() { $uid = GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('frontend.user', 'id', 0); $user = $this->userRepository->findByIdentifier($uid); $this->view->assign('user', $user); }Then in Edit.html the form look like this :
<f:form action="update" name="user" object="{user}" > <f:form.upload property="cv" additionalAttributes="{accept :'application/pdf'}" /> </f:form>And in update action :
public function initializeUpdateAction(): void { $fileUploadConfiguration = [ UploadedFileReferenceConverter::CONFIGURATION_FILE_VALIDATORS => ['application/pdf'], UploadedFileReferenceConverter::CONFIGURATION_UPLOAD_FOLDER => $this->settings['folders']['cvFolder'], ]; /** @var PropertyMappingConfiguration $newUserConfiguration */ $newUserConfiguration = $this->arguments['user']->getPropertyMappingConfiguration(); $newUserConfiguration->forProperty('cv')->setTypeConverterOptions(UploadedFileReferenceConverter::class, $fileUploadConfiguration); } public function updateAction(User $user): void { $this->userRepository->update($user); }- so, in FE form, I upload a new file (CV) and this new file should replace the old one
- but the result is not as expected :
– new file is attached to record : so far so good
– old file is not removed for this record - the you have two files attached to that record instead of one – have a look at picture in description
Hope it help,
Florian -
Alexander Schnitzler commented 04/17/20, 09:55
Hi Florian,
with that code attached I understand your use case much better.
I am still not quite sure where we would find the error exactly. I would need to debug the data mapper and the property mapper to see what exactly happens here and why the current object storage does not completely override the old one. That does not even have anything to do with maxitems here. It seems that property relations are merged. I currently don’t know what the desired behaviour would be (for all), what actually makes sense and why things are like they are.
-
Christian Kuhn changed status
Needs FeedbackNew 02/19/22, 15:15 -
Thomas Löffler commented 03/08/23, 15:08
It seems that the upload_example of Helmut (https://github.com/helhum/upload_example/) is used here.
As the example is only coded to add files and not to replace files there is a need of adapting the example’s code.Imho it’s not a bug in the Core. It’s a missing feature in the example.
-
Georg Ringer commented and changed status
NewRejected 06/11/24, 23:01extbase doesn’t care about this restriction, same like minitems. and you need to take care about that yourself. therefore I am closing this issue
regarding the upload_example: with 13 it is planned to have a solution within the core, see ##103511
-
Georg Ringer changed status
RejectedClosed 06/11/24, 23:01
I am not sure about this ticket. Can you explain what exactly worked and stopped working suddenly?
With a more detailed description I could search for code that changed.
Besides that: maxitems is not evaluted by Extbase to validate the amount of records being stored.
maxitems is used to determine the exact type of relation between tables, but nothing more.