Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74898 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37246 invoked from network); 14 Jun 2014 07:40:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Jun 2014 07:40:25 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.169 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.169 mail-qc0-f169.google.com Received: from [209.85.216.169] ([209.85.216.169:58594] helo=mail-qc0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9F/84-03909-66CFB935 for ; Sat, 14 Jun 2014 03:40:22 -0400 Received: by mail-qc0-f169.google.com with SMTP id c9so5361519qcz.28 for ; Sat, 14 Jun 2014 00:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=NwQl6M1qdAaBCxkt3Ziiu88mDUR9sFPdUSqXf881rXA=; b=0Bh2c5TFTEcTR69abE8Mbc7Xn0tFuv4fCq73+/9SUnX2IVnmpCh3tkRaR3d+bSRLGa pq3a826Fi19/0RARW3b55pMKuR7N60YD6iwy3ho1hYW0cpz42j/9nclte/NIVwcxUhwQ JnqnACz8qDDhE8mIqTxWry6YbnUL9MavBDKoeHEDPsx7x9D4vAh0wVF0haZXlBqtb8xA SmcbnimpQHSV9uQef2q3Lm77sbmo2ULRHFUZWszYXOaJ29b663DuoT76bHYrcbl0AePY K7g7lD1bNqU6wxQQoZiKfucxb8M6qUreIYWVbqvF0Wzh9OBXTRTF7n1bMMF9DFy1qXnd 2Caw== MIME-Version: 1.0 X-Received: by 10.140.91.226 with SMTP id z89mr7460201qgd.65.1402731619790; Sat, 14 Jun 2014 00:40:19 -0700 (PDT) Received: by 10.140.17.77 with HTTP; Sat, 14 Jun 2014 00:40:19 -0700 (PDT) In-Reply-To: <53999376.8070807@fedoraproject.org> References: <53999376.8070807@fedoraproject.org> Date: Sat, 14 Jun 2014 09:40:19 +0200 Message-ID: To: Remi Collet Cc: PHP internals , Sebastian Bergmann Content-Type: multipart/alternative; boundary=001a113a73a2e9b6af04fbc6e7b6 Subject: Re: [PHP-DEV] Internal Serializable object. Hack to create an object without constructor From: tyra3l@gmail.com (Ferenc Kovacs) --001a113a73a2e9b6af04fbc6e7b6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Jun 12, 2014 at 1:48 PM, Remi Collet wrote= : > Hi, > > As Internal Class doesn't support newInstanceWithoutConstructor, some > user code use the above hack (ex phpunit-mock-object) > > $object =3D unserialize( > sprintf('%s:%d:"%s":0:{}', > (version_compare(PHP_VERSION, '5.4', '>') > && $class->implementsInterface("Serializable") ? "C" : "O"), > strlen($className), > $className > ) > ); > > Of course, this is already a hack. > > Of course, better solution will be to support > newInstanceWithoutConstructor for all internals classes, but this is > another story > > Problem, Serializable internal class raised the > 'Empty serialized string cannot be empty' exception. > > I don't really see any reason to make serialized string mandatory, as > those classes can be create (constructor) without any mandatory option. > > The trivial attached patch could make everyone life easier. > > The new test serialize again the result object to ensure all internal > structures are properly initialized, and no segfault. > > > Feedback welcome. > > > Remi. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > I'm +1 on this change, would like to hear what others think. ps: small typo in the patch: Check that SplObjectStorage::unserialize desn't throws exception when NULL passed should be Check that SplObjectStorage::unserialize doesn't throw exception when NULL passed imo --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --001a113a73a2e9b6af04fbc6e7b6--