Unverified Commit 80814fb9 authored by Dave Reid's avatar Dave Reid Committed by Dave Reid
Browse files

Follow-up #2387341 by Dave Reid: Fixed duplicated code left in xmlsitemap_entity_update().

parent 736d0e02
......@@ -1690,30 +1690,6 @@ function xmlsitemap_entity_insert(EntityInterface $entity) {
function xmlsitemap_entity_update(EntityInterface $entity) {
if (xmlsitemap_link_bundle_check_enabled($entity->getEntityTypeId(), $entity->bundle())) {
xmlsitemap_xmlsitemap_process_entity_link($entity);
// Check if we have differences between the translations from the link
// storage and the current translations of the entity, and if so, remove
// them.
if ($entity instanceof ContentEntityInterface) {
$translation_languages = $entity->getTranslationLanguages();
$link_storage = \Drupal::service('xmlsitemap.link_storage');
$link_storage_languages = [];
$links = $link_storage->loadMultiple([
'type' => $entity->getEntityTypeId(),
'id' => $entity->id(),
]);
foreach ($links as $link) {
$link_storage_languages[] = $link['language'];
}
if ($language_differences = array_diff($link_storage_languages, array_keys($translation_languages))) {
$link_storage->deleteMultiple([
'type' => $entity->getEntityTypeId(),
'id' => $entity->id(),
'language' => $language_differences,
]);
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment