Doctrine 1
  1. Doctrine 1
  2. DC-271

Doctrine_Record link many many

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2.0-BETA3
    • Fix Version/s: 1.2.0
    • Component/s: Record
    • Labels:
      None
    • Environment:
      php 5.3, win xp sp3/fc4

      Description

      When saving the generated user form of sfGuardDoctrinePlugin 3.0.0 with a related many many object(s), such as groups or permissions, is/are selected, the script dies in Doctrine_Record line 2501 of R6780. Apparently public property access of the relation does not return a Doctrine_Collection object .

      Doctrine_Record.php
       
          public function link($alias, $ids, $now = false)
          {
                  //... some code
                  foreach ($records as $record) {
                      if ($this->$alias instanceof Doctrine_Record) {
                          $this->$alias = $record;
                      } else {
                          $this->$alias->add($record); //fails here
                      }
                  }
                  //... more code
          }
      

      So I used this workaround as a temporary measure.

      ProjectConfiguration.php
       
        public function setup()
        {
          $this->enablePlugins(
            'sfDoctrinePlugin', 
            'sfDoctrineGuardPlugin'
          );
          
          $this->dispatcher->connect('doctrine.filter_model_builder_options', array($this, 'doctrineFilterModelBuilderOptions'));    
        }
        
        public function doctrineFilterModelBuilderOptions(sfEvent $event, $options)
        {
        	$options['baseClassName'] = 'myDoctrineRecord';
        	
          return $options;
        }
      

      Notice that I only changed the access from property access to array access.

      myDoctrineRecord.php
       
          public function link($alias, $ids, $now = false)
          {
                  //... some code
                  foreach ($records as $record) {
                      if ($this->$alias instanceof Doctrine_Record) {
                          $this->$alias = $record;
                      } else {
                          $this[$alias]->add($record); //works for me
                      }
                  }
                  //... more code
          }
      

        Activity

        Hide
        Colin Darie added a comment -

        I confirm this issue, and the following line solves it for me too (on a symfony 1.4 project)

        Doctrine_Record.php, line 2503
         
        $this[$alias]->add($record);
        //instead of
        $this->$alias->add($record);
        
        Show
        Colin Darie added a comment - I confirm this issue, and the following line solves it for me too (on a symfony 1.4 project) Doctrine_Record.php, line 2503 $ this [$alias]->add($record); //instead of $ this ->$alias->add($record);

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            Ken Marfilla
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: