Skip to content
Snippets Groups Projects
Commit bb465e97 authored by Sean Blommaert's avatar Sean Blommaert Committed by Adrian Cid Almaguer
Browse files

Issue #3380623 by seanB, Johan den Hollander, adriancid: Revisions not deleted...

Issue #3380623 by seanB, Johan den Hollander, adriancid: Revisions not deleted when revision_translation_affected is NULL for all languages
parent 97cbfb97
Branches 2.6.x
No related tags found
No related merge requests found
......@@ -78,17 +78,21 @@ class NodeRevisionDelete extends QueueWorkerBase implements ContainerFactoryPlug
$revision = $this->entityTypeManager->getStorage('node')->loadRevision($vid);
// We have to track revisions per language, otherwise unexpected behavior
// and even loss of data might occur.
// and even loss of data might occur. Try to find the revision language
// by checking which translation was affected.
// See https://www.drupal.org/project/node_revision_delete/issues/3118464
foreach ($revision->getTranslationLanguages() as $langcode => $language) {
if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
// Set the active revision ID for the language.
if (($revision->isDefaultRevision() && $revision->isLatestTranslationAffectedRevision()) || ($revision->wasDefaultRevision() && $revision->isLatestTranslationAffectedRevision())) {
$active_vids[$langcode] = $vid;
}
$revisions_per_language[$langcode][] = $vid;
$revision = $revision->getTranslation($langcode);
break;
}
}
// Set the active revision ID for the language.
if (($revision->isDefaultRevision() && $revision->isLatestTranslationAffectedRevision()) || ($revision->wasDefaultRevision() && $revision->isLatestTranslationAffectedRevision())) {
$active_vids[$revision->language()->getId()] = $vid;
}
$revisions_per_language[$revision->language()->getId()][] = $vid;
}
// Load all enabled plugins, and check all revisions per language.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment