This is a follow-up of #2928778: Exception when trying to save a new revision after manually setting the original revision ID.

That breaks our default content. It is possible that it only happens with the ERR patch that we use from #2848878: Embed Paragraph Content in Normalized Parent Entities (REST) because what I think happens is that we denormalize an entity with revision_id and then immediately setting it on the reference and relying on auto-save and it also calls setNewRevision() because the parent is saved as a new revision.

This seems to cause a regression in our install profile with paragraphs default content, which has a fixed revision_id and ERR references to it, which then fails.

What's happening is that the revision ID is set/changed on a new entity which does not yet have a revision_id and then the revision id is the same as the loaded (= empty) and newRevision is set to FALSE. And then this has some impact later, possibly due to other calls to setNewRevision(TRUE) that then again unset the revision_id because it thinks that previously, it did not save as a new revision, despite actually being a new entity.

This seems to fix it for me: https://gist.githubusercontent.com/Berdir/9468aff9027edbcdc7bfb66975f127...

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir created an issue. See original summary.

Berdir’s picture

Oh, this is fun. This is even more complex to reproduce, because my initial understanding was wrong. When setting a revision ID, getRevisionID() does already return that. So what we have to do first explicitly set the revision ID to NULL and then set an ID.

While that may seem weird, it is actually exactly what happens in \Drupal\serialization\Normalizer\FieldableEntityNormalizerTrait::denormalizeFieldData(), first it explicitly sets no value and then it sets the actual value.

The last submitted patch, 2: revision-id-unset-2934517-2-test-only.patch, failed testing. View results

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Very nice find :)

Wim Leers’s picture

Nice find indeed! I'm pretty sure I ran into this with Quick Edit, and perhaps also REST/Serialization/HAL.

  • larowlan committed 895db7d on 8.5.x
    Issue #2934517 by Berdir: Setting a revision ID on a new entity sets the...
larowlan’s picture

Version: 8.4.x-dev » 8.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed as 895db7d and pushed to 8.5.x.

As per https://www.drupal.org/core/release-cycle-overview#current-development-c... 8.4 is in 'critical fixes only', so this can't be backported to 8.4

Berdir’s picture

Version: 8.5.x-dev » 8.4.x-dev
Status: Fixed » Reviewed & tested by the community

Even though the next 8.4.x release is critical only and I set this to major since the only direct impact I know only happens with an uncommitted patch for entity_reference_revisions it is a regression between 8.4.3 and 8.4.4 so can we consider this for 8.4.5?

Finishing and committing #2848878: Embed Paragraph Content in Normalized Parent Entities (REST) is not possible now until this bug is fixed in a stable version of core.

Wim Leers’s picture

@larowlan: doesn't "criticals only for current minor" start when the beta of the next minor is released?

Berdir’s picture

mtodor’s picture

We have encountered a problem with the update of Thunder to Drupal Core 8.4.4. Since we are using our demo content for our tests (demo content is imported with default_content module). And this patch solves a problem. Thanks, @Berdir.

It would be nice if this patch could be applied for 8.4.5 since it is a regression introduced with 8.4.4.

alexpott’s picture

Priority: Major » Critical

As a patch (#2928778: Exception when trying to save a new revision after manually setting the original revision ID) applied to 8.4.x and released in 8.4.4 has caused this regression - I think this should be committed to 8.4.x too. It is a clear regression. I think the original priority of this bug was incorrect since Thunder broke when upgrading from 8.4.3 to 8.4.4 with no work around (other than applying this patch). Note that Thunder does not use the ERR patch. Therefore I'm changing the priority to critical.

plach’s picture

I think this fits the definition of critical, since not creating a new revision could qualify as data loss. Regardless of that I agree this should be backported, since it completes the original "fix". The latter was targeting 8.5.x and I should have warned committers that backporting it to 8.4.x was potentially risky. My bad, sorry.

catch’s picture

Fine with critical (and backport) here too.

  • larowlan committed 84785ee on 8.4.x
    Issue #2934517 by Berdir: Setting a revision ID on a new entity sets the...
larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Discussed with @xjm who (in addition to @catch and @plach above) was happy with the backport here.

Cherry-picked as 84785ee and pushed to 8.4.x.

Status: Fixed » Closed (fixed)

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