do_bind_inherited_class()

php.internals

Tim Starling

20 years ago
I was just browsing the PHP source and I noticed something apparently amiss. The top of do_bind_inherited_class() in Zend/zend_compile.c reads: found_ce = zend_u_hash_find(class_table, Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (void **) &pce); if (found_ce == FAILURE) { if (!compile_time) { /* If we're in compile time, in practice, it's quite possible * that we'll never reach this class declaration at runtime, * so we shut up about it. This allows the if (!defined('FOO')) { return; } * approach to work. */ zend_error(E_COMPILE_ERROR, "Cannot redeclare class %R", Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant)); } return NULL; } else { ce = *pce; } Shouldn't that be found_ce = zend_u_hash_find(class_table, Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (void **) &pce); if (found_ce == FAILURE) { zend_error(E_COMPILE_ERROR, "Internal Zend error - Missing class information for %R", Z_TYPE(opline->op1.u.constant), Z_UNIVAL(opline->op1.u.constant)); return NULL; } else { ce = *pce; } same as do_bind_class()? I'll submit that as a proper patch if you prefer. -- Tim Starling

Antony Dovgal

20 years ago
What exactly are you trying to fix? On 15.01.2006 16:15, Tim Starling wrote:
> I was just browsing the PHP source and I noticed something apparently amiss. > The top of do_bind_inherited_class() in Zend/zend_compile.c reads: > > found_ce = zend_u_hash_find(class_table, Z_TYPE(opline->op1.u.constant), > Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (void > **) &pce); > > if (found_ce == FAILURE) { > if (!compile_time) { > /* If we're in compile time, in practice, it's quite possible > * that we'll never reach this class declaration at runtime, > * so we shut up about it. This allows the if (!defined('FOO')) > { return; } > * approach to work. > */ > zend_error(E_COMPILE_ERROR, "Cannot redeclare class %R", > Z_TYPE(opline->op2.u.constant), Z_UNIVAL(opline->op2.u.constant)); > } > return NULL; > } else { > ce = *pce; > } > > > Shouldn't that be > > found_ce = zend_u_hash_find(class_table, Z_TYPE(opline->op1.u.constant), > Z_UNIVAL(opline->op1.u.constant), Z_UNILEN(opline->op1.u.constant), (void > **) &pce); > > if (found_ce == FAILURE) { > zend_error(E_COMPILE_ERROR, "Internal Zend error - Missing class > information for %R", Z_TYPE(opline->op1.u.constant), > Z_UNIVAL(opline->op1.u.constant)); > return NULL; > } else { > ce = *pce; > } > > same as do_bind_class()? I'll submit that as a proper patch if you prefer. > > -- Tim Starling >
-- Wbr, Antony Dovgal

Tim Starling

20 years ago
Antony Dovgal wrote:
> What exactly are you trying to fix?
Confusing, misdocumented code. I'm sorry, am I wasting bandwidth? I felt duty-bound to report it. -- Tim Starling