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.
Comment | File | Size | Author |
---|---|---|---|
#3 | interdiff.txt | 2.05 KB | David_Rothstein |
#3 | cps-exclude-temporary-files-2460959-3.patch | 10.25 KB | David_Rothstein |
#2 | interdiff.txt | 4.5 KB | David_Rothstein |
#2 | cps-exclude-temporary-files-2460959-2.patch | 10.01 KB | David_Rothstein |
#1 | cps-exclude-temporary-files-2460959-1.patch | 8.61 KB | David_Rothstein |
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein at Tag1 Consulting commentedHere is the patch.
Comment #2
David_Rothstein CreditAttribution: David_Rothstein at Tag1 Consulting commentedUpdated 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.
Comment #3
David_Rothstein CreditAttribution: David_Rothstein at Tag1 Consulting commentedSome code comment updates following a review by alexjarvis.
Comment #4
merlinofchaos CreditAttribution: merlinofchaos commentedComment #10
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedTestbot weirdness.