Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104369 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 31282 invoked from network); 12 Feb 2019 19:35:06 -0000 Received: from unknown (HELO mail-it1-f171.google.com) (209.85.166.171) by pb1.pair.com with SMTP; 12 Feb 2019 19:35:06 -0000 Received: by mail-it1-f171.google.com with SMTP id o131so5206943itc.5 for ; Tue, 12 Feb 2019 08:18:01 -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=9ofugiHdl7Mu6Rart2vq6MygGJxJCWB6INCsiIvlF+A=; b=DxzunYmpjoSyNiNBfEDMDLICvwCPB3Yy+xN3Qk4Chv6fxkzG+y+gXULpFogFTNdB53 nUcceMNDWY2dE4Tmd9CK41L85AfLbCXNBHMsV3kHeZJ+R69ZThdKEmF428ftyB3ABMdN 9s6TkgJ++/ygfcHpu/XAtBUMHqZzqhIcJI6unvonvYKw6us0f1JLf/bMyHoXFPYiTKsh pGwweYNZTXKTaXbBEfBRxDrEQPP0jo7cgbTST8dTlE2Wye4gxvXWgI6H7vz2ENoVXVNS 1jhl4bjMOiCRTvfSJIf+Y7brauGgLh3KTmkMERT9L0k0XAwdHlLHWcN0Ozu1BmniOUyL AKBg== 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=9ofugiHdl7Mu6Rart2vq6MygGJxJCWB6INCsiIvlF+A=; b=I93r1s79jytEScCsBAQgMcujW0ZCsN7rJCiatV8SujFqACa5gIjLbJ3EDeJVSIalRz 51S2DJMC3RQmcPhqjUy6a2rlTrDduOTNUgXqrWRn7whheXl4Dka6S/CxK+rZwKlL07LT e1Vc9TzZHaZGiCVHTgM/Dlacm1h6ho/P2uFFPrKmNX1lvLOKQ08vqy7HYD3bsPElKg04 HBO0M//ltZx8xXx8c9nJ8vxyNzt4qfvDJp8B2jp76++GZ+MqzEk9R+3MPaK+71OPKjHU Pa8aMOHbPxh3ZtjQ3fAjs+1kO8YAbVsvy70K2hliv+U11Mc/tL6AuutJvgvJ7CUWc7yT EmxA== X-Gm-Message-State: AHQUAubuC6FsQgrTF53N7yFd7Je5nEdf/yKDXsXZomcDqYD9sWwivhiY CRNAAlORibr6N2/nGfnOjDg0aYYabhXaDgoJfFKVOw== X-Google-Smtp-Source: AHgI3IbOR767Q3WeGzveuiL98qPbAcZVTDLzvP6R0FgMrPj/isOayN+pBFZ/pvi1Iqa3ghvmCg5cgLFYpmHG0h3c9nQ= X-Received: by 2002:a5d:91d3:: with SMTP id k19mr2451176ior.258.1549988279430; Tue, 12 Feb 2019 08:17:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 12 Feb 2019 17:17:42 +0100 Message-ID: To: Bishop Bettini Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000cd381f0581b4c430" Subject: Re: [PHP-DEV] Convert ext/xml to use an object instead of resource From: nikita.ppv@gmail.com (Nikita Popov) --000000000000cd381f0581b4c430 Content-Type: text/plain; charset="UTF-8" On Tue, Feb 12, 2019 at 4:30 PM Bishop Bettini wrote: > On Tue, Feb 12, 2019 at 10:00 AM Nikita Popov > wrote: > >> The ext/xml extension currently has GC issues, see >> https://bugs.php.net/bug.php?id=76874. The tl;dr is that uses of >> xml_parser >> will usually result in a cyclic structure, but resources do not support >> cycle GC. This means that the user is required to take care of breaking GC >> cycles manually, which is very unusual for PHP. > > >> I would like to port the xml extension from using a resources towards >> using >> an object, which is fully GC integrated. This is implemented in >> https://github.com/php/php-src/pull/3526. >> >> An XmlParser class is used instead of a resource. The class is final and >> cannot be manually constructed. It is still used with the normal >> xml_parser_* APIs. This is intended as an internal representation change, >> not a conversion to OO APIs. The xml_parser_free() method becomes >> effectively a no-op and may be deprecated in some future version. >> >> This change is intended for PHP 7.4. While it is technically BC breaking >> (in that code that goes out of the way to use is_resource or similar may >> break), but we've done a couple of these resource->object migration in >> minor versions in the past (ref >> https://wiki.php.net/rfc/operator_overloading_gmp and >> https://wiki.php.net/rfc/hash-context.as-resource). >> > > +1 for movement away from resources, generally. > > Resources represent connections to external resources, in a manner that's > opaque to userland [1]. Would it make sense to update is_resource (and > friends) to be aware that "resources" returned from xml_parser_* are not > resources proper, but rather resources nominal? > > If userland needed to strictly determine what was a resource proper and > what was a resource nominal, we could improve the signature: > is_resource(mixed $var, bool $strict = false). But, honestly, the > aforementioned opaqueness makes me think this wouldn't be necessary. > > [1]: http://php.net/manual/en/language.types.resource.php > Very much opposed to any kind of special handling for is_resource(). We used to do this for is_object() and __PHP_Incomplete_Class and I'm very happy to be rid of this special behavior. Let's not add is back in a new place. Nikita --000000000000cd381f0581b4c430--