funky issue
| From: | Lukas Kahwe Smith | Date: | Wed, 30 Aug 2006 11:33:32 +0000 |
| Subject: | funky issue | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-43835@lists.php.net to get a copy of this message | ||
Hi,
I am noticing a funky issue in MDB2_Schema.
Specifically in the interaction between the parser [1] and the validator [2].
The parser generates some data structures, passes them on to the validator inside method calls. However the odd thing is that the process dies if I dont pass by reference variables that are just checked via isset().
here is some code from the parser:
case 'database-table':
$result = $this->val->validateTable($this->database_definition['tables'], $this->table, $this->table_name);
if (PEAR::isError($result)) {
$this->raiseError($result->getUserinfo(), 0, $xp, $result->getCode());
} else {
$this->database_definition['tables'][$this->table_name] = $this->table;
}
and here the corresponding method in validate:
function validateTable(&$tables, &$table, $table_name)
{
..
/* Table name duplicated? */
if (isset($tables[$table_name])) {
return $this->raiseError(MDB2_SCHEMA_ERROR_VALIDATE,
'table "'.$table_name.'" already exists');
}
..
}
$tables is not modified anywhere and this is the only place its actually being used inside the method. $table is however modified and therefore needs to be passed by reference.
switching the signature to
function validateTable($tables, &$table, $table_name
or even
function validateTable(&$table, $tables, $table_name
causes the operation to fail .. in 5.2.0 it seems to even cause a fatal error .. but i need to get this some more.
regards,
Lukas
[1] http://cvs.php.net/viewvc.cgi/pear/MDB2_Schema/MDB2/Schema/Parser.php?view=markup
[2] http://cvs.php.net/viewvc.cgi/pear/MDB2_Schema/MDB2/Schema/Validate.php?view=markup