Skip to content

Commit

Permalink
Revert "Fix more than one record generator initialisation on same PHP…
Browse files Browse the repository at this point in the history
… process"

This reverts commit a498c6b.
  • Loading branch information
alquerci committed Sep 10, 2018
1 parent a6cfb23 commit cc986a3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
1 change: 0 additions & 1 deletion lib/Doctrine/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class Doctrine_Event
const RECORD_DQL_SELECT = 28;
const RECORD_DQL_UPDATE = 29;
const RECORD_VALIDATE = 30;
const RECORD_POST_SETUP = 31;

/**
* @var mixed $_nextSequence the sequence of the next event that will be created
Expand Down
7 changes: 0 additions & 7 deletions lib/Doctrine/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,6 @@ public function preHydrate($event)
public function postHydrate($event)
{ }

/**
* Empty template method to provide Record classes with the ability to alter setup
* after it runs
*/
public function postSetUp($event)
{ }

/**
* Get the record error stack as a human readable string.
* Useful for outputting errors to user via web browser
Expand Down
10 changes: 7 additions & 3 deletions lib/Doctrine/Record/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ public function initialize(Doctrine_Table $table)
$this->_options['tableName'] = str_replace('%TABLE%', $ownerTableName, $tableName);
}

// check that class doesn't exist (otherwise we cannot create it)
if ($this->_options['generateFiles'] === false && class_exists($this->_options['className'])) {
$this->_table = Doctrine_Core::getTable($this->_options['className']);
return false;
}

$this->buildTable();

$fk = $this->buildForeignKeys($this->_options['table']);
Expand Down Expand Up @@ -455,9 +461,7 @@ public function generateClass(array $definition = array())
} else {
throw new Doctrine_Record_Exception('If you wish to generate files then you must specify the path to generate the files in.');
}
} elseif (!class_exists($definition['className'])) {
// The class is not defined then we can load the definition.

} else {
$def = $builder->buildDefinition($definition);

eval($def);
Expand Down
5 changes: 5 additions & 0 deletions lib/Doctrine/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ public function setTableDefinition()

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

$autoLoad = (bool) ($this->_options['generateFiles']);
if (class_exists($className, $autoLoad)) {
return false;
}

// move any columns currently in the primary key to the end
// So that 'keyword' is the first field in the table
$previousIdentifier = array();
Expand Down
8 changes: 0 additions & 8 deletions lib/Doctrine/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,6 @@ public function __construct($name, Doctrine_Connection $conn, $initDefinition =
if ($this->isTree()) {
$this->getTree()->setUp();
}

$event = new Doctrine_Event($this->record, Doctrine_Event::RECORD_POST_SETUP);

$this->record->postSetUp($event);
} else {
if ( ! isset($this->_options['tableName'])) {
$this->setTableName(Doctrine_Inflector::tableize($this->_options['name']));
Expand Down Expand Up @@ -3061,10 +3057,6 @@ public function initializeFromCache(Doctrine_Connection $conn)
$this->getTree()->setUp();
}

$event = new Doctrine_Event($this->record, Doctrine_Event::RECORD_POST_SETUP);

$this->record->postSetUp($event);

$this->_filters[] = new Doctrine_Record_Filter_Standard();
if ($this->getAttribute(Doctrine_Core::ATTR_USE_TABLE_REPOSITORY)) {
$this->_repository = new Doctrine_Table_Repository($this);
Expand Down

0 comments on commit cc986a3

Please sign in to comment.