With the CPS File Entities module enabled, temporary files get included in changesets. This means that if you upload a file to a node but then change your mind and don't save the node, or if you have some other process that generates temporary managed files on the site (for example, short-lived download links), those files get included as part of the current changeset. This is very confusing to site administrators and also may lead to some bugs.

Since temporary files are not intended for actual use on the site and are deleted on cron runs after 6 hours, they shouldn't be included in CPS.

The approach in this patch will solve that by allowing modules to indicate via a hook that particular entities should not be tracked by CPS (a useful feature, I think) and then implementing that hook in the CPS File Entities module to delay CPS tracking until/unless the temporary file gets re-saved with a permanent status.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

Status: Active » Needs review
FileSize
8.61 KB

Here is the patch.

David_Rothstein’s picture

Updated the patch to fix a couple things. Before, when the file got transferred from temporary to permanent, the version being manipulated in the changeset was made permanent, but the live version of the file was still temporary (meaning there's a risk Drupal would delete it out from under the changeset, if the changeset remained in a draft state for more than 6 hours). Furthermore, the live version of the file was marked as published, even though the live version of entities not yet included in a published CPS changeset are normally supposed to be unpublished.

This version of the patch fixes all that; the live version of the file now matches the version that is initially added to the CPS changeset in all ways except for the published status.

There's a bit of a conflict here between fixing the above bug and making the hook generally useful - I didn't see any quick way to resolve that so I documented the problem instead.

Note that this patch also requires #2430181: drafy_enforce implements drafty_field_attach_submit() to be applied to the Drafty module in order to work correctly.

David_Rothstein’s picture

Some code comment updates following a review by alexjarvis.

merlinofchaos’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

The last submitted patch, 1: cps-exclude-temporary-files-2460959-1.patch, failed testing.

The last submitted patch, 2: cps-exclude-temporary-files-2460959-2.patch, failed testing.

Status: Closed (fixed) » Needs work

The last submitted patch, 3: cps-exclude-temporary-files-2460959-3.patch, failed testing.

David_Rothstein’s picture

Status: Needs work » Closed (fixed)

Testbot weirdness.