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.

Comments

alex.ihlo’s picture

I've never done a patch before, where do you add this to?

marcingy’s picture

StatusFileSize
new1.2 KB

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.

alex.ihlo’s picture

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.

vm’s picture

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.

v8powerage’s picture

marcingy - Your patch isn't working, patch from first post is OK

SamRose’s picture

Status: Needs review » Reviewed & tested by the community
ktonini’s picture

2nd patch worked for me too. Thanks!

Jaza’s picture

Also working for me. Let's get it committed, thanks!

jacobangel’s picture

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;
SamRose’s picture

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.

SamRose’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new1.57 KB

Turned http://drupal.org/node/446094#comment-1874748 into a patch and tested. No errors found.

Turkish Delight’s picture

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!

shunshifu’s picture

Patch in #11 worked beautifully for me too

hadsie’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.25 KB

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.

kbahey’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
StatusFileSize
new1.74 KB

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.

kbahey’s picture

Status: Reviewed & tested by the community » Fixed

Fixed in 6.x-1.1, available here.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

totocol’s picture

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

vm’s picture

the latest version of the module should be used which is currently 1.7

totocol’s picture

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