Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108036 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62885 invoked from network); 8 Jan 2020 17:00:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Jan 2020 17:00:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 75C601801FD for ; Wed, 8 Jan 2020 07:06:10 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 8 Jan 2020 07:06:10 -0800 (PST) Received: by mail-lf1-f52.google.com with SMTP id n25so2715929lfl.0 for ; Wed, 08 Jan 2020 07:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0gSd8P93rvKDLe2hdGzrfyOCIhLiQS33lPPOf0NFTws=; b=NShi15agueMhN6/lEWjSumihlPjgSYm2anEcaTAlkU0vY+QVJ7nQcx3Zvsi/0QpQdW TINiJKcGe1GNELo/f935l7dLCS21GNyWY+uQxBm2XnQrEGb6xgXDKOnxAFeACG2X2tz2 TPBvmLsGq+y+rrRjDbQVmqFpCRS5oTIz1H7WR9JtzoOmM0Krfqci78/zn3AbNTX9cLNZ CJVIi1nJFBYyPlFY5CENUt1W9gkg6PH8ozsnrYOLP4IsMVtiuYVAyqRnOlk8E6yLuU7N w+Kn7eP7bMs/QE5gzik+QGSiCBFteleJKpe6ps6oWw5qM6FdfYa/KeLK7QXWEePQRaIm WCtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0gSd8P93rvKDLe2hdGzrfyOCIhLiQS33lPPOf0NFTws=; b=HAGFNzwEvxR+4kzOszhn/6ljSSdcXZdnO2hUfQmUF/ACKKA4kAMss4MNCNF9hGYhy5 LWnimrYRECYfgaw3cgmSOIOjkK0ww5VnwjbBr5hYf0CCnQ6UvS8sR4rNo+VxsyZankPc gzQmEVHAZVzTPP+sBw3f8bMuJkXsCubo9dqEYXcnYKr0L06f4tQWJXC9kysv9tuyg58u NRphMKJ94Sa8OzI2EQr8W4y+ntb1fQRd+KxFv4LcY4T7Zv5CX98g6rFCN6ZRzBocwiJR XiC4GvRT3kMhDLz96aAA9Rv2Fl8DeMV8qpUufzk226DteY3Ayy9LABSXbGWkTxmomGVr kH6w== X-Gm-Message-State: APjAAAW60pUSNcRlU0yuefwe2XusY2V8PwpkVjJf2kho/kcG6MX6k7Ae ou2N5um5fQ8pHa/X5VmJXZdrxNWZzX7xEjoBMYmm2Kpe X-Google-Smtp-Source: APXvYqzhfvS4RnYsiBczzxIsiQVjOjcN8H0btfzzW9bzM9raUdMlsUbi+UaukREUPF9N1OTkfFHyTKq4GcA7ow7gvIs= X-Received: by 2002:ac2:5503:: with SMTP id j3mr3097903lfk.104.1578495967021; Wed, 08 Jan 2020 07:06:07 -0800 (PST) MIME-Version: 1.0 References: <003401d5c634$3b617760$b2246620$@noctuint.cz> In-Reply-To: <003401d5c634$3b617760$b2246620$@noctuint.cz> Date: Wed, 8 Jan 2020 16:05:50 +0100 Message-ID: To: mdolezal@noctuint.cz Cc: PHP internals Content-Type: multipart/alternative; boundary="00000000000064e2ec059ba23b31" Subject: Re: [PHP-DEV] zend_call_method with arguments passed by reference From: nikita.ppv@gmail.com (Nikita Popov) --00000000000064e2ec059ba23b31 Content-Type: text/plain; charset="UTF-8" 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 --00000000000064e2ec059ba23b31--