REPORTED PROBLEM: When users submit a profile image, it saves correctly... but it also displays a file.inc error message:
"The specified file temporary://Untitled 2_0.jpg could not be copied, because no file by that name exists. Please check that you supplied the correct filename."
ANALYSIS:
A backtrace from the error reveals a call to user_save triggered by the Rules event user_update, causes the above error. I have one rule associated with that Event. It sets a field value on the updated account based on an external API. This triggers an entity_save, which throws the error. The error appears whether I force saving during rule execution, or allow rules cleanup to do it. If I disable the rule, the error disappears.
STEPS TO REPRODUCE:
1) create a rule that fires on "After updating an existing user account", which modifies a field value on the account. Or just import the following rule:
{ "rules_modify_user" : {
"LABEL" : "modify user",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "user_update" ],
"DO" : [
{ "data_set" : { "data" : [ "account:mail" ], "value" : "ohthehugemanatee@localhost.localdomain" } }
]
}
}
2) Edit a user, and add or change the profile image.
This may also be a problem with rules that fire on new account creation, I'm not sure.
Comments
Comment #1
ohthehugemanatee CreditAttribution: ohthehugemanatee commentedNoting a workaround: use the Event "before saving a user account", and add a condition to make sure that account_unsaved:uid is empty. This avoids the double save and should be interchangeable in most circumstances...
Comment #2
TR CreditAttribution: TR commentedEven though this issue is older, I'm going to mark it as a duplicate of #2077781: With "after updating user account" rule, upload of user picture succeeds but raises "file could not be copied" error because that issue has more details/discussion and workarounds.