#103708MetaDataRepository->update() can't erase column content
Description
Right now it is not possible in v12.4 or v13.x to call the method to erase the content of a field.
This worked fine in v10 and 11.
Given: A record exists with a copyright value. A new update is executed with an empty value for copyright.
I would expect the copyright to be empty. Instead, it still has the old value.
That’s our code:
$this->metaDataRepository->update($file->getUid(), [
'title' => $this->getShortenedString($mediaObject['value'], 100),
'description' => $mediaObject['description'] ?? '',
'alternative' => $mediaObject['description'] ?? '',
'creator_tool' => 'destination.one',
'source' => $mediaObject['url'] ?? '',
'copyright' => $mediaObject['source'] ?? '',
]);
The $updateRow = array_diff($updateRow, $metaDataFromDatabase); removed the empty value.
Reviews 2
History 310
-
Daniel Siepmann commented 04/23/24, 09:36
-
Gerrit Code Review pushed patch set 1 for main to change 84000 status
NewUnder Review 04/23/24, 09:44 -
Gerrit Code Review pushed patch set 2 for main to change 84000 04/23/24, 13:13
-
Gerrit Code Review pushed patch set 3 for main to change 84000 04/23/24, 14:06
-
Gerrit Code Review pushed patch set 4 for main to change 84000 04/23/24, 16:52
-
Gerrit Code Review pushed patch set 5 for main to change 84000 04/23/24, 17:54
-
Gerrit Code Review pushed patch set 6 for main to change 84000 04/23/24, 18:02
-
Gerrit Code Review pushed patch set 1 for 12.4 to change 84012 04/23/24, 18:41
-
Daniel Siepmann commented and changed status
Under ReviewResolved done0 %100 % 04/23/24, 19:05Applied in changeset commit:005f04a3b4c4e0450cc17e4b23aaeb92c5aac5ad.
-
Daniel Siepmann changed status
ResolvedClosed 04/24/24, 06:07
From my understanding TYPO3 should not use `array_diff` as this doesn’t work as the code should work. It will only compare values, not combination of keys and values.
That should also result in further issues. E.g. given an existing record with a title of some value, it should be impossible to update the description to the same value, as this should be stripped out.
So what happens in our case is that there is some other existing empty value, that’s why the diff removes empty copyright.