Development

#3210: propel_load_data.patch

You must first sign up to be able to contribute.

Ticket #3210: propel_load_data.patch

File propel_load_data.patch, 1.7 kB (added by trivoallan, 10 months ago)
  • lib/symfony/plugins/sfPropelPlugin/lib/propel/sfPropelData.class.php

    old new  
    9494      foreach ($datas as $key => $data) 
    9595      { 
    9696        // create a new entry in the database 
    97         $obj = new $class(); 
     97        $classname = ucfirst($class); 
     98        if (!class_exists($classname)) 
     99        { 
     100          throw new sfException(sprintf('Unknown class "%s".')); 
     101        } 
     102 
     103        $obj = new $classname(); 
    98104 
    99105        if (!$obj instanceof BaseObject) 
    100106        { 
    101           throw new Exception(sprintf('The class "%s" is not a Propel class. This probably means there is already a class named "%s" somewhere in symfony or in your project.', $class, $class)); 
     107          throw new sfException(sprintf('The class "%s" is not a Propel class. This probably means there is already a class named "%s" somewhere in symfony or in your project.', $classname, $classname)); 
    102108        } 
    103109 
    104110        if (!is_array($data)) 
     
    245251          continue; 
    246252        } 
    247253 
    248         call_user_func(array($class.'Peer', 'doDeleteAll'), $this->con); 
     254        // Check that peer class exists before calling doDeleteAll() 
     255        $peer_classname = ucfirst($class.'Peer'); 
     256        if (!class_exists($peer_classname)) 
     257        { 
     258          throw new sfException(sprintf('Unknown class "%s".', $peer_classname)); 
     259        } 
     260 
     261        call_user_func(array($peer_classname, 'doDeleteAll'), $this->con); 
    249262 
    250263        $this->deletedClasses[] = $class; 
    251264      }