Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:104361
Return-Path: <nikita.ppv@gmail.com>
Delivered-To: mailing list internals@lists.php.net
Received: (qmail 99975 invoked from network); 12 Feb 2019 18:17:28 -0000
Received: from unknown (HELO mail-it1-f178.google.com) (209.85.166.178)
  by pb1.pair.com with SMTP; 12 Feb 2019 18:17:28 -0000
Received: by mail-it1-f178.google.com with SMTP id g85so7847182ita.3
        for <internals@lists.php.net>; Tue, 12 Feb 2019 07:00:23 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=mime-version:from:date:message-id:subject:to;
        bh=3vBng+LL/czwFk+JsGUa1IuwzYMx7XKIwPj7X6msGX8=;
        b=ugBzS0lnwNP5n200/zJSC74IlLn+5XvQFM63Q5GpOfE99/7J8S3YT8uMk37NUjRB7s
         KNUSBZmHRY5jcWgnbEHgugqHGWVb9d2eCIja5gBFJneBOXEyLhSGlwysh/tMcZuBlxbU
         klFW3R9//BCOD159VjVCyf/5kFmsyIwLZpKuLwxEGd/fh/G+hRlJ8d4aYD7X+re6GHpJ
         DSI3GworlrqSxk80y7Wrl/jP5G/2QqsYwwWCZtvpucrRrXu3Fll2Q+1zWDymUlM5PckM
         FlUZjuNH0eAEimg4uxTtmBLgBFybneFyJCee0L9Yh46wKdw4NqZ6Fyfm4WG53Q0N+8x/
         xyaA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
        bh=3vBng+LL/czwFk+JsGUa1IuwzYMx7XKIwPj7X6msGX8=;
        b=c3AciHBIiDYldMEQh488NsxTrPmPwiyhcTllfS4AZLpWt7DlkCslF820SSUSBRn4vd
         xso5rT7SOfMvN+VZ86fRXQC6GzESpJygWQVyk5tNF5kwuGTCgGzxN2VUFjoJBNjP7g8V
         OefVvS9qqUpfd7KtI3oh342EWQbKnDG5rnYg4mUhYaMtsQWLEzQNKEWKF8tAsncIx4Kj
         3x7k8pzMFYxThwVpN4QFN+pSqM3KeyhhZfCmfCb0lU9Z1Gvvv/xGlrTXHlXrZAlFKJ7C
         gd2su5qfj932kY/X9pejqMplMr5ErPqm8d5v4mGcdoekXYabzTHcF/0k2eAs/9WZd/2K
         Qs/A==
X-Gm-Message-State: AHQUAuahg+Mm9n54TnOuDKJ03OmNIYh01wNup2GR+EYXac2Ws3stIW6F
	hTQDIqTBBJ880/2elWU256CMHxjJU9gCXsa9AcKMFUgr
X-Google-Smtp-Source: AHgI3IYF+ApO2fW11RRZ4OQlk695rOuRiMpQM9aEYnFqbyEQD+b8z0oNEE6rpD2H1x0OY4ADj3YUC6fxHqlyD1LudVw=
X-Received: by 2002:a05:660c:81a:: with SMTP id j26mr2035643itk.70.1549983622392;
 Tue, 12 Feb 2019 07:00:22 -0800 (PST)
MIME-Version: 1.0
Date: Tue, 12 Feb 2019 16:00:06 +0100
Message-ID: <CAF+90c-q631w16DahA9bZPWyZPtYMaA0yB+vvKLxKi3AApUQDg@mail.gmail.com>
To: PHP internals <internals@lists.php.net>
Content-Type: multipart/alternative; boundary="000000000000386f130581b3af47"
Subject: Convert ext/xml to use an object instead of resource
From: nikita.ppv@gmail.com (Nikita Popov)

--000000000000386f130581b3af47
Content-Type: text/plain; charset="UTF-8"

Hi internals,

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).

Any thoughts?

Regards,
Nikita

--000000000000386f130581b3af47--