Development

#1709 (sfGuardUserProfile.user_id not updated when sfGuardUser saved for the 1st time)

You must first sign up to be able to contribute.

Ticket #1709 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

sfGuardUserProfile.user_id not updated when sfGuardUser saved for the 1st time

Reported by: dhooge Assigned to: fabien
Priority: minor Milestone:
Component: sfGuardPlugin Version: 1.0.0
Keywords: sfguard profile save Cc:
Qualification:

Description

First you create from scratch both an sfGuardUser instance and its associated sfGuardUserProfile.
Then you populate them.
Problem: the sfGuardUserProfile.user_id is not updated when the sfGuardUser instance is saved.

This update is done at the end of the getProfile() method but it is too early in that case since the sfGuardUser has no Id yet. This must also be done either in sfGuardUser::save() or sfGuardUser::doSave().

As a workaround for the time being, I created the following method in my actions.class.php:

  protected function savesfGuardUser($sf_guard_user)
  {
    parent::savesfGuardUser($sf_guard_user);
    $profile = $this->sf_guard_user->getProfile();
    $profile->setUserId($sf_guard_user->getId());
    $profile->save();
  }

Change History

05/04/07 14:13:13 changed by dhooge

Same kind of problem with addPermissionByName() which expects its associated object to already have a defined ID. The solution is again to first save the sfGuardUser instance and then add permissions.

09/13/07 23:43:14 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.
  • qualification set to Unreviewed.

in r5076

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.