Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81933 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6926 invoked from network); 5 Feb 2015 14:58:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2015 14:58:02 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.43 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.43 mail-wg0-f43.google.com Received: from [74.125.82.43] ([74.125.82.43:48973] helo=mail-wg0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/CF-27691-9F483D45 for ; Thu, 05 Feb 2015 09:58:01 -0500 Received: by mail-wg0-f43.google.com with SMTP id y19so8080218wgg.2 for ; Thu, 05 Feb 2015 06:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=5LYt4vtStwbgnJ+fa26B4sTaILKQsdZgjWoykJy4KHM=; b=S/67nFIVkrRQfF8hjWfl9toROMUT7G6F7TM2E10OQ1er1q4mI/W0EdcKh9BP2tJnfu WRS9g98KSKdlRz6cXABB8m8Vup55N0AW9HwKdt/7d+l74CZm78fosQMWYchd2KFSzSVu mxGxrr4uCtSn+mS/cmoFJJwMVUBUjhREAPkV5l2bPR1DDX800ZXU9fqs5uTgERWCi/Kx OcKp2HzoEraPbHlK6f01Pa1lFOsKmLj4032w93xkwZJg5qNgl6zJnZNVM9bhOExUWUfk ZfQ5nwaINJQys183xR5uN2UVSe2n2wOtlWZaHkX6PUJZVFpf8ZHmqu+dhZj2VB60N8X8 ZH7w== X-Received: by 10.180.99.42 with SMTP id en10mr48375361wib.26.1423148277795; Thu, 05 Feb 2015 06:57:57 -0800 (PST) Received: from [192.168.0.172] ([62.189.198.114]) by mx.google.com with ESMTPSA id ud9sm8246131wib.5.2015.02.05.06.57.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 06:57:57 -0800 (PST) Message-ID: <54D384EC.90305@gmail.com> Date: Thu, 05 Feb 2015 14:57:48 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: Serialize generating corrupted data From: rowan.collins@gmail.com (Rowan Collins) Juan Basso wrote on 05/02/2015 14:07: > No one? > > On Mon, Feb 2, 2015 at 8:57 PM, Juan Basso wrote: > >> Hi, >> >> I was testing few things today and I released one bug in the serialize >> function. The serialize function returns a corrupted value when it is >> serializing an object that contains a __sleep magic method and this method >> return some key that are not string. Ie: >> >> http://viper-7.com/EK16EV >> >> If the __sleep returns a string that is not a property it is fine, it will >> give the notice and the generated response is a valid serialized data (in >> another words you can use unserialize to retrieve the object back). Ie, >> http://viper-7.com/H9ooff >> >> I can try to make a patch to solve it, but before that I would like how >> the behavior should be. Some options: >> 1) Give the notice saying the field doesn't exist and do not include on >> the serialized response >> 2) Give the notice saying the field doesn't exist and convert the value to >> string (ie, on my example the int(1) would be transformed to string(1)) >> 3) Give a warning and return false once the input from __sleep is invalid >> 4) None of the above alternative >> 5) Don't change it >> Playing around with existing behaviour, if you return something other than an array, you get a Notice and a serialized null ('N;') - e.g. http://3v4l.org/rm9rs I think it would be reasonable for the same to happen if the array contains something other than a string, particularly given that the message would still describe the fix quite readily ( "__sleep should return an array only containing the names of instance-variables to serialize"). Personally, I'd have made this a Warning rather than a Notice, since it's clearly discarding data, but it should be consistent either way. Regards, -- Rowan Collins [IMSoP]