Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121972 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50675 invoked from network); 9 Dec 2023 16:01:12 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Dec 2023 16:01:12 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9B4B9180003 for ; Sat, 9 Dec 2023 08:01:26 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mx1.dfw.automattic.com (mx1.dfw.automattic.com [192.0.84.151]) (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 ; Sat, 9 Dec 2023 08:01:26 -0800 (PST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mx1.dfw.automattic.com (Postfix) with ESMTP id 5AD3F1DB564 for ; Sat, 9 Dec 2023 16:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; h=x-mailer:references:message-id:content-transfer-encoding:date :date:in-reply-to:subject:subject:mime-version:content-type :content-type:from:from:received:received:received:received :received:received; s=automattic1; t=1702137666; bh=r0dtq1OulXXQ G0TF7CpfdTP2LRqjxeQHwuCH9RHqTDY=; b=gfA5IsjGDAgdwiVkaZ0OW8Y8vtYz 8KbnN4nPjalKqt/fR4O/HMpcDpE7wKBXTSIpuxv7zGUx+/MlfDu1ScJvR6sS6fzK VCtiUj+9g+6XiOtTTJ+1DOeXiOCLvZ0lEWBSevWwpxn4fTpOUqPqFblWfrbCPqWe GzcZSsOihn/20H3RPzOoDqXejVOs9PK5u6IkUcwtau9MJb39+4RtAgrc4HTyLxrD xQnUN/ahCuZANJRwwpdeJ6fzOLUAWpzb+zUg8ZW1X/HjOqPeDytrE6gSAO9HENwr Mk3jzVcUpt6db8Ya1rILROcYhwsLykZd2cca1sKv5KR/xMxQujNK9jKM1w== X-Virus-Scanned: Debian amavisd-new at wordpress.com Received: from mx1.dfw.automattic.com ([127.0.0.1]) by localhost (mx1.dfw.automattic.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EOs-EGT1Nmkl for ; Sat, 9 Dec 2023 16:01:06 +0000 (UTC) Received: from smtp-gw.dca.automattic.com (smtp-gw.dca.automattic.com [192.0.97.210]) (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 mx1.dfw.automattic.com (Postfix) with ESMTPS id EEE641DB51F for ; Sat, 9 Dec 2023 16:01:05 +0000 (UTC) Authentication-Results: mail.automattic.com; dkim=pass (2048-bit key; unprotected) header.d=automattic.com header.i=@automattic.com header.b="foNvlcg7"; dkim=pass (2048-bit key; unprotected) header.d=automattic.com header.i=@automattic.com header.b="dUa4mfP/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=automattic.com header.i=@automattic.com header.b="jsUXsHUS"; dkim-atps=neutral Received: from smtp-gw.dca.automattic.com (localhost.localdomain [127.0.0.1]) (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 smtp-gw.dca.automattic.com (Postfix) with ESMTPS id 92969A094E for ; Sat, 9 Dec 2023 16:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; s=automattic2; t=1702137665; bh=r0dtq1OulXXQG0TF7CpfdTP2LRqjxeQHwuCH9RHqTDY=; h=From:Subject:In-Reply-To:Date:Cc:References:To:From; b=foNvlcg7ei3mn/yOJW2J41FvJyPCOAgUMNNNkI/RJlOcy+YVTtO2k7GsPiMEnvAsb SCMlwv51AJGWDQE8YCI0UXTeEMVm3bwF+6JM8zN8a6qnvsSUjGnMHZP1s1DFK8e/R/ NRLXeuvDlKfPpl94cPNefFJNNcrCPF090jlxERYjueDhPiPLd84EUsBpBqbC8P3PRU /l3QDmVl5OBC5jKoRmGxaH3KE4VshvQhU0YiqenmZoGP8dojevihlP95T2tX8N3l1s ONox7k5WR7421ySqSZjEWJXeKh9D+7OS0X1rDIqdnXJUIuPp0eDDGHaK2As+6dt2sv abeQ7tGFhK6DA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; s=automattic1; t=1702137665; bh=r0dtq1OulXXQG0TF7CpfdTP2LRqjxeQHwuCH9RHqTDY=; h=From:Subject:In-Reply-To:Date:Cc:References:To:From; b=dUa4mfP/HYPiMlceqIaomblkYfvYLLvPL0ZU6HfFiABT0HjjqMXRY10KWS/XeXkt5 vmAu5AQSc01K5yc0fk12PxhymAOVyTUnqWNl27FT0prLgRmRKgIYGlk05uIhLVrBwK AT8zPiUMz5UqlLBvgZdi+HTVR5WkBuBEAQsKh6AlS6DjD5RweeZ1pjK+2EeIs57x5X M4/bBKcZEWSSpx4TXrOdjxH326JBStOO1DsOaQg6pNY0Mf0sZ7jHaWigNeWoAx3JXi ETFo5l3RsMLlDBM6TEME/VQ0KCYwcYDXjLgmr7JXLHUbdqrPBZwm9lrAnaTN1uM6/U BSRa3QNkYQ2Wg== Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-gw.dca.automattic.com (Postfix) with ESMTPS id 704B3A0703 for ; Sat, 9 Dec 2023 16:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; s=automattic2; t=1702137665; bh=r0dtq1OulXXQG0TF7CpfdTP2LRqjxeQHwuCH9RHqTDY=; h=From:Subject:In-Reply-To:Date:Cc:References:To:From; b=jsUXsHUSkbrCsfNbH3ahLrIpwrcMS2Ah5aOW3u450JyS0OS2n2kbxX4aczyNrnLkT ok+5zCMHASYY1hIx0K4k0P46jhd5gwJI89VmrNwwlOJk297pvD0kBx8JKWQrFGB62u PeiZYFpVZXn1dF383pxB9D1ZFB2bur3Cgj9x+gXnzpssGQ+8UL56LORhLE0Ay8QxbP uP2oNOc+Z6ZVjb3uVuWVxLsfXyki9cq9I0DcRwzD8WvCNEqhRkMDTIk0dBZM9hHhWX T9HSxFZs/Fy5zbn3+tCLXI4iX0ZWC96KyIfnrUNFFBvHX5mg9UJ4UT9UOTIw2/u1f7 u83FEUYhGM6Ng== Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-33349915da3so2471971f8f.0 for ; Sat, 09 Dec 2023 08:01:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702137664; x=1702742464; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:subject:mime-version:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r0dtq1OulXXQG0TF7CpfdTP2LRqjxeQHwuCH9RHqTDY=; b=l/D2FklWnZCZMszWyqXks+fPPXdwA85kZHnDiosWIxZPPEKopydIKV0PYUMPHgpBnB GWHjKy2mueZCNv0RR5KtkRGEyiakB/GfcjV2f7HhxK1lkYsqF63xDS92Xpa6RdmZYwgJ P15zk/MD6OAgGqwBQMOMDnKXuzr2JuwYHFN2SVodEKwkY44kDCDKuJHdHTxw/JFdbMXU MuMMGE1sIMvt7Uk3LroiCEOSJeiwaEa2fgxzlQLlgmx0SPAvq3V9IwCPe/n/2FWGlYAG HT6DbgB8HDBd+oDstVYjYRmm30rYAiLbEjKTMYHIDlJAxL7c34WbUiQ6wuNn9ijMnILy eq4Q== X-Gm-Message-State: AOJu0YxjgFOwjLnxvojD2szMgJFx6BlmmsaNxVByoDTb3Ghtj7dpgFBn ylsMOei9KnHlZp4hUBi/27IgJoIgk5DcHU/CDvBEGcC4GFh9wHNAjQqXrJaUV4ZOhiMRQVaYhfc OXJ0ATSn7pCWM3mftnA== X-Received: by 2002:a5d:52cd:0:b0:333:3983:409b with SMTP id r13-20020a5d52cd000000b003333983409bmr694362wrv.117.1702137664509; Sat, 09 Dec 2023 08:01:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHubHi4CJbOTRXmJm8LT9r/C5iunrNcX0jrMGFCZ0YvSrf4NjiSsHf+IZlsiG2658Vm4RQCg== X-Received: by 2002:a5d:52cd:0:b0:333:3983:409b with SMTP id r13-20020a5d52cd000000b003333983409bmr694357wrv.117.1702137664116; Sat, 09 Dec 2023 08:01:04 -0800 (PST) Received: from smtpclient.apple (c144-230.i06-5.onvol.net. [77.71.144.230]) by smtp.gmail.com with ESMTPSA id g3-20020adff403000000b003335ddce799sm4604330wro.103.2023.12.09.08.01.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Dec 2023 08:01:03 -0800 (PST) Reply-To: Dennis Snell X-Google-Original-From: Dennis Snell Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.200.91.1.1\)) In-Reply-To: Date: Sat, 9 Dec 2023 17:00:52 +0100 Cc: Max Semenik , Internals Content-Transfer-Encoding: quoted-printable Message-ID: <186E7CDC-92D4-4A33-9B1A-8B8624B8E54B@automattic.com> References: <1BF39851-A294-44D9-827F-933B00807441@automattic.com> To: Robert Landers X-Mailer: Apple Mail (2.3774.200.91.1.1) Subject: Re: [PHP-DEV] [RFC][Discussion] NotSerializable attribute From: internals@lists.php.net ("Dennis Snell via internals") > On Dec 9, 2023, at 4:55=E2=80=AFPM, Robert Landers = wrote: >=20 > On Sat, Dec 9, 2023 at 4:32=E2=80=AFPM Dennis Snell via internals > wrote: >>=20 >> Max, I love this idea. >>=20 >> Would it make sense to flip the design though and add = `#[Serializable]` with a new `php.ini` setting? >>=20 >> I=E2=80=99m thinking that almost every class I use, if not every = single class, should not be serialized. >> If PHP had a flag to say =E2=80=9Cprevent all classes from = serializing=E2=80=9D then I could toggle that flag and >> avoid changing every single one of the potentially thousands of = classes in my codebase, and >> I wouldn=E2=80=99t have to worry about ensuring that everyone = creating a new class remembers to add >> this attribute. >>=20 >> For existing sites with serializable classes we can leave the default = of this new flag to the >> permissive legacy behavior: every class is serializable. However, if = you are willing and have >> vetted your code you can flip that flag and now _unless_ you = explicitly declare serializability >> support, your classes don=E2=80=99t serialize or unserialize. >>=20 >> That could point to a future where _no_ class serializes _unless_ it = implements `__sleep()` >> and `__wakeup()` or `Serializable`, which seems quite reasonable in = my mind as a tradeoff >> between explicitness and surprise. >>=20 >> Warmly, >> Dennis Snell >>=20 >>> On Dec 9, 2023, at 1:30=E2=80=AFPM, Max Semenik = wrote: >>>=20 >>> Hi, I'd like to propose a new attribute, #[NotSerializable]. This >>> functionality is already available for internal classes - userspace = should >>> benefit from it, too. >>>=20 >>> The RFC: https://wiki.php.net/rfc/not_serializable >>> Proposed implementation: https://github.com/php/php-src/pull/12788 >>>=20 >>> Please let me know what you think. >>>=20 >>> -- >>> Best regards, >>> Max Semenik >>>=20 >>> --0000000000006c4879060c12de83-- >>>=20 >>=20 >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: https://www.php.net/unsub.php >>=20 >=20 > Hi Dennis! >=20 > The biggest downside for the reverse of #[NotSerializable] is that it > would break almost everything that uses serialize (e.g., WordPress > caching, some Symfony/Doctrine things, SQS transports, etc.). Also, > there is the question of whether this would apply to json_encode() or > just serialize(). Thanks Robert, My idea was that the flag, by default, would preserve the existing = behavior. A large codebase could decide to wait to disable serialization until = every class is appropriately marked. Either way I guess a large refactor is resolved. With `#[Serializable]` = the onus is on making sure that features requiring serialization are marked as = such. With `#[NotSerializable]` the onus is on classes (which are not concerned = with serialization) to opt-out of something unrelated. The RFC calls this out and it is awkward to implement `__wakeup()` with = a throwing exception. `#[Serializable]` takes that a step further in linking the = two concepts only where they are related. >=20 > PS. Please don't forget to bottom post on this list. Thank you! >=20 > Robert Landers > Software Engineer > Utrecht NL