Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116279 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 18932 invoked from network); 17 Oct 2021 09:18:21 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Oct 2021 09:18:21 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BA9DA1804AE for ; Sun, 17 Oct 2021 03:05:46 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 17 Oct 2021 03:05:46 -0700 (PDT) Received: by mail-oi1-f173.google.com with SMTP id z126so20160665oiz.12 for ; Sun, 17 Oct 2021 03:05:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=CegpaepIS23GD+Azz2cFY66/hiTgZ0A5lBZF5g1V1mw=; b=csPuX3JVciSE6rNv+yKdpYoAfocUCZ6/PYBPYiBuNuehJeNx7EQzD2WTt4Sz2AE0Uu 6g3VogzX2iI9IYhsaqCwvP0GTv5SLffCrteKbcEPrX+nL1/Tzj+DqJek3FORLFBjH5pR Uu1uxFKQWt+owCFD52N6heB2lCtBfvf2d8ZddJSW/OH0gcBYIjrsb0AYdEPW1Db26k85 RNhyq60rV2/clbpRQ8iQTgJ9gGrgA/agJBkIhUDkKYbxQddcZvgrsyRjluN615BCPYca j4/uh4obsd+ErvyNd9e5xplNpORwgD7BYFn+XuwaORRv7KR4NFTMDZOIbKDlACYCw874 XlEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=CegpaepIS23GD+Azz2cFY66/hiTgZ0A5lBZF5g1V1mw=; b=TfC2KTfV3Cq/a/lM3TNruqjkllE/YnK/F288DNnQla+mLCrxvgDEBjTfvZsOsZ8N57 1krWmmr79Lb0ey/s2HDH50WMFYT9pdKazEYvpN9V+HrFIPnT6k4dvrC2VaL1WJprzGib MXW3QtpD+gBg4C9EvsfZmg3i35YYfAxLL7eZuT2ebU0uagiQTezrkDinvv1CpWrRVt+N Fz43LWrKb9WVj57unsmqiu02WCbj66nkFIftapk8LJH7VhZM4+WXoHzVA8qplPtebS1P 1ZPc9Iaao3o9HZR6tRabc1cu95at2cJHxUgMZ2rCo2uNAHagzNvTeBM3ynXCnuJNDnOK Y0fA== X-Gm-Message-State: AOAM532XfZpLgO5XW/h3dEaccMwWd8goTIVBE8mCb+2HPNxm+jhTJ0Hb 1SZIxan+vyMpni9vIDzVPORvOPcTHKFhKQoVXAhgh21EY/I= X-Google-Smtp-Source: ABdhPJwggWNKrvQOKs9FkccaR9eS2IcgqHbbfNMkpsCRatH4KNKOm+yaHfYO41t74noFjf4oT5ZXUBLY8k1TNwc/nMs= X-Received: by 2002:a05:6808:1487:: with SMTP id e7mr16131567oiw.126.1634465144788; Sun, 17 Oct 2021 03:05:44 -0700 (PDT) MIME-Version: 1.0 Date: Sun, 17 Oct 2021 12:05:34 +0200 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="0000000000005a5bca05ce899266" Subject: Change of $depth behaviour in json_encode() on PHP 8.1 From: benjamin.morel@gmail.com (Benjamin Morel) --0000000000005a5bca05ce899266 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi internals, I noticed a change of behaviour on PHP 8.1: https://3v4l.org/DoG4A ``` // depth 1 $a =3D new \stdClass(); // depth 2 $b =3D new \stdClass(); $b->x =3D $a; // depth 3 $c =3D new \stdClass(); $c->x =3D [$a]; var_export(json_encode($a, 0, 0)); echo "\n"; var_export(json_encode($b, 0, 1)); echo "\n"; var_export(json_encode($c, 0, 2)); ``` On PHP 8.1, all three examples successfully encode the input object, while on PHP <=3D 8.0, json_encode() returns false as this exceeds the max depth. I couldn't find a note about this in the migration guide for PHP 8.1. Is this documented, or is this a regression that should be fixed? Thanks in advance, =E2=80=94 Benjamin --0000000000005a5bca05ce899266--