Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:74866 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89159 invoked from network); 12 Jun 2014 11:44:51 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jun 2014 11:44:51 -0000 Authentication-Results: pb1.pair.com smtp.mail=remi@fedoraproject.org; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=remi@fedoraproject.org; sender-id=unknown Received-SPF: error (pb1.pair.com: domain fedoraproject.org from 217.70.183.196 cause and error) X-PHP-List-Original-Sender: remi@fedoraproject.org X-Host-Fingerprint: 217.70.183.196 relay4-d.mail.gandi.net Received: from [217.70.183.196] ([217.70.183.196:57558] helo=relay4-d.mail.gandi.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 31/62-02977-1B299935 for ; Thu, 12 Jun 2014 07:44:50 -0400 Received: from mfilter12-d.gandi.net (mfilter12-d.gandi.net [217.70.178.129]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 3C0A1172093; Thu, 12 Jun 2014 13:44:46 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter12-d.gandi.net Received: from relay4-d.mail.gandi.net ([217.70.183.196]) by mfilter12-d.gandi.net (mfilter12-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id 7gfzNbBpOx2S; Thu, 12 Jun 2014 13:44:44 +0200 (CEST) X-Originating-IP: 82.241.130.121 Received: from schrodingerscat.famillecollet.com (pom51-2-82-241-130-121.fbx.proxad.net [82.241.130.121]) (Authenticated sender: contact@ll-experts.com) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 660C5172074; Thu, 12 Jun 2014 13:44:44 +0200 (CEST) Message-ID: <539992AC.3070200@fedoraproject.org> Date: Thu, 12 Jun 2014 13:44:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: PHP internals CC: Sebastian Bergmann Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Internal Serializable object. Hack to create an object without constructor From: remi@fedoraproject.org (Remi Collet) 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.