statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.11k stars 538 forks source link

[5.x] Fix wrong blueprint parent after revision publish #11116

Closed jacksleight closed 1 week ago

jacksleight commented 1 week ago

This PR fixes an issue where after publishing a revision the parent set on the blueprint and field objects will still refer to the previous version of the entry.

This can cause issues during the preProcess calls fired by PublishedEntriesController::extractFromFields if you're using the parent. The issue we had is that we do something in preProcess that depends on the value of another field. We fetch the value of that field from the parent data, but if the parent is the previous version the value might be wrong.

The reason updating the parent isn't done just after clone (which would be the obvious place) is that the save calls further up in publishWorkingCopy/unpublishWorkingCopy can also result in the associated blueprint/parent objects getting out of sync, so the same issue persists, although I think that's unique to the eloquent driver.