Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103506 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 15303 invoked from network); 26 Nov 2018 14:57:33 -0000 Received: from unknown (HELO mail-it1-f176.google.com) (209.85.166.176) by pb1.pair.com with SMTP; 26 Nov 2018 14:57:33 -0000 Received: by mail-it1-f176.google.com with SMTP id b5so26951444iti.2 for ; Mon, 26 Nov 2018 03:20:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=D2Z1tcPOiYkRyMsEV5xWhgFBuX3Rq4t6zLX7y4OtAtY=; b=jSHRDf0F4G+Sd28aLW/nuk0xUv+SV1steNu7/3wPt4cXr4bRz/GLDVK4OhssP41pTX qSLcwGDFsALOM6biOy2UPteZgi8M958H9hmRNyryTjsbVG3gSpv7nWrempfmL7bIhnZp zWndyiuhMOb6au9lDsNy6xSqBtMyskFYehGn2KI2bCBiOYBnZbJyMjgAR0yWRit9Y7ZE 0tYs4QMNNraYH04y3yftg/ulSO+pmugiYOx6FMxC2Agc7MnAQh8FssQPjyQZaObECyNA UWaRn+rSL24vC00hHN2DoGCsoFHQK6IprzzzKGCFkRTbPOvYuCHeG05WSQWDOQ33l4cu aEaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=D2Z1tcPOiYkRyMsEV5xWhgFBuX3Rq4t6zLX7y4OtAtY=; b=m3o+3FRcWjsDy9V6/tcOi8jWNReYOZawxvHAI87sNp2TK/RcmXcXF9C4LiP/4PUQ1s iyNysIj++Xdo+RO6O2RFV9NYCzScI9GIpA231/olUlWJig0oUNTd5AFOUMZS4jwYrysX 9++/2xfISWyH10b6joriqaZkNA3UJgeOGwldF+Mnz7nH6FLTBIhgm0cwp5TS9vVhc96e Kyco0lQNxkmMa6L7wFMZknywY/LpDxlJVN7+CDwAiaH109yLmJJhCUZje5UI0EnIYJMl EuwbbgnpydEHw+s4QbWT4OXtZ/vktgsfd8nfIFUPHBWbIdWCK/FheyWz9+NnsXbwrl4C zXkw== X-Gm-Message-State: AGRZ1gJOjTVpaiEvezbckv/g93n9QVSbTZ9uqNjoYKjayO5yxdqxFN+R mAJ4UvTW49ST7EFQk0bpfKV2El+caB+N5mQLQzb9pw== X-Google-Smtp-Source: AJdET5fHqPx64JVbaxLxOzVg7VJKzigrZ3YH00+leWwl01tdH0+ampZTZcBDBrV2Mq6M2G/fgrJF+WanRvw2nRbVyDg= X-Received: by 2002:a02:410e:: with SMTP id x14mr22275714jaa.36.1543231253967; Mon, 26 Nov 2018 03:20:53 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 26 Nov 2018 12:20:36 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="000000000000b2f95b057b8f86af" Subject: Re: [PHP-DEV] Built-in classes that cannot be serialized From: nikita.ppv@gmail.com (Nikita Popov) --000000000000b2f95b057b8f86af Content-Type: text/plain; charset="UTF-8" On Mon, Nov 26, 2018 at 10:28 AM Sebastian Bergmann wrote: > The following classes register zend_class_serialize_deny: Closure, COM, > DOTNET, Generator, HashContext, Reflection, ReflectionClass, > ReflectionClassConstant, ReflectionExtension, ReflectionException, > ReflectionFunction, ReflectionFunctionAbstract, ReflectionGenerator, > ReflectionMethod, ReflectionNamedType, ReflectionObject, > ReflectionParameter, ReflectionProperty, ReflectionRype, > ReflectionZendExtension, SimpleXmlElement, SplFileInfo, Variant. > > Are these all the built-in classes that cannot be serialized? > > Would it be possible to implement ReflectionClass::isSerializable() that > returns false when the class is a) built-in and b) has > zend_class_serialize_deny registered? > Apart from serialize_deny, a pretty common pattern is throwing __wakeup. See for example CURLFile. We should migrate such cases to serialize_deny though. I think it's pretty weird to explicitly implement __wakeup (signalling that yes, you can be unserialized), and then use it to throw (sorry, I lied). In any case, what's your motivation here? As long as throwing (un)serialize/__sleep/__wakeup exist, you will not be able to determine whether a class can be (un)serialized a priori. It may even be that a class can only sometimes be serialized. The only reliable way to find out is to actually try it. What prevents you from attempting (un)serialization and catching potentially thrown exceptions? Nikita --000000000000b2f95b057b8f86af--