Update
User Pictures are still disappearing. This time, on a fresh 8.0.5 site though, it is not the default image that is being lost - per the summary below - and nothing to do with image styles - this time we have gone with the style we were given by default by the User module - but Pictures added after custom fields were added in Configuration >> Account settings
(/admin/config/people/accounts
) are going missing although AFAIR the default image which was added before custom fields were added, still remains intact..
Here's some new info: (Please see screenshot attached)
- I uploaded the Picture last night after I noticed it had disappeared
- The image had been deleted from the styles directory this morning
- I looked in
/admin/content/files
and saw that the files was listed as "permanent" and "used in 1 place" even though the image file had been deleted - I removed and re-uploaded the User Picture and it displayed as exptect ... but ...
- The image file appeared twice; once as a "Temporary" file and once as a "permanent" file per the screenshot.
- The screenshot shows that both entries pertain to the most recent upload.
Previous summary
On /admin/config/people/accounts/fields/user.user.user_picture the UI still shows that a default Image has been uploaded. However the image has been removed from the appropriate image style directory.
The default image is displayed correctly for at least a day.
The image is automatically removed after a few days but survives several cron runs.
This behaviour happens regardless of whether Drupals default image style or a custom image style is chosen.
This behaviour happens even when the user picture field is referenced in a View.
Pictures of users explicitly uploaded (IE where the default image is not used) display correctly after the default image has been automatically removed.
Steps to reproduce:
- create a custom image style e.g. "User picture (85x85)"
- Add some more fields to Configuration >> People (admin/config/people/accounts/fields) e.g. Name and address text fields
- Upload a default image for the Picture field (admin/config/people/accounts/fields/user.user.user_picture)
- Tell Drupal to use our custom image style to display the user picture (https://admin/config/people/accounts/display)
- Create a View to list all users with their picture and any other fields like name and address
- Tell the view to use the custom image style to display the User_picture field
- Add some users. Some with pictures ; some without (IE that will use the default image)
- Wait a few days
- Monitor the use of the files directory in which the custom image is stored
- Monitor the page in which the View is displayed:
note that, after a few days, the browser's "missing image" icon and our alt text of the users picture 's the rendered View row will replace the default image you uploaded in step 3.
O
Comment | File | Size | Author |
---|---|---|---|
#7 | Files___Bradford_Abbas_β_Website.png | 40.75 KB | iainH |
Comments
Comment #2
cilefen CreditAttribution: cilefen commentedCan you add the steps to reproduce to the issue summary please?
Comment #3
iainH CreditAttribution: iainH as a volunteer commentedComment #4
iainH CreditAttribution: iainH as a volunteer commentedComment #5
swentel CreditAttribution: swentel commentedI can't figure out why this would happen, this isn't really related to the user module or so since it's a normal image field.
When uploading, I don't see the status being set to temporary either.
Comment #6
iainH CreditAttribution: iainH as a volunteer commentedYes ... but ... as images are not dropped when referenced by Nodes etc. this suggests that the way that image styles and User module interact is the problem. Is there a User module test case that would be able to verify that the default user picture is retained after a few days .... perhaps by tweaking the timestamp of the image-style-generated file?
Comment #7
iainH CreditAttribution: iainH as a volunteer commentedComment #8
iainH CreditAttribution: iainH as a volunteer commentedThis is a bit of a problem for me (I tagged it as a major bug) because displaying some fields of the user profiles - including the user pictures - are a visitor-facing requirement of the site and, currently, this is the only bug I know of that is preventing the site from going live.
Comment #9
iainH CreditAttribution: iainH as a volunteer commentedI delved into this a bit more and have raised an issue on the Core Image queue #2683679: Images incorrectly deleted with a theory - to be refuted most probably!; not really knowing yet where the error lies. But as @swentel suggests it is unlikely to be a User module issue I thought it was worth a go.
Comment #10
xjmIf this is still happening, it's critical because of the data loss. We can leave it filed against
user.module
for now (no need to file a separate issue against a different component within the core queue).Comment #11
claudiu.cristeaThis might be an effect of #2787187: Data loss: Deleting a translation of an entity deletes all file_usage entries for files referenced by the entity .
Comment #12
xjmWell, nothing in the summary suggests the user is being translated.
There was also a previous bug #2725415: Text Editor module fails to track usage of images uploaded in text_with_summary fields, allows uploaded images to be deleted but that was specific to images used in long text summaries with CKeditor, which would not apply here.
Then there is #1239558: Deleting an entity with revisions and file/image field does not release file usage of non-default revisions, causing files to linger which could result in unused images being listed in general, but users are also not revisioned by default, so that also seems unlikely.
Comment #13
xjmI think I just managed to reproduce this somehow with an image field:The two things I did were rename a file, and rely on the file munging for a file with two extensions. Going to try those two things separately on a new install and see which is reproducible.Edit: Not actually the bug.
Comment #14
xjmNever mind, in #13, the files are actually named differently, and I confirmed that when temporary files are purged, the permanent file still remains.
Comment #15
xjmSo the screenshot attached above is not actually enough to confirm that the original report cause the file to be marked as both temporary and permanent.
/admin/structure/files
displays the name of the file, which is not the same as its filepath. To confirm there were actually two entries for a single file using that view, one would need to look at the links displayed and confirm they are the same file.Comment #16
xjmComment #17
xjmThere are a lot of steps that would seem unrelated in the summary, but I wasn't able to reproduce this, so I tried the following.
/admin/config/media/image-styles
and add a "User picture" image style that resizes the image to 85 x 85./admin/config/people/accounts/fields
and add a date field for the user's birthday./admin/config/people/accounts/fields/user.user.user_picture
and upload a default user picture./admin/config/people/accounts/display
and change the image style to the "User picture" one./admin/config/development/configuration/single/import
:system.file
as the configuration name.(Use the filepath and default config hash from your
system.file
config. You can see it by going to the single export tab and looking at the samesystem.file
config.)Save. This overrides your temporary file purge time to be 1 second, meaning temporary files are essentially deleted immediately when you run cron.
/admin/reports/status
./admin/people
. Nothing has been deleted.So I think we need some other steps to reproduce this, and maybe some more specifics for the original report in the summary. Such as:
file_managed
table? Are there still entries there after the problem starts happening?Alternately, if anyone can find a different (less complicated) path to reproduce this, that would really help. Maybe someone who is having the problem could set up a simple site and monitor it and debug with it, then report back here.
Comment #18
yobottehg CreditAttribution: yobottehg commentedI have a client reporting the same behaviour on the file upload form. Can't reproduce it also
Comment #19
xjm@yobottehg, a few questions that might help diagnose it:
/admin/content/files
? (Keeping in mind that the displayed file name does not necessarily have the counters like_0
so they need to check both the name and the link to the file.)Comment #21
dawehnerLast summer (July 2015) I debugged a similar problem with files disappearing from the system somehow.
This has been files attached to a regular node form though.
I observed the following things:
{files}
table, but some remainedComment #22
dawehnerThere seems to be indications that its related to the wysiwyg editor, see #2806287: Wysiwyg uploaded images disappear
Comment #23
quironsuscribing
Comment #24
lauriiiI have also faced this same issue on multiple sites that I have worked with. It has only happened few times and I have no clues what has caused it to happen.
Comment #25
dawehner@lauriii
Did you had more than one language on the site?
Comment #26
lauriii@dawehner yup, all of the sites where I have seen this to happen has been multilingual
Comment #27
quironMaybe this can be usefull, are steps to reproduce an unexpected image lost for image fields in multilingual sites: https://www.drupal.org/node/2810355
Comment #28
Juanswe CreditAttribution: Juanswe commentedHi, First i wanna say that im sorry for my bad english.
im a very new guy with Drupal, im using D8.2.5. And im having the same issues. But my problem its happening when i install a new language on my page and the logged in user change the default language on her page, the avatar dissapear, But only if he change the language. The others user have not problems.
Sorry, i can not help more because im new in Drupal, but i wanna share my problem so maybe can help somehow.
Thanks!
Comment #30
Wim Leers#28: thank you so much for posting that! Your information confirms exactly what I suspected:
Then the steps to reproduce are:
content_translation
installed!)This is because
\Drupal\user\AccountForm::form()
does:Which means that
\Drupal\user\AccountForm::syncUserLangcode()
is called upon saving the account form, which then does:… which means that the default translation is being changed!
This is exactly the same problem as #2810355: $entity->isDefaultTranslation() behaves incorrectly when changing default translation, causing file/image field usage to be set to zero, causing files to be deleted then.
Thanks to #28, I was able to prove this conclusively.
Comment #31
Wim LeersThis is now merged with #2810355 — see #2810355-40: $entity->isDefaultTranslation() behaves incorrectly when changing default translation, causing file/image field usage to be set to zero, causing files to be deleted.