Posted by shaisachs on April 27, 2009 at 12:38pm
| Project: | Register with Picture |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
If I use this module to register, but don't upload a picture during the registration process, I get this error:
The selected file could not be copied, because no file by that name exists. Please check that you supplied the correct filename.
This is because in the _user hook, the "insert" op doesn't check that file_save_upload returned successfully. The attached patch resolves this issue.
| Attachment | Size |
|---|---|
| reg_with_pic.module.patch | 738 bytes |
Comments
#1
I've never done a patch before, where do you add this to?
#2
Cleaner version of the patch that uses a check for $file rather than !$file. But yes checking for the presence of the file solves the file not found error. And alex.ihlo - http://drupal.org/patch/apply shows how to apply a patch.
#3
Yeah I found that before I replied to ur first post. But I just don't understand how to access the command line in the cPanel of my host, like that page says to do. ...I should've said that in my first reply-
Either way, thanks for the updated patch, definitely necessary.
#4
you do not access the command line in cPanel. You need shell access and not all hosts allow this. Your's may, if you prefer command line. however, you can set up something like cygwin (if using windows) on your localmachine and patch the files, then upload them.
#5
marcingy - Your patch isn't working, patch from first post is OK
#6
Patch http://drupal.org/files/issues/file_check.patch in http://drupal.org/node/446094#comment-1713054 above working for me
#7
2nd patch worked for me too. Thanks!
#8
Also working for me. Let's get it committed, thanks!
#9
wouldn't this be cleaner?
case 'insert':// file repopulates from uploadcache
if($file = file_save_upload('picture_upload_register')) {
$info = image_get_info($file->filepath);
// save picture to correct path and update the row in the user table
$destination = variable_get('user_picture_path', 'pictures') .'/picture-'. $user->uid .'.'. $info['extension'];
if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
db_query("UPDATE {users} SET picture='%s' WHERE uid=%d", $file->filepath, $user->uid);
}
}
break;
#10
The patch at http://drupal.org/node/446094#comment-1713054 may be causing me problems. All user images on profile page disappear after a new user uploads, until cache is cleared.
#11
Turned http://drupal.org/node/446094#comment-1874748 into a patch and tested. No errors found.
#12
Firstly, I want to say that I've applied the patch in comment #11, and it works beautifully.
Random question for you all however. During my tests, I created a user and ran into the error message when no picture was uploaded. However, I decided that some users may decide to go and recreate their account, in which case I receive a "the picture was resized" message. When I check my avatar file I find that no picture was uploaded (as I imagine no user could be associated with that picture due to the fact that a user was created previously), however I'm curious, is that resized picture floating around in cache somewhere? Thanks!
#13
Patch in #11 worked beautifully for me too
#14
This works for me too. I've attached a patch which is identical to #11 but with the spacing fixed on the case 'insert' line.
This bug also turns up when programmatically calling user_save to insert new users.
#15
Marking #313588: Error Message Displayed When User Registers with No Avatar (f.e. automatically generated by listhandler) as a duplicate of this issue.
I am attaching a pre-patched module that has been tested. It also contains some formatting changes to make the code more readable.
@mmilano, if you are busy, I can commit this and create a new stable release 6.x-1.1. Many people need this. You don't need to do anything.
#16
Fixed in 6.x-1.1, available here.
#17
Automatically closed -- issue fixed for 2 weeks with no activity.
#18
HI,
Thanks for this module.
I have installed version 6.x-1.1 but still does not fixed the issue. Have tested many things and it only happens when user does not select a picture on registration so it is down to this module.
Any alternatives fixes?
Raul
#19
the latest version of the module should be used which is currently 1.7
#20
Thank @VM
Just an update. I finally found what was wrong. I had accidentally copied an old version of reg_with_pic in another module's folder so I had to do a search on the database to actually find out if I had any reg_with_pic files anywhere
Thanks for the response anyway