On Wed, Jan 8, 2020 at 3:59 PM mdolezal.noctuint.cz via internals < internals@lists.php.net> wrote:
> Hello, > > I hope this is the appropriate mailing list, please redirect me to better > please if required. > > > > I am currently rewriting our PHP extension from PHP5 to PHP7. > > To call PHP methods from our C/C++ code we use slightly modified > zend_call_method from Zend/zend_interfaces.c (to use more arguments than > 2). > > > Now I found out that it does not work with arguments passed by reference, > such as: > > public function FuncWithRef(array &$changeThis) > > > > if values are changed in the PHP code then zval values back in C part after > zend_call_function call are not influenced. > > With PHP5 the value was overwritten and could be used later in C code. > > Previously the zend_fcall_info struct for function call was filled with > params simply by > > > > params[0] = &arg1; > > > > In PHP7 this is changed to > > > > ZVAL_COPY_VALUE(¶ms[0], arg1); > > > > After function is executed (zend_call_function) both fci.params and arg1 > contain still the original zval values, > > changes made in PHP code are not available. Is there any way how to solve > this? > > I am mainly searching for and comparing code snippets in PHP/ext folder to > see how things were rewritten from PHP5 to PHP7. > > Sorry if I missed something obvious and thank you for your help. > It looks like the implementation of zend_call_method() does not support this, as it does not copy parameters back after the call. I'd suggest to use the lower level zend_call_function() for the cases where you need this for now. Nikita