Skip to content

Commit cc986a3

Browse files
committed
Revert "Fix more than one record generator initialisation on same PHP process"
This reverts commit a498c6b.
1 parent a6cfb23 commit cc986a3

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

lib/Doctrine/Event.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ class Doctrine_Event
6868
const RECORD_DQL_SELECT = 28;
6969
const RECORD_DQL_UPDATE = 29;
7070
const RECORD_VALIDATE = 30;
71-
const RECORD_POST_SETUP = 31;
7271

7372
/**
7473
* @var mixed $_nextSequence the sequence of the next event that will be created

lib/Doctrine/Record.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,6 @@ public function preHydrate($event)
600600
public function postHydrate($event)
601601
{ }
602602

603-
/**
604-
* Empty template method to provide Record classes with the ability to alter setup
605-
* after it runs
606-
*/
607-
public function postSetUp($event)
608-
{ }
609-
610603
/**
611604
* Get the record error stack as a human readable string.
612605
* Useful for outputting errors to user via web browser

lib/Doctrine/Record/Generator.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ public function initialize(Doctrine_Table $table)
160160
$this->_options['tableName'] = str_replace('%TABLE%', $ownerTableName, $tableName);
161161
}
162162

163+
// check that class doesn't exist (otherwise we cannot create it)
164+
if ($this->_options['generateFiles'] === false && class_exists($this->_options['className'])) {
165+
$this->_table = Doctrine_Core::getTable($this->_options['className']);
166+
return false;
167+
}
168+
163169
$this->buildTable();
164170

165171
$fk = $this->buildForeignKeys($this->_options['table']);
@@ -455,9 +461,7 @@ public function generateClass(array $definition = array())
455461
} else {
456462
throw new Doctrine_Record_Exception('If you wish to generate files then you must specify the path to generate the files in.');
457463
}
458-
} elseif (!class_exists($definition['className'])) {
459-
// The class is not defined then we can load the definition.
460-
464+
} else {
461465
$def = $builder->buildDefinition($definition);
462466

463467
eval($def);

lib/Doctrine/Search.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ public function setTableDefinition()
311311

312312
$className = $this->getOption('className');
313313

314+
$autoLoad = (bool) ($this->_options['generateFiles']);
315+
if (class_exists($className, $autoLoad)) {
316+
return false;
317+
}
318+
314319
// move any columns currently in the primary key to the end
315320
// So that 'keyword' is the first field in the table
316321
$previousIdentifier = array();

lib/Doctrine/Table.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,6 @@ public function __construct($name, Doctrine_Connection $conn, $initDefinition =
268268
if ($this->isTree()) {
269269
$this->getTree()->setUp();
270270
}
271-
272-
$event = new Doctrine_Event($this->record, Doctrine_Event::RECORD_POST_SETUP);
273-
274-
$this->record->postSetUp($event);
275271
} else {
276272
if ( ! isset($this->_options['tableName'])) {
277273
$this->setTableName(Doctrine_Inflector::tableize($this->_options['name']));
@@ -3061,10 +3057,6 @@ public function initializeFromCache(Doctrine_Connection $conn)
30613057
$this->getTree()->setUp();
30623058
}
30633059

3064-
$event = new Doctrine_Event($this->record, Doctrine_Event::RECORD_POST_SETUP);
3065-
3066-
$this->record->postSetUp($event);
3067-
30683060
$this->_filters[] = new Doctrine_Record_Filter_Standard();
30693061
if ($this->getAttribute(Doctrine_Core::ATTR_USE_TABLE_REPOSITORY)) {
30703062
$this->_repository = new Doctrine_Table_Repository($this);

0 commit comments

Comments
 (0)