Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: “Remove Translation” removes entry’s grid fields for all languages

Status Resolved
Add-on / Version Publisher 3.9.1
Severity
EE Version 6.4.2

Eric Swierczek

Jun 07, 2023

Create an entry in 2+ languages with a grid field with some data. Go to one of the entries and click “Remove Translation”. Load any other language, and the grid data will have been deleted too.

Relevant function trace:
* ext.publisher.php->before_channel_entry_save()
* $this->entryEvent->emit(‘publisherDeleteTranslation’, $entryId, $languageId);
* EntrySubscriber.php->onPublisherDeleteTranslation()
* $entry->delete($entryId, $languageId);
* Entry.php->delete()
* $this->entryEvent->emit(‘publisherDeleteEntry’, $eventArgs);
* EntrySubscriber.php->onPublisherDeleteEntry()
* $fieldHandler->call(‘deleteEntry’, $args);
* which finally calls `GridType.php->deleteEntry()`, which deletes all grid rows for this entry

A potential hacky fix for this might be to adjust `FieldHandler.php->call()` to check:

if (isset($parameters['languageId'])) {
    $parameters['skipEntryDelete'] = true;
}

at the beginning, and then in `GridType.php->deleteEntry()` we can check:

if (isset($params['skipEntryDelete'])) {
    return;
}

GridType.php->delete would also need to be adjusted to accept the parameters that are passed:

public function deleteEntry(array $params = [])

so it skips the entire grid entry deletion event in that case. That at least seemed to work in my test case, but you’d have a better sense of side-effects of this sort of change.

Attached image shows rows in the publisher and grid tables before/after for languages 1 and 4 and removing the translation for lang 4.

 

#1

BoldMinded (Brian)

I think I fixed this in 3.10.1 - from the change log: [Fixed] Refreshing the translation of an entry that contains a Grid field using DeepL or Google would cause all of the Grid data to be erased, even for the default language :(

While this isn’t directly related to DeepL I think it’s the same logic.

#2

BoldMinded (Brian)

Comment has been marked private.

#3

BoldMinded (Brian)

Refreshing the translation calls the same deleteTranslation code.

Login to reply