Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128466 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 3CBBF1A00BC for ; Wed, 13 Aug 2025 15:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1755099159; bh=vr70Gf7FoM1LvvnqzKDOobloqq+uu2JJtGN5Io/gPOc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MApa38I+aEK+FxrN8JF1NzhukEFwy3VFcYNMdCTL6QB7PXhYOIK+AcUXT6unSvCY4 jclVwsQiB43FQogxcjBbBDi2Rd0UO88NFvFGHGyd5JlAKMw+ZeRzzuxPhlN0UWk5Do rZWOd6385YNDMVNcOzc9/J6KVNrGY97lNMhntWVzCHkz3YRV3aFy0X2g++TIR0479J 4qcdvVK4fv2XKqYXkS3VdDwmt+YGmKDVzff4d62KIIlkf1NFC48Q22PHjnqqvUSg0q 13wsEK6/kH08KLzWv4nMsWsqqTToO3Ajy2TPwCig5d2Dd/lxOxwOmNUi9wrBH8s947 3dUujScsoschQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AA21D18005C for ; Wed, 13 Aug 2025 15:32:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 13 Aug 2025 15:32:38 +0000 (UTC) Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7e8248b3f1cso820136085a.0 for ; Wed, 13 Aug 2025 08:34:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755099255; x=1755704055; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WhPlvS+chdqsLknf/IjLPIHqK7Dxbvar09lN3/MTEzY=; b=IzJCqsRxAXwPhjvu4a8hp/S64ZzCkRG9uhBrminAXA5i0yPA1R2SUaB2h3FooXC04n ThOIAuRG5ReumvLXMw6TYXGFHgfrD3jAxl8QgoajdgrkYwNipNYIoHwaxd94MrLeKOjH SbbSMVHU0cj0ZtJesw/uvpgV0A9J7MdTvVYJ+QFquqA58/GcsDtbAXp1Bxrw3JrgaNZv EO+wkU8KBQYsXlS6/xibgF1S2W7k/gEO3cLUo5oFm4hx9szSNFX6LWZq2VAWcK+emKgZ kNYGUaLDOpHviPcT0mUkZ2Ho3W2x04G5vnOurcAQu7UjRQ9HoRGiEhLi81QBtkczIQBx YWPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755099255; x=1755704055; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WhPlvS+chdqsLknf/IjLPIHqK7Dxbvar09lN3/MTEzY=; b=E5y9TkyCKBWtJUQzg0l9kTRGMz/SLOl9Jg7XHkVQKWtoo70JsizAYr9YJcXfVUxp9B CfVV21EZ7LVLcUvMiH0w48yxu14xZFvNpuyLloUdEePYOM7SHH2X+/bjawIIvDmYqi6B pZtM4G18M/g9xYbqcQYxseBCrLGWNDH5UWTkKkPWauGasyX6KysYpMFdKbu3nlkhSUVk R4irCzMVoSM+VxYn9eLzKW7903PdIyahczjByl8wMwU5tVbLK1DUde65eecoUW88Kqu1 F2Mp/OoKujsoWmFLEk4gt5P4Vsvso4FrImdgVDP22L4tHBfzPzarBgHmb/2t9wSDSGhL J1zg== X-Forwarded-Encrypted: i=1; AJvYcCUl1BQMi/KuapRAH0p2l/vTs8G4Ao0Q8PrChgJydI0qUL/8v6KrsJ6tPmJMWTGh4TqYbV/kB9cArBY=@lists.php.net X-Gm-Message-State: AOJu0YzYSwLXcQjaFWhIsoCoJxiytpRlYejbecKi59zavqzRcru7sB2q p8QsX8qRQKcTzWp9I60sS+RxAONffPiQXta9ycsnzKBlzPLfKnT0C+Go9YcS9WdVgikeSoekNRc qftm6ylvAOuj0uCB0ufcV1p0KN0oxB9Y= X-Gm-Gg: ASbGncs0ZYpKsJNZKe4LrtliV8QfPMd7gEQAqZWpNbINamrLPKPU0+LmdbgShJOMQA2 2VZ87P3yBy0n9LCWoSbUJkrBaPL6ccI+05Z/9N2F/a6F94vUbCXvSXKLEcjwQR7TntyfifIQK3x Ki8l/nBkImMXFtuNQoilK+bhoBhC0eDJ7nWplUrdPEkf1rcp4bDdLlWgclbnx+VrXdaG8Cg1wLn i6fscXRnT8naWh5S6SpcIX4Qekx6MmXCSbkeghadg== X-Google-Smtp-Source: AGHT+IFthJFUOjzSwY2OIyQ6VccSWdhLFYUDxuyX1spC+mm8nw2e+F3rRxdOp8H8NM7WNvy/ASHmvAT5JRfZWJtiy8M= X-Received: by 2002:a05:620a:4444:b0:7c5:3d60:7f91 with SMTP id af79cd13be357-7e865274335mr552353885a.15.1755099254753; Wed, 13 Aug 2025 08:34:14 -0700 (PDT) Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 13 Aug 2025 17:34:02 +0200 X-Gm-Features: Ac12FXy1sVGbbIdwk2iKW75Q0W4lGIUykVCOBwjoD1apAGI2J8S_4xqmqLCGgXk Message-ID: Subject: Re: [PHP-DEV] [RFC] [VOTE] Deprecations for PHP 8.5 To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: Kamil Tekiela , "Christoph M. Becker" , "Gina P. Banyard" , PHP internals Content-Type: multipart/alternative; boundary="000000000000a01130063c40e3e9" From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000a01130063c40e3e9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le mer. 13 ao=C3=BBt 2025 =C3=A0 14:33, Tim D=C3=BCsterhus a =C3=A9crit : > Hi > > On 8/13/25 13:58, Nicolas Grekas wrote: > > I wish we had some process to revert that decision. Now is the less > costly > > time to do it, even if it's already late. > > There is always the option of =E2=80=9Dnot implementing=E2=80=9D the deci= sion. Reverting > would mean another RFC that would also require a 2/3 majority. > I'm happy to do it this way if that's the consensus. > > The discussion period failed to raise the points made by Jakub in the P= R > ( > > https://github.com/php/php-src/pull/19435) and failed a serious impact > > analysis IMHO. > > This should be enough to raise a flag and allow us to reconsider. > > I wonder if people that voted in favor of deprecating __sleep/wakeup > would > > still vote the same now? > > I already participated in the PR discussion and having slept over it, I > think it would be helpful to consider both __sleep() and __wakeup() > separately in this discussion of whether or not to actually follow > through with doing the deprecation. > > As I've mentioned in the PR, `__sleep()` is actually broken when > inheritance is involved and there's also a trivial way to implement > `__serialize()` while preserving compatibility: > > public function __serialize() { > return get_mangled_object_vars($this); > } > Well, the way to introduce __serialize while maintaining compatibility with both child classes and existing payloads is to copy/paste the same boilerplate over and over: public function __serialize(): array { $data =3D []; foreach ($this->__sleep() as $key) { $data[$key] =3D $this->$key; } return $data; } And then, this has exactly the same issue regarding private properties, without any better way since this has to call __sleep to account for child classes. This is just moving the concern elsewhere without any benefit. On their side, child classes that do have an issue with private properties can already implement __serialize on their side, there's nothing to fix here: __sleep works well, and there's already an upgrade path when it's not enough. > So while this one might result in some amount of migration work, it's > reasonably easy to do. > > `__wakeup()` on the other hand is not broken and migrating to > `__unserialize()` is non-trivial. > > So deprecating `__sleep()` with PHP 8.5 still makes sense to me. For > `__wakeup()` I don't have a strong opinion either way and I've also > intentionally abstained from voting on this deprecation. > implementing __unserialize to satisfy a proper upgrade path for payload and child classes might be done this way: public function __unserialize(array $data): void { foreach ($data as $key =3D> $value) { $this->{("\0" =3D=3D=3D $key[0] ?? '') ? substr($key, 1 + strrpos($key, "\0")) : $key} =3D $value; } $this->__wakeup(); } Again, this doesn't work with private properties. The previous code was better and safer, and contained less boilerplate. I made a draft PR for SYmfony here: https://github.com/symfony/symfony/pull/61407 I'm not sure the implementation is correct yet. That's just to show the kind of impact this could have. Deprecating only sleep and not wakeup would at least fix the complexity of the __unserialize replacement. But then, this would fail the purpose of the RFC, which was to get rid of sleep/wakeup altogether. This deprecation is a net loss on every aspect. Nicolas --000000000000a01130063c40e3e9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Le=C2=A0mer. 13 ao= =C3=BBt 2025 =C3=A0=C2=A014:33, Tim D=C3=BCsterhus <tim@bastelstu.be> a =C3=A9crit=C2= =A0:
Hi

On 8/13/25 13:58, Nicolas Grekas wrote:
> I wish we had some process to revert that decision. Now is the less co= stly
> time to do it, even if it's already late.

There is always the option of =E2=80=9Dnot implementing=E2=80=9D the decisi= on. Reverting
would mean another RFC that would also require a 2/3 majority.

I'm happy to do it this way if that's the c= onsensus.

=C2=A0
> The discussion period failed to raise the points made by Jakub in the = PR (
> https://github.com/php/php-src/pull/19435) and fai= led a serious impact
> analysis IMHO.
> This should be enough to raise a flag and allow us to reconsider.
> I wonder if people that voted in favor of deprecating __sleep/wakeup w= ould
> still vote the same now?

I already participated in the PR discussion and having slept over it, I think it would be helpful to consider both __sleep() and __wakeup()
separately in this discussion of whether or not to actually follow
through with doing the deprecation.

As I've mentioned in the PR, `__sleep()` is actually broken when
inheritance is involved and there's also a trivial way to implement `__serialize()` while preserving compatibility:

=C2=A0 =C2=A0 =C2=A0public function __serialize() {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return get_mangled_object_vars($this); =C2=A0 =C2=A0 =C2=A0}

Well, the way to = introduce __serialize while maintaining=C2=A0compatibility with both child = classes and existing payloads is to copy/paste the same boilerplate over an= d over:

=C2=A0 =C2=A0 public function __serialize(= ): array
=C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 $data =3D [];=C2=A0 =C2=A0 =C2=A0 =C2=A0 foreach ($this->__sleep() as $key) {
=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $data[$key] =3D $this->$key;
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return $data;<= br>=C2=A0 =C2=A0 }

And then, this has exactly the = same issue regarding private properties, without any better way since this = has to call __sleep to account for child classes.
This is just mo= ving the concern elsewhere without any benefit.
On their side, ch= ild classes that do have an issue with private properties can already imple= ment __serialize on their side, there's nothing to fix here: __sleep wo= rks well, and there's already an upgrade path when it's not enough.=

=C2=A0
So while this one might result in some amount of migration work, it's <= br> reasonably easy to do.

`__wakeup()` on the other hand is not broken and migrating to
`__unserialize()` is non-trivial.

So deprecating `__sleep()` with PHP 8.5 still makes sense to me. For
`__wakeup()` I don't have a strong opinion either way and I've also=
intentionally abstained from voting on this deprecation.

implementing __unserialize to satisfy a proper upgrade pa= th for payload and child classes might be done this way:

=C2=A0 =C2=A0 public function __unserialize(array $data): void
= =C2=A0 =C2=A0 {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 foreach ($data as $key =3D&g= t; $value) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $this->{("= ;\0" =3D=3D=3D $key[0] ?? '') ? substr($key, 1 + strrpos($key,= "\0")) : $key} =3D $value;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 $this->__wakeup();
=C2=A0 =C2=A0 }
<= div>
Again, this doesn't work with private properties.

The previous code was better and safer, and containe= d less boilerplate.

I made a draft PR for SYmfony here:=C2=A0= https://github.co= m/symfony/symfony/pull/61407
I'm not sure the implementat= ion is correct yet.
That's just to show the kind of impact th= is could have.

Deprecating only sleep and not wake= up=C2=A0would at least fix the complexity of the __unserialize replacement.=
But then, this would fail the purpose of the RFC, which was to g= et rid of sleep/wakeup altogether.

This depre= cation is a net loss on every aspect.

Nicolas
=
--000000000000a01130063c40e3e9--