Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104362 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 9641 invoked from network); 12 Feb 2019 18:47:10 -0000 Received: from unknown (HELO mail-ua1-f65.google.com) (209.85.222.65) by pb1.pair.com with SMTP; 12 Feb 2019 18:47:10 -0000 Received: by mail-ua1-f65.google.com with SMTP id s15so594937uap.6 for ; Tue, 12 Feb 2019 07:30:04 -0800 (PST) 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:reply-to :from:date:message-id:subject:to:cc; bh=X7GRDwsK7p0WXc8bChFMOCZv3UvOP7uyvq9JaGI62T0=; b=lPQo+FqFiBxAYp2iabIRE/ZOmnwawM2kgXd8bIL/70cf4TDjJtDBlWvn8yFOoQZ7er pTBZvc2lHa+3pqD1a0Y0T+wuJ2Sioiguvqil2e7BY6+azPS9/B/UF0svh3sAfduZJ9Yf vTHP2bKDPmowchMdYoUEfRB3ozh1BMovmFGHMloYA2zM5NjK0eHTRQGx5SDQIYKb060S hLtZoTyGc5wQ2Svu2rWSTGM4VNV9/uY+gR2eFMtbP/jMeQ1QMZ27YN37kOIbs8wMHDbi jD3SmcYF29Cy+gZdpyOcdYh53D25p96UcKKZ4ROMPtiSGnpwkO1HlhHqzLNbA7owYDZO NReg== X-Gm-Message-State: AHQUAuZUUAqkZh1p/Oyf/ZT9vB3iW4OOx0tKZt7prm4wwxNF8qzpLE3S svz1IBGLe6cJI08K8tUtSO09EIYah8YCJgsMCBa/pBJz X-Google-Smtp-Source: AHgI3IZsTqCfutQ2jc4z4jBaAeyBBFaXClG7rnfPXxFewRu0IVfwWCDsX+Z+fvAkYsHPNgiR6XnKRtk2JKSI3baMb9M= X-Received: by 2002:ab0:7048:: with SMTP id v8mr1777966ual.84.1549985404204; Tue, 12 Feb 2019 07:30:04 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Reply-To: bishop@php.net Date: Tue, 12 Feb 2019 10:29:38 -0500 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000006cc0a40581b419e1" Subject: Re: [PHP-DEV] Convert ext/xml to use an object instead of resource From: bishop@php.net (Bishop Bettini) --0000000000006cc0a40581b419e1 Content-Type: text/plain; charset="UTF-8" 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 --0000000000006cc0a40581b419e1--