Re: funky issue
| From: | Bertrand Mansion | Date: | Wed, 30 Aug 2006 11:45:25 +0000 |
| Subject: | Re: funky issue | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-43836@lists.php.net to get a copy of this message | ||
Lukas Kahwe Smith wrote:
>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.
Hi Lukas,
I didn't look at the code so here are just a few things I'd try:
- use array_key_exists instead of isset()
- make sure $tables is an array
- make sure $table_name is a scalar
Not sure it will help...
--
Bertrand Mansion
http://www.mamasam.com - creative internet solutions
http://golgote.freeflux.net - blog