Hello,

the attched patch fixes this for me, but I'm sure it will impact a lot of 
other things. Andi, can you shed some light on it?

Derick

On 25 Mar 2002 [EMAIL PROTECTED] wrote:

> From:             [EMAIL PROTECTED]
> Operating system: Linux
> PHP version:      4.1.2
> PHP Bug Type:     Scripting Engine problem
> Bug description:  Multiply-defined functions in classes not reported
> 
> PHP does not report multiply-defined errors for class member functions. For
> example, the following script below, when executed, only outputs "two",
> with no errors.
> 
> Instead, PHP should be giving error messages since the function bar has
> been defined multiple times.
> 
> <?
> class foo
> {
>         function bar() {echo "one\n";}
>         function bar() {echo "two\n";}
> }
> 
> $f = new foo();
> $f->bar();
> -- 
> Edit bug report at http://bugs.php.net/?id=16265&edit=1
> -- 
> Fixed in CVS:        http://bugs.php.net/fix.php?id=16265&r=fixedcvs
> Fixed in release:    http://bugs.php.net/fix.php?id=16265&r=alreadyfixed
> Need backtrace:      http://bugs.php.net/fix.php?id=16265&r=needtrace
> Try newer version:   http://bugs.php.net/fix.php?id=16265&r=oldversion
> Not developer issue: http://bugs.php.net/fix.php?id=16265&r=support
> Expected behavior:   http://bugs.php.net/fix.php?id=16265&r=notwrong
> Not enough info:     http://bugs.php.net/fix.php?id=16265&r=notenoughinfo
> Submitted twice:     http://bugs.php.net/fix.php?id=16265&r=submittedtwice
> 
Index: Zend/zend_compile.c
===================================================================
RCS file: /repository/Zend/zend_compile.c,v
retrieving revision 1.225
diff -u -r1.225 zend_compile.c
--- Zend/zend_compile.c 14 Feb 2002 03:55:20 -0000      1.225
+++ Zend/zend_compile.c 25 Mar 2002 19:13:17 -0000
@@ -732,7 +732,9 @@
        op_array.return_reference = return_reference;
 
        if (is_method) {
-               zend_hash_update(&CG(active_class_entry)->function_table, name, 
name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array));
+               if (zend_hash_add(&CG(active_class_entry)->function_table, name, 
+name_len+1, &op_array, sizeof(zend_op_array), (void **) &CG(active_op_array)) == 
+FAILURE) {
+                       zend_error(E_ERROR, "Cannot redeclare %s()", name);
+               }
        } else {
                zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
 
-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to