After upgrading to the latest version of the Gallery2 module from the previous current release, the following error message appears when a new user tries to register:

warning: __clone method called on non-object in /home/.gob/xxxxx/drupal5/includes/common.inc on line 1376

  • The user/register page appears to be the only place where this error occurs.
  • Enabling/disabling the module toggles the error on/off.
  • Turning caching on/off does not seem to influence the issue.
CommentFileSizeAuthor
#5 gallery_user_clone.patch1.08 KBprofix898

Comments

bjmiller’s picture

The following seems to have fixed it for me. You'll need to clear your website's cache if it is enabled to see the results.

At line 69 in gallery.module:

change

$gallery_user = drupal_clone($user);

to:

if (isset($user))
    $gallery_user = drupal_clone($user);
mynameisbrian’s picture

That fix gets rid of the error on the /user/register page, but after submitting a username and email address, the same error shows up on the redirect page (usually the defauly front page), and no authorization email is sent to the user. Any ideas?

profix898’s picture

Assigned: Unassigned » profix898

I will take a look at this ... shouldnt be too difficult to fix ...

mynameisbrian’s picture

Actually the "not sending an authorization email" part of my previous post was a bug on my end. However, the common.inc line 1375 error still pops up after a registration request. I actually just commented the line out of that file, as it mentions it's a substitute function for PHP4, but I'm using PHP5. Still, it'd be good to figure out what's causing this.

profix898’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

Can you please review the attached patch. hook_user is called multiple times during the registration process with $edit/$user not being set or empty ... The patch moves the drupal_clone() to insert/update op where it is actually needed.

@mynameisbrian: In PHP5 all objects are passed by reference by default. To prevent alteration of the user object in gallery_user_* the drupal_clone() call is needed. In PHP4 cloning is not necessary. The Drupal documentation for the function is a little misleading though.

bjmiller’s picture

Thanks. I rolled back my temporary fixes and applied your patch. Seems to work well.

profix898’s picture

Assigned: profix898 » Unassigned
Status: Needs review » Fixed

Patch committed to Drupal-5 branch. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)