Load all changed entities before updating them during publishing

Created on 7 December 2022, over 1 year ago
Updated 4 April 2023, about 1 year ago

Problem/Motivation

During publishing, other modules could want to hook into `hook_cps_changeset_published_before_transaction_end` or `hook_cps_changeset_published` and work on the changed entities, possibly even comparing them to the currently published entities.

Those hooks though happen too late and the `published_revision` of the entities can actually be the revisions which were just published (in real world scenarios this can actually change depending on when `$changeset->getChangedEntities();` is called for the first time, possibly resulting in fun random results).

This feature request is to avoid this uncertainty and always provide the correct "previous" revisions to any hook.

Steps to reproduce

Use `hook_cps_changeset_published_before_transaction_end` to work on the entities `published_revision` and note that they can (or cannot) be the revisions which were just published.

Proposed resolution

Call `$changeset->getChangedEntities();` at the very beginning of the publishing process. This will cache the changed entities once for the entire process, with the "previous" published revisions.

Remaining tasks

Test the patch.

User interface changes

None.

API changes

None.

Data model changes

None.

✨ Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇹Italy marco

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024