From:             chris at studentadvantage dot com
Operating system: Linux 2.4.20-8smp
PHP version:      4.3.2
PHP Bug Type:     Unknown/Other Function
Bug description:  Subclass of overloaded class loses pass-by-reference functionality.

Description:
------------
When a class which is overloaded is included in another php file via
'require_once', 'require', etc., functions in classes which inherit from
that class and that take references no longer seem to be getting
references, rather they seem to be getting copies of the argument
variables.

Here's my setup (from 'phpinfo()'):

========%<========

PHP Version 4.3.2

System  Linux charles 2.4.20-8smp #1 SMP Thu Mar 13 17:45:54 EST 2003
i686
Build Date      Aug 20 2003 21:26:20
Configure Command       './configure' '--prefix=/opt/php' '--with-mysql'
'--with-apxs=/opt/apache/bin/apxs'
Server API      Apache
Virtual Directory Support       disabled
Configuration File (php.ini) Path       /opt/php/lib/php.ini
PHP API         20020918
PHP Extension   20020429
Zend Extension  20021010
Debug Build     no
Thread Safety   disabled
Registered PHP Streams  php, http, ftp

This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

========%<========

Incidently, in my example code php doesn't complain if
'my_base_b::my_base_b()' is not defined, but it does give an error if
'my_base_a::my_base_a()' isn't defined. From what I read in the manual, it
should complain because __call applies to constructors as well.

Reproduce code:
---------------
test_inc.php:
=================
<?php
  class my_base_a {
    function my_base_a( ) { }
    function __call( $method, $params, &$return ) {
      return( false );
    }
  };
  overload("my_base_a");
?>

test_main.php:
=================
<?php
  require_once('test_inc.php');

  class my_base_b {
    function my_base_b( ) { }
    function __call( $method, $params, &$return ) {
      return( false );
    }
  };
  overload("my_base_b");

  class overload_a extends my_base_a {
    function modify_reference( &$ref ) {
      $ref = "Modified Reference";
    }
  };

  class overload_b extends my_base_b {
    function modify_reference( &$ref ) {
      $ref = "Modified Reference";
    }
  }

  $instance_a = new overload_a( );
  $instance_b = new overload_b( );
  $ref_a = $ref_b = "Unmodified Reference";

  print "Before: $ref_a, $ref_b<br>";
  $instance_a->modify_reference( $ref_a );
  $instance_b->modify_reference( $ref_b );
  print "After: $ref_a, $ref_b<br>";

?>

Expected result:
----------------
Before: Unmodified Reference, Unmodified Reference
After: Modified Reference, Modified Reference

Actual result:
--------------
Before: Unmodified Reference, Unmodified Reference
After: Unmodified Reference, Modified Reference

-- 
Edit bug report at http://bugs.php.net/?id=25227&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=25227&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=25227&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=25227&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=25227&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=25227&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=25227&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=25227&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=25227&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=25227&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=25227&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=25227&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25227&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=25227&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=25227&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=25227&r=gnused

Reply via email to