Req #62455 [Opn->Wfx]: last chance to work with __call by reference died after removing call-time-&
| From: | cataphract@php.net | Date: | Sun, 01 Jul 2012 13:08:53 +0000 |
| Subject: | Req #62455 [Opn->Wfx]: last chance to work with __call by reference died after removing call-time-& | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-171654@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62455&edit=1
ID: 62455
Updated by: cataphract@php.net
Reported by: scout4u at ya dot ru
Summary: last chance to work with __call by reference died
after removing call-time-&
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: *General Issues
PHP Version: 5.4.4
Block user comment: N
Private report: N
New Comment:
You can still pass by reference to __call using call_user_func_array().
Previous Comments:
------------------------------------------------------------------------
[2012-06-30 19:34:29] scout4u at ya dot ru
Description:
------------
As of PHP 5.4 our content management system became not working without
possibility to get it to life. Beacause of a bug of removing call-time passing
by reference.
Explanation:
We have magical loading of «methods» in class as __call() - processed launches:
__call:
1. seeking existing of function If it exists â then function launches
and everything is ok.
2. If there is no such function â it's been loaded from _functions/
directory:
So we have auto-loading of functions.
BUT:
Because of __call don't support (why???) references we could call our
methods like this:
$sm->test( &data );
and in test-function we were be able to work BY REFERENCE. In php53 there was
deprecations â ok, we were turning them off. BUT as of php54 we completely can't
load virtual function with passing reference nohow... at all.
Ok, we can to preload function if it doesn't exist. But we already can't work by
reference. So... in case of dealing with realy big array we will have to push
that into the function and COPY back to the original. This is a huge CPU/memory
consuming way.
Sooo... If there is no way to pass to the __call Maybe dear authors will revert
support (even with peprecation-errors) for future times exactly untill __call
could deal with reference (if that will never start working with reference â
maybe there should be way to work with __call at least by passing reference in
call-time maner?)
I belive that __call and its ability of working by reference is a criticaly
important (maybe not so usual happen) but important thing to leave in PHP still
working
Test script:
---------------
<?php
class sm{
function __call($n, $val){
if( !function_exists($n) )
include $n;
return call_user_func($n, $val); // call_user_func can not use reference either. But everything
works when we pass reference call-time.
}
}
$sm = new sm();
$data = array('prop'=>1);
function test( &$d ){
$d['prop'] = 2;
}
$sm->test( &$data ); // PHP 5.2, 5.3(deprecated) $data['prop'] === 2
//!!!!!!!!! as of PHP54 this techinique will stop working and working by reference to __call will
not be working in all PHP-version as of 54.
$sm->test( &$data ); // PHP 5.4(removed) fail
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62455&edit=1