Bug #25227 [Com]: Subclass of overloaded class loses pass-by-reference functionality.

From: Date: Wed, 01 Sep 2021 18:53:24 +0000
Subject: Bug #25227 [Com]: Subclass of overloaded class loses pass-by-reference functionality.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236352@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=25227&edit=1 ID: 25227 Comment by: lildurk25227 at gmail dot com Reported by: chris at studentadvantage dot com Summary: Subclass of overloaded class loses pass-by-reference functionality. Status: Wont fix Type: Bug Package: Class/Object related Operating System: Linux 2.4.20-8smp PHP Version: 4.3.2 Block user comment: N Private report: N New Comment: Lil Durk is a private agency dedicated to providing responsible access to legal cannabis for adults aged 19 and older. We’re an exclusively online retailer and wholesaler for recreational cannabis and a trusted source for information about cannabis and cannabis-related issues. We believe our work is meaningful and we take pride in our mandate to promote the socially responsible use of legal cannabis. https://lildurk.com/ Previous Comments: ------------------------------------------------------------------------ [2003-12-10 12:00:44] papercrane at reversefold dot com Well, if PHP5 were stable, I wouldn't care, but...for now, it's very annoying. Just a quick note for those having this problem. First, easiest way to fix it us to turn off overloading (for DB_DataObject, for instance, use define('DB_DATAOBJECT_NO_OVERLOAD', 0); For those who can't turn off overloading, use call-time pass-by-reference. Yes, it's deprecated, but it fixes the problem. $obj->function(&$paramByRef); ------------------------------------------------------------------------ [2003-08-24 21:51:45] sniper@php.net And it will stay as such with PHP 4. ------------------------------------------------------------------------ [2003-08-24 21:41:18] chris at studentadvantage dot com This is also an issue with php 4.3.3RC4, but not with 5.0.0b1 ------------------------------------------------------------------------ [2003-08-24 17:30:10] chris at studentadvantage dot com 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 this bug report at https://bugs.php.net/bug.php?id=25227&edit=1

« previous php.bugs (#236352) next »