Issue #3295076: Migrate rollback for translations doesn't work
Open
requested to merge issue/entity_reference_revisions-3295076:3295076-migrate-rollback-for into 8.x-1.x
2 unresolved threads
Merge request reports
Activity
187 188 } 188 189 } 189 190 } 190 191 } - Comment on lines 173 to 190
173 protected function rollbackTranslation(array $destination_identifiers) { 174 $revision_id = $destination_identifiers['revision_id']; 175 $entity = $this->storage->loadRevision($revision_id); 176 if ($entity && $entity instanceof TranslatableInterface) { 177 if ($key = $this->getKey('langcode')) { 178 if (isset($destination_identifiers[$key])) { 179 $langcode = $destination_identifiers[$key]; 180 if ($entity->hasTranslation($langcode)) { 181 // Make sure we don't remove the default translation. 182 $translation = $entity->getTranslation($langcode); 183 if (!$translation->isDefaultTranslation()) { 184 $entity->removeTranslation($langcode); 185 $entity->save(); 186 } 187 } 188 } 189 } 190 } 191 } 173 protected function rollbackTranslation(array $destination_identifiers) { 174 if ($revision_id = $this->getKey('revision')) { 175 $entity = $this->storage->loadRevision($revision_id); 176 if ($entity && $entity instanceof TranslatableInterface) { 177 if ($key = $this->getKey('langcode')) { 178 if (isset($destination_identifiers[$key])) { 179 $langcode = $destination_identifiers[$key]; 180 if ($entity->hasTranslation($langcode)) { 181 // Make sure we don't remove the default translation. 182 $translation = $entity->getTranslation($langcode); 183 if (!$translation->isDefaultTranslation()) { 184 $entity->removeTranslation($langcode); 185 $entity->save(); 186 } 187 } 188 } 189 } 190 } 191 } 192 }
208 209 } 209 210 } 210 211 211 212 } - Comment on lines 198 to 211
199 protected function rollbackNonTranslation(array $destination_identifiers) { 200 $revision_id = $destination_identifiers['revision_id']; 201 $entity = $this->storage->loadRevision($revision_id); 202 if ($entity) { 203 if ($entity->isDefaultRevision()) { 204 $entity->delete(); 205 } 206 else { 207 $this->storage->deleteRevision($revision_id); 208 } 209 } 210 } 211 212 } 199 protected function rollbackNonTranslation(array $destination_identifiers) { 200 if ($revision_id = $this->getKey('revision')) { 201 $entity = $this->storage->loadRevision($revision_id); 202 if ($entity) { 203 if ($entity->isDefaultRevision()) { 204 $entity->delete(); 205 } 206 else { 207 $this->storage->deleteRevision($revision_id); 208 } 209 } 210 } 211 } 212 }
Please register or sign in to reply