List Info

Thread: funky issue




funky issue
user name
2006-08-30 11:33:32
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_definitio
n['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_na
me] 
= $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/p
ear/MDB2_Schema/MDB2/Schema/Parser.php?view=markup
[2] 
http://cvs.php.net/viewvc.cgi
/pear/MDB2_Schema/MDB2/Schema/Validate.php?view=markup

-- 
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

funky issue
user name
2006-08-30 11:45:25
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_defin
ition['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_na
me] 
>= $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.n
et - blog

-- 
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

funky issue
user name
2006-08-30 14:37:43
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_definitio
n['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_na
me]
> = $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/p
ear/MDB2_Schema/MDB2/Schema/Parser.php?view=markup
> 
> [2]
> http://cvs.php.net/viewvc.cgi
/pear/MDB2_Schema/MDB2/Schema/Validate.php?view=markup
> 

yep, sounds like a bug... you can always use
array_key_exists() instead.

 -Philippe

-- 
PEAR Development Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )