Problem/Motivation

In #3388540: Orphan Purger not triggered when deleting revisions, we identified a behavior change in 11.3, where hasTranslationChanges() suddenly returns TRUE when it previously returned FALSE, causing extra revisions to be created.

Additionally, using loadRevision() might now hit the static cache depend on what and how it's loaded and must use loadRevisionUnchanged().

Steps to reproduce

create an entity, save, save a new revision with a different title. load the old revisions, call hasTranslationChanges(). Without making any changes, this will return TRUE as it compares against the default revision.

Because it doesn't use loadRevisionUnchanged(), the same should happen when saving non-default revision and loading that.

Proposed resolution

I think it should always load the revision if it's an entity type that supports revisions.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3562759

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

berdir created an issue. See original summary.

berdir’s picture

Status: Active » Needs review
amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Discussed this a bit in Slack, and the conclusion looks good to me. Nice find :)

catch’s picture

Version: 11.x-dev » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

I've stared at this a couple of times without committing it, thinking it would be nice to have an inline comment explaining why we need the unchanged revision to be loaded. But all I end up with is 'We must load the unchanged revision so it can be compared correctly' or similar which does not add anything. So... going ahead here without that, the test coverage should stop anyone changing it back mistakenly.

Committed/pushed to main, 11.x and 11.3.x, thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • catch committed 658cf84b on 11.3.x
    fix: #3562759 ContentEntityBase::hasTranslationChanges() must use...

  • catch committed 1c7d89d0 on 11.x
    fix: #3562759 ContentEntityBase::hasTranslationChanges() must use...

  • catch committed ff724645 on main
    fix: #3562759 ContentEntityBase::hasTranslationChanges() must use...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.