Skip to content

Commit 28e6674

Browse files
committed
Fix translations removal, ensure headers translations are removed as well
1 parent 9afec68 commit 28e6674

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

inc/container.class.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,12 @@ function pre_deleteItem() {
356356
}
357357

358358
//delete label translations
359-
$translation = new PluginFieldsLabelTranslation();
360-
$translation->delete(
361-
[
362-
'itemtype' => self::getType(),
363-
'items_id' => $this->getID()
364-
]
365-
);
359+
$translation_obj = new PluginFieldsLabelTranslation();
360+
$translations = $translation_obj->find("plugin_fields_itemtype = '" . self::getType() .
361+
"' AND plugin_fields_items_id = ". $this->fields['id']);
362+
foreach ($translations as $translation_id => $translation) {
363+
$translation_obj->delete(['id' => $translation_id]);
364+
}
366365

367366
//delete table
368367
if (class_exists($classname)) {

inc/field.class.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,6 @@ function pre_deleteItem() {
136136
PluginFieldsDropdown::getClassname($this->fields['name']));
137137
}
138138

139-
$translation = new PluginFieldsLabelTranslation();
140-
$translation->delete(
141-
[
142-
'itemtype' => self::getType(),
143-
'items_id' => $this->getID()
144-
]
145-
);
146-
147139
$container_obj = new PluginFieldsContainer;
148140
$container_obj->getFromDB($this->fields['plugin_fields_containers_id']);
149141
foreach (json_decode($container_obj->fields['itemtypes']) as $itemtype) {
@@ -154,6 +146,14 @@ function pre_deleteItem() {
154146
$classname::removeField($this->fields['name']);
155147
}
156148

149+
//delete label translations
150+
$translation_obj = new PluginFieldsLabelTranslation();
151+
$translations = $translation_obj->find("plugin_fields_itemtype = '" . self::getType() .
152+
"' AND plugin_fields_items_id = ". $this->fields['id']);
153+
foreach ($translations as $translation_id => $translation) {
154+
$translation_obj->delete(['id' => $translation_id]);
155+
}
156+
157157
if (isset($oldname)) {
158158
$this->fields['name'] = $oldname;
159159
}

0 commit comments

Comments
 (0)