#1547: Saving an object creates unnecesary NULL related object
-------------------------+--------------------------------------------------
  Reporter:  jpsaraceno  |       Owner:  jwage                
      Type:  defect      |      Status:  closed               
  Priority:  critical    |   Milestone:  1.0.3                
 Component:  Record      |     Version:  1.0.2                
Resolution:  worksforme  |    Keywords:                       
  Has_test:  0           |    Mystatus:  Pending Core Response
 Has_patch:  0           |  
-------------------------+--------------------------------------------------
Comment (by jpsaraceno):

 Sorry about the late response, tested a bit more and wasn't actually the
 save() what triggered the null location creation.
 Problem was, after this I was redirecting to a page that was attempting to
 display the location doing something like:
 {{{
 <?php if($user->getLocation() : ?>
 //display location here
 <?php endif; ?>
 }}}

 So, managed to fix the issue by adding a method hasLocation:
 {{{
 public function hasLocation() {
     return ($this->location_id != null)
 }
 }}}

 And then asking for hasLocation() instead of getLocation();

 Now, I would expect getLocation() to simply return null in this case,
 since the Location in this case has an absolutely independent life cycle
 from the user. Don't know what's the expected behavior, or if this can or
 should be configurable.

 Thanks for looking after this,

 JP.

-- 
Ticket URL: <http://trac.doctrine-project.org/ticket/1547#comment:4>
Doctrine <http://www.phpdoctrine.org>
PHP Doctrine Object Relational Mapper
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"doctrine-svn" group.
 To post to this group, send email to [email protected]
 To unsubscribe from this group, send email to [EMAIL PROTECTED]
 For more options, visit this group at 
http://groups.google.co.uk/group/doctrine-svn?hl=en-GB
-~----------~----~----~----~------~----~------~--~---

Reply via email to