Closed (fixed)
Project:
Drupal core
Version:
8.4.x-dev
Component:
file.module
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Jul 2017 at 13:59 UTC
Updated:
29 Aug 2017 at 06:00 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
berdirComment #3
dawehnerNice find!
Comment #4
xjmUsers not being able to save nodes sounds critical to me, even if it only happens with certain modules or on certain sites, so promoting this to critical.
Comment #5
berdir@xjm: You don't even need special modules for this, according to #2787187: Data loss: Deleting a translation of an entity deletes all file_usage entries for files referenced by the entity , it should be enough to create a node, add a translation, remove that translation again and then trying to edit the original node again. (Assuming no revisions are used)
Comment #6
berdirWas looking for test coverage for this, but didn't find anything. The test form has support for existing files, so it was fairly easy to add.
Comment #7
dawehnerI'll work on the test coverage
Consider the difference between
a) An image disappears on the frontpage, without any user interaction before
b) Someone cannot save a node with a node, which had an file deleted.
Unlike a), b) at least doesn't leave a utterly broken site. B) is also an active process, and as such MUCH easier to figure out. B) also already existed before the other issue.
Given that I still don't understand why this patch was reverted.
Comment #8
dawehnerDamnit crosspost.
Comment #9
dawehnerBerdir's test coverage is much better!
We need some form of documentation here ...
Comment #14
martin107 commentedReferring to #6
I have the smallest of changes .. which can wait until the next iteration.
Some of the new test code is using t('Save') - I think we should simplify those to 'Save'
There is no need to invoke translation in tests unless directly testing translation.
Comment #15
mpdonadioShould be back to green w/ feedback addressed.
Comment #17
berdir"need to check the status" is IMHO unclear, we're not really checking the status of anything, we're checking a configuration setting. Also, permanent files are never gargabe collected, only temporary files, the point is that we no longer mark them as temporary.
We also have a comment at the top of the method that explains this part, but it's further up and seems to apply to the whole thing when it actually doesn't, it is the explanation what this block is doing, not the part about a file existing.
My suggestion would to move the existing comment to this position and and update/extend it:
When files that are no longer in use are automatically marked as temporary (now disabled by default), it is not safe to reference a permanent file without usage. Adding a usage and then later on removing it again would delete the file, but it is unknown if and where it is currently referenced. However, when files are not marked temporary (and then removed) automatically, it is save to add and remove usages, as it would simply return to the current state.
Comment #18
xjmWe need to mention this issue in the release notes alongside #2801777: Give users the option to prevent drupal from automatically marking unused files as temporary until a fix is committed here.
Comment #20
mpdonadioWill try to post an update tonight.
Comment #21
mpdonadioI read this several times, and think @Berdir's explanation makes sense after the moved comment; just fixed a type in his text. Also added a @see to the CR (which is still unpublished).
Comment #22
berdirI think you lost a part of my suggestion here between "Adding removing .."
Comment #23
mpdonadioYup. Must have chopped it off when flowing to 80 cols.
Comment #24
berdirLooks good to me, but not sure if I can RTBC as I wrote most of the patch myself. @dawehner? :)
Comment #25
dawehnerJust some random rambling: Sometimes it feels like its easier to express these kind of technical problems using some kind of ascii graph / description of possible states instead of a long text like this. Anyway, this is just a sitenote. This text is totally understandable
Comment #26
xjmWell, this assumes that the person reading the code has the facility to interpret the ascii spatially (sight, spatial reasoning, possibly LTR native language...). For something like a list, the API module can render it semantically, but not if the spaces are a spatial map. In those cases we would at least want the information to be available as parseable text as well.
In this particular case a list or numbered list could do the trick? The text is good but walls-of-text are best broken up into smaller chunks for readability, generally.
\Drupal::config()here makes it backport-safe. Do we have a followup to add the service?Thank you for referencing a CR instead of an issue ID.
Neither of 1-2 is particularly worth blocking commit on given the severity of this issue, so leaving RTBC for the moment.
Comment #28
xjmNormally I might not credit the reasonably small review in #14 but this is definitely something that we want to fix in the long term. Good spot, thanks @martin107!
Going ahead and committing this with the "honor system" for followup(s), given that it would be good to have this in the beta for testing with the file usage change.
We might want to backport this to 8.3.x along with #2801777: Give users the option to prevent drupal from automatically marking unused files as temporary -- the two together might be worth a final 8.3.x patch release. However, that patch should be combined with this one if so.
Comment #30
mpdonadioIs anything really needed for an 8.3.x version? It applies cleanly (I checked), so we can just cherry-pick, depending on what we do with #2801777: Give users the option to prevent drupal from automatically marking unused files as temporary .
Comment #31
mpdonadioAnd re #26-2, since preRenderManagedFile() is a static method, we can't use DI. Or did you have a different idea? (and thanks to @Sam152 and @ larowlan for reminding me about this).
Comment #32
xjm@mpdonadio, we might as well include it WITH the 8.3.x version (see the other issue for details). They are for release together and the other isn't backported yet.