Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:125452 php.internals:125453 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 qa.php.net (Postfix) with ESMTPS id 429581A00BD for ; Fri, 6 Sep 2024 18:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1725646161; bh=HiN2BHU90TAVDFDSO3KQaln3Mc8G0UGIjRR11eGbslg=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=kbFTKL0uUXejjFN/nKo5LcWT6oPb6Lrz+DFkh20r58w/npvfvR3fX+vlyOjTQHCW0 QSKjjz4n9XsvLIDYdb6L/h/1rHEi4/gZzBZdEBoejUvGMEcTe8xF5QqHHE97coOH6r hNX9y5XbuJcWEyP2c3M6Jc2Yl0zWuuM2/GuXggEiM1CFwVYzHbeFXhDoVRj+U/AKC3 +9O73Cq910wqyhvNelZkwrFEkJpAbf97R2uEnJ66iDF1hsvf2lvbtmMx2hIPMREHWK t28BKE97HDUupRTgh+9z4oz9Lk+B21SqyaRbppDMs/tWRaJwPH9jfGZWf3pd4Ui3+X 9kQLijuq49v3g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4F8DC180078 for ; Fri, 6 Sep 2024 18:09:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 ; Fri, 6 Sep 2024 18:09:20 +0000 (UTC) Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a8a6d1766a7so245636766b.3 for ; Fri, 06 Sep 2024 11:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725646040; x=1726250840; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=/vsd2MPhp6exR5UETHT0xkVQcsy8LBITCA+sKNQnpYM=; b=LHe67QL7HsynAelbYlOJTG2nHe21M68hkgurjyguKdGCZ12zMaGulOJWLvNHgdrjIL 2MXsXb0kR6jA4K5GfPb5AmQwAN7qJ0GDwDMwqlr7n33l9auDhVSaOR7G3tFqHEfR0aaF SsJNt1ITTs5wDm+Z6IGbpDj0wvOdy/GR+auCwmmsa6DaRMyemyXyfYUTzhPPtcWKIFur +uuten7+8CUr/xce1F/uE4L3TnglPVZ6F8bVx24tDaHUDatbgLygwczV9HcfJ+4SYATt jze3UFH7w+sk+vHGDoH6o/yFc57xeQkojEzaLG7PD8lGWdaVN8nmIyxgEZMpqw4cgEzR xFJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725646040; x=1726250840; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/vsd2MPhp6exR5UETHT0xkVQcsy8LBITCA+sKNQnpYM=; b=Pz6EQ4cVadoKePVF5VNCAZFPND6JLx2MzoG+ASVmBl7VP812OKVCIfUiAJAjDpYzXf 9VZpYE8yzosI2mxyzO0G+jGPwYe8DsWblbivIYV8Wf0ZulqH53VmYKcid9/2jYHqksjt Ht8DxmEvWmST4uOsf+NvtwA1POvtuBqjZ2tJHeKVVVdH8+7WBd8N5L1JU1TnJ6wgsjN/ e0ALYDcvmG0JWd3x/QiKVCHEtmfAkJu8IhIJHgcQlHcjhaM1mw0YaXGsnMhOLRXx7z37 DijXnuI6HDtOHIW/mneB0TXpWsTIqr1WwQ5w0eFGKG6c55XpKTv42aUHiD7KSMAZ+o71 aUhg== X-Forwarded-Encrypted: i=1; AJvYcCX4A7b/lP/sIJMYCHw9prNLRCYroX9p6p9/HDXpYX3kCfx1Apq8Z5UursBW2ZjFQn9oQRi+ZAWCH0s=@lists.php.net X-Gm-Message-State: AOJu0Ywjk+sbiSdhLPAzntDsTBke9Zj/dz0BGDS3f+hOftndDjmDrnXQ Ps0eDfYaO/YD9uNY5vSlTJ2KO8ep/Z+pTIQ33V8q9IjG9e8VyF6BR7xg1w== X-Google-Smtp-Source: AGHT+IG07AZlqHWprlf8pbS3SGvKd0W6BxY3+xx+0OI5MLOEnh+KUQeWz72KyUA9ohWlMpWZD0bqiA== X-Received: by 2002:a17:907:25c8:b0:a8a:86a9:d6e2 with SMTP id a640c23a62f3a-a8a8866c0bemr283723566b.37.1725646039934; Fri, 06 Sep 2024 11:07:19 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8a8143c981sm166688966b.191.2024.09.06.11.07.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Sep 2024 11:07:19 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_C17DB746-EEEF-4C38-A33A-37CC95F6E9ED" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: Re: [PHP-DEV] RFC: Deprecate json_encode() on classes marked as non-serializable Date: Fri, 6 Sep 2024 20:07:07 +0200 In-Reply-To: <98553A91-FD3F-4E1B-91D9-D8B00CAD5FC5@getmailspring.com> Cc: Philip Hofstetter , PHP internals To: John Coggeshall References: <98553A91-FD3F-4E1B-91D9-D8B00CAD5FC5@getmailspring.com> X-Mailer: Apple Mail (2.3776.700.51) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_C17DB746-EEEF-4C38-A33A-37CC95F6E9ED Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 5 sept. 2024 =C3=A0 18:03, John Coggeshall a = =C3=A9crit : >=20 >=20 > As per my previous email to the list, I have now created the official = RFC to deprecate calling json_serialize() on instances of classes marked = with ZEND_ACC_NOT_SERIALIZABLE. >=20 > I would suggest we take a step back from this and look at it with a = bit more of a wider lens. It seems to me that this would be a good place = to have an attribute (e.g. #[NotSerializable] ) that could be defined = for any class (with ZEND_ACC_NOT_SERIALIZABLE being automatically given = this attribute)? It just seems to be a more holistic approach that makes = sense, rather than basing it on internal engine stuff and/or limiting it = to internal objects. >=20 > Coogle >=20 >=20 Hi, An attribute adds very little value. It doesn=E2=80=99t add new = capability, because you can achieve the same effect with a serialiser = that throws unconditionally; it is just a nicer syntax. People generally = don=E2=80=99t bother making their classes unserialisable unless they = have a good reason; having an attribute won=E2=80=99t really change = that. The core problem is that objects are json-serialisable by default, = although most of them are not supposed to be json-serialised. Taking a = second step back, if we really want to solve the issue, one should: * for internal classes, determine which ones could be json-serialisable = (at least, stdClass); for all other classes, `json_encode(...)` shall be = disabled (after a deprecation period); * for user-defined classes, the user shall opt into = json-serialisability, either by extending a json-serialisable class, or = by using an {attribute / magic method / interface} (chose your bikeshed = colour). =E2=80=94Claude --Apple-Mail=_C17DB746-EEEF-4C38-A33A-37CC95F6E9ED Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Le 5 sept. 2024 =C3=A0 18:03, John Coggeshall = <john@coggeshall.org> a =C3=A9crit :


As per my previous email to the list, I = have now created the official RFC to deprecate calling json_serialize() = on instances of classes marked with = ZEND_ACC_NOT_SERIALIZABLE.
<= div class=3D"gmail_signature">
I would suggest we take a step = back from this and look at it with a bit more of a wider lens. It seems = to me that this would be a good place to have an attribute (e.g. = #[NotSerializable] )  that could be defined for = any class (with ZEND_ACC_NOT_SERIALIZABLE  being = automatically given this attribute)? It just seems to be a more holistic = approach that makes sense, rather than basing it on internal engine = stuff and/or limiting it to internal = objects.

Coogle



Hi,

An attribute adds very = little value. It doesn=E2=80=99t add new capability, because you can = achieve the same effect with a serialiser that throws unconditionally; = it is just a nicer syntax. People generally don=E2=80=99t bother making = their classes unserialisable unless they have a good reason; having an = attribute won=E2=80=99t really change that.

The = core problem is that objects are json-serialisable by default, although = most of them are not supposed to be json-serialised. Taking a second = step back, if we really want to solve the issue, one = should:

* for internal classes, determine which = ones could be json-serialisable (at least, stdClass); for all other = classes, `json_encode(...)` shall be disabled (after a deprecation = period);
* for user-defined classes, the user shall opt into = json-serialisability, either by extending a json-serialisable class, or = by using an {attribute / magic method / interface} (chose your bikeshed = colour).

=E2=80=94Claude




= --Apple-Mail=_C17DB746-EEEF-4C38-A33A-37CC95F6E9ED--