Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:95018 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41075 invoked from network); 10 Aug 2016 17:34:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Aug 2016 17:34:57 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@fleshgrinder.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php@fleshgrinder.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fleshgrinder.com from 212.232.28.122 cause and error) X-PHP-List-Original-Sender: php@fleshgrinder.com X-Host-Fingerprint: 212.232.28.122 mx201.easyname.com Received: from [212.232.28.122] ([212.232.28.122:58501] helo=mx203.easyname.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 62/81-32735-FB56BA75 for ; Wed, 10 Aug 2016 13:34:56 -0400 Received: from cable-81-173-132-156.netcologne.de ([81.173.132.156] helo=[192.168.178.20]) by mx.easyname.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bXXP2-0007C5-JT; Wed, 10 Aug 2016 17:34:52 +0000 Reply-To: internals@lists.php.net References: <9e9c440e-05d2-a452-556e-a6c62a9f195e@gmx.de> To: "Christoph M. Becker" , Nikita Popov Cc: PHP Internals List Message-ID: <208237ee-a22a-97b7-be63-f7cba986b137@fleshgrinder.com> Date: Wed, 10 Aug 2016 19:34:44 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <9e9c440e-05d2-a452-556e-a6c62a9f195e@gmx.de> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="bAAdf22Dqf6EJ0Hh80tsBtLtDgPvx49CF" Subject: Re: [PHP-DEV] GC issue wrt. to resource <-> object cycles? From: php@fleshgrinder.com (Fleshgrinder) --bAAdf22Dqf6EJ0Hh80tsBtLtDgPvx49CF Content-Type: multipart/mixed; boundary="I3HPHcKC78OVKDqttw85nWpXe2vB8ks7v" From: Fleshgrinder Reply-To: internals@lists.php.net To: "Christoph M. Becker" , Nikita Popov Cc: PHP Internals List Message-ID: <208237ee-a22a-97b7-be63-f7cba986b137@fleshgrinder.com> Subject: Re: [PHP-DEV] GC issue wrt. to resource <-> object cycles? References: <9e9c440e-05d2-a452-556e-a6c62a9f195e@gmx.de> In-Reply-To: <9e9c440e-05d2-a452-556e-a6c62a9f195e@gmx.de> --I3HPHcKC78OVKDqttw85nWpXe2vB8ks7v Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 8/10/2016 4:17 PM, Christoph M. Becker wrote: > On 10.08.2016 at 12:59, Nikita Popov wrote: >=20 >> The simplest way to fix ext/xml in particular is probably to migrate i= t to >> use an object instead of a resource. >=20 > I guess that is the best action in the long run (i.e. 7.2+), but that > would of course cause a BC break, so probably it's best to document tha= t > the user has to break the cycle manually, if xml_set_object() is used > (7.0, 7.1). >=20 > Wrt. to PHP 5.6 it appears there are no issues at all. While the code > out-commented by Thies is still there (which should be removed to avoid= > further confusion), in the following a (shallow) copy of the object is > made, and apparently due to the additional refcount in the object store= > of PHP 5, everything is okay. >=20 > Another alternative for PHP 7.2 might be to drop (after deprecation) > xml_set_object(); actually, it seems to me this function is a relict of= > pre PHP 5. Cf. example #1[1]. Instead of doing: >=20 > xml_set_object($this->parser, $this); > xml_set_element_handler($this->parser, "tag_open", "tag_close"); >=20 > one could simply do: >=20 > xml_set_element_handler($this->parser, > [$this, "tag_open"], [$this, "tag_close]); >=20 > [1] > >=20 It does not have to be a BC if we simply introduce a new API for this extension and keep the old one as is. The whole set of functions just cries out loud for a class that encapsulates the state of the parser and both the utf8_* functions simply do not belong in this extension. This new API can be introduced in any PHP minor along with a deprecation and removal (move to PECL and abandon) of the resource based things in PHP 8. --=20 Richard "Fleshgrinder" Fussenegger --I3HPHcKC78OVKDqttw85nWpXe2vB8ks7v-- --bAAdf22Dqf6EJ0Hh80tsBtLtDgPvx49CF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJXq2W4AAoJEOKkKcqFPVVrKhkP/ikF1vqEhFUnREuKXka91MUS hYJ/dJ4rcCm/lnTffPpVRpP9FJqXy8UJDjyS/qnvr41OkSdPJpnCfJChS4sL+brU Df6bqRSM5vhsddrJYtAZq4L2VfyCoB6Mcn3stmht2tF4mwnt4SxFwOvlBMVJJ8rB q4Bx6ubxrQWIQegs4614KrMUPJqV8QSojsWNbcFoPriiYQqWLFPtC0m1o69z66nj PEvS71Y6DV/ToE/kQynTtv+9mespqWYw0MNSTejQy/wdLCJEOQMQpacMoS+pORoD xOC9ORUL2r5avDKjZWZJttcOFvEhXr93JCmYdHNMVqgA5ed3aQctII4ayWcGuGzH aUvRsJMcaJRXBjfnCD3ehqm8yi7xR5Q832xdT2MuMlKuIgjycU6+THlD8rycrfXy O7lBfMPDO/5znFBNYoLWgO5VpVv3Xb86u9QuxA9NGGmawwUpNuJQaUhl/ZY3Cad7 VK12yu4IJQWF9UoonOXSgJhpVXQvkITHS0k7c4TR4p4KX1ukm+GQlxzH7h/WwQ9Z HH+W+NhYKIcQpNuTvo5x3nHJ7tDJoD7nimdGZVGX1hKgeC/P8p1QPhJ5B6G/MVPU +QldNUxVSdPuwVPsbuzaThygKmdgJu978nRTyGZAVJ7uPvNC6RfH85gh7Dw5lwSx Np3PFQB2ALIY1aCFlU4a =j18p -----END PGP SIGNATURE----- --bAAdf22Dqf6EJ0Hh80tsBtLtDgPvx49CF--