Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When generating users the picture files are registered under file_usage
Steps to reproduce:
drush --yes site-install
drush --yes en devel_generate
drush sql-query "select * from file_usage"
drush --yes genu 5
drush sql-query "select * from file_usage"
The file_usage should contain 5 references to the user type.
Next create a new user by hand:
- Visit admin/people/create
- Add picture
Next run
drush sql-query "select * from file_usage"
fid module type id count
26 user user 17 1
This user picture is managed.
This could be of
function user_save($account, $edit = array(), $category = 'account') {
...
if (!$picture->status) {
as we generate a managed file
function devel_create_users($num, $kill, $age = 0, $roles = array()) {
...
// Create an empty, managed file where we want the user's picture to
// be so we can have GD overwrite it with the image.
$picture_directory = variable_get('file_default_scheme', 'public') . '://' . variable_get('user_picture_path', 'pictures');
file_prepare_directory($picture_directory, FILE_CREATE_DIRECTORY);
XRef Discovered by deleting files belonging to nodes and users using drush entity #1330504: Test the File entity which failed for nodes due to file_usage.
Comment | File | Size | Author |
---|---|---|---|
#1 | devel-user-picture-file-usage-1336224-1.patch | 1.53 KB | clemens.tolboom |
Comments
Comment #1
clemens.tolboomThe attached patch creates a temporary:// file which when set $file->status = 0 triggers user_save to copy the image into it's final destination.
less is more :)
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedI believe this is a dupe.
Comment #3
clemens.tolboomThis is not a dup of #1288674: Devel generates files without filenames which only fixes the file name.
This patch links the file to the user as the issue summary tries to tell. Just running
on a devel genu / genc site should convince you.
Files for nodes are in file_usage table but the files for users are not.
Comment #4
willzyx CreditAttribution: willzyx commentedClosing for lack of activity. Feel free to reopen if the issue still exists