Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115902 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 53371 invoked from network); 31 Aug 2021 13:21:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 31 Aug 2021 13:21:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A3DFD18050B for ; Tue, 31 Aug 2021 06:56:47 -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.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS12876 195.154.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from smtp-in.fusiondirectory.org (smtp-in.fusiondirectory.org [195.154.20.156]) (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 ; Tue, 31 Aug 2021 06:56:46 -0700 (PDT) Received: from smtp-in.fusiondirectory.org (localhost.localdomain [127.0.0.1]) by smtp-in.fusiondirectory.org (Proxmox) with ESMTP id B9CAE101889 for ; Tue, 31 Aug 2021 15:56:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= fusiondirectory.org; h=cc:content-transfer-encoding:content-type :content-type:date:from:from:message-id:mime-version:reply-to :subject:subject:to:to; s=fusiondirectory; bh=SdUmguNPtlxsCHqafC TGgd3e2lFjgol+BEAJ1jQmQeE=; b=sbP/oNys/axzINu3veskoUdmz43D4pV0Ai uIj4TzQOOhZxgJ8VNA9Vb5Ytf+8bEQBli5hJKnxKD8tN/Nc66rr1TnzipTLFACpO 5upH02ASVubzE4wcq/TUqwnPhBuQBfgx9bJBumOuS2JOV2+DXWSgQM3QJfnZZXPU Mp+H6D5KUcBw0Qz3F6Hl/2pi+mSKGCzBi+sjN4rRVeKjkRuOdy8IpbtPsqy2zr7S xluNh5RTotsWpR48CtoQfdq2km+WEs8MrZzfe/mxNq8W9e2wpRDS8xPtCdGrOYyd H9N4nNC9efwvDaVdyBRl9bUJw4qyan4vPSp3+MaYXMoUOwVmL54A== Received: from smtp.fusiondirectory.org (smtp.fusiondirectory.org [195.154.20.141]) by smtp-in.fusiondirectory.org (Proxmox) with ESMTP id 75BE1101519 for ; Tue, 31 Aug 2021 15:56:44 +0200 (CEST) Received: from mcmic-probook.opensides.be (63.120.199.77.rev.sfr.net [77.199.120.63]) by smtp.fusiondirectory.org (Postfix) with ESMTPSA id 425F225CBC3 for ; Tue, 31 Aug 2021 15:56:44 +0200 (CEST) Date: Tue, 31 Aug 2021 15:56:42 +0200 To: PHP Internals Message-ID: <20210831155642.1779f22f@mcmic-probook.opensides.be> Organization: FusionDirectory X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Resources and object resources From: come.chilliet@fusiondirectory.org (=?UTF-8?B?Q8O0bWU=?= Chilliet) Hello, Resources cannot be serialized. This is mentionned on https://www.php.net/manual/en/function.serialize.php , but one can easily miss it. The information does not seem to appear on https://www.php.net/manual/en/language.oop5.serialization.php and https://www.php.net/manual/en/language.types.resource.php And nowhere does it says what happens if you serialize an object with a resource in a property. Now most resources are replaced by classes in the recent versions of PHP. Because of this, it is advised to replace tests like (is_resource($object->res)) with ($object->res !=3D=3D FALSE). So, I tried to do this in my application with LDAP connections, which will = be objects in PHP 8.1. And the application broke, because when unserializing from session an object containting an LDAP connection, the property is set to int(0). So is_resour= ce() and !=3D=3D FALSE will not have the same result. I cannot find any documentation page mentionning that resources are turned = into int(0) upon serialization. It seems to be consistent accross versions: https://3v4l.org/BHtAh But what will happen when LDAP connections are turned into objects in 8.1? = Will they also become int(0) upon serialization or will they behave in an other = way? I could not find a case of resource that became an object and is allowed on 3v4l to test this. There is no LDAP or CURL in there. C=C3=B4me