Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73005 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47700 invoked from network); 8 Mar 2014 16:50:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Mar 2014 16:50:12 -0000 Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.49 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 74.125.82.49 mail-wg0-f49.google.com Received: from [74.125.82.49] ([74.125.82.49:42114] helo=mail-wg0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F9/20-44862-14A4B135 for ; Sat, 08 Mar 2014 11:50:11 -0500 Received: by mail-wg0-f49.google.com with SMTP id a1so2326651wgh.32 for ; Sat, 08 Mar 2014 08:50:06 -0800 (PST) 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=Uz1Deadan5Jew2toj7YljzcQgQ2BzzoDXLzpVFh55OQ=; b=YSwK9UQ49kwku7W+HOXNUrFz1en6ZVNkFrEZ01u/wNngWCyHR9VLZZ1KbjCub/MWsD SkYCLXgyBzzeqr7Dn/8w/enDdJREWlmqH5v+7S6xUnENS8B1ktCAxR5UMbL1GBhztiZc ehFRacZJUpxDhH9sTqyp48rkoPwEy9Uk8GzyQnmmuPteMh3c/EHnkmV29q/saC++fbaT ch0UzsxRaxJy8mtE/NV/R7A1FFUki/wJIlmZUmAsQO6Hna4JLaCjbFT5cljSaz5NhSTz DW5pnmuzr6EzVdXrL81bcUHRZg2IrY+xXX3/FPGk32Brlkn3IuSq7Gfm/5KbyMbcWGxf cpwQ== MIME-Version: 1.0 X-Received: by 10.194.82.35 with SMTP id f3mr25013770wjy.36.1394297406737; Sat, 08 Mar 2014 08:50:06 -0800 (PST) Received: by 10.227.24.136 with HTTP; Sat, 8 Mar 2014 08:50:06 -0800 (PST) In-Reply-To: References: Date: Sat, 8 Mar 2014 11:50:06 -0500 Message-ID: To: Tjerk Meesters Cc: Etienne Kneuss , Julien Pauli , PHP Internals Content-Type: multipart/alternative; boundary=047d7bf0c106a3d44404f41b29f7 Subject: Re: [PHP-DEV] [PR 614] ArrayObject and isset() / empty() behaviour From: theanomaly.is@gmail.com (Sherif Ramadan) --047d7bf0c106a3d44404f41b29f7 Content-Type: text/plain; charset=ISO-8859-1 On Sat, Mar 8, 2014 at 4:56 AM, Tjerk Meesters wrote: > On Sat, Mar 8, 2014 at 8:27 AM, Tjerk Meesters >wrote: > > > Hi Etienne, > > > > Thanks for your input, much appreciated. > > > > I have moved the decision up the chain as you suggested; the results can > > be found here: > > > > https://github.com/datibbaw/php-src/compare/php:PHP-5.4...bug66834a > > > > > > > It's suffering from a few memory leaks which can be fixed, > > > > They are fixed now and a new PR has been opened: > > https://github.com/php/php-src/pull/616 > > > > but would this be acceptable otherwise? > > > > > > > > On Sat, Mar 8, 2014 at 12:12 AM, Etienne Kneuss wrote: > > > >> > >> > >> > >> On Fri, Mar 7, 2014 at 4:58 PM, Etienne Kneuss wrote: > >> > >>> > >>> > >>> On Fri, Mar 7, 2014 at 3:15 PM, Julien Pauli wrote: > >>> > >>>> On Fri, Mar 7, 2014 at 11:14 AM, Tjerk Meesters > >>>> wrote: > >>>> > Hi, > >>>> > > >>>> > I come across the following bug: > >>>> https://bugs.php.net/bug.php?id=66834 > >>>> > > >>>> > With an extended ArrayObject instance, the behaviour of `isset()` > and > >>>> > `empty()` is as follows: > >>>> > > >>>> > 1. Call `static::offsetExists()` > >>>> > 2. If return value is truthy, then > >>>> > a. isset() returns true > >>>> > b. empty() returns false > >>>> > c. spl_array_has_property() returns true > >>>> > > >>>> > However, if the ArrayObject instance is not overridden: > >>>> > > >>>> > 1. Fetch value (either via string or long key) > >>>> > 2. If key is found, then: > >>>> > a. isset() returns false if value is `null`, true otherwise. > >>>> > b. empty() returns true if value is truty, false otherwise. > >>>> > c. spl_array_has_property() returns true > >>>> > > >>>> > That's counterintuitive, so my patch addresses this by also calling > >>>> > `offsetGet()` if applicable. I wanted to bring this to the attention > >>>> of the > >>>> > group first, because it may affect performance to achieve this goal: > >>>> > >>> > >>> I have always been annoyed by this dichotomy between offsetExists() > >>> which is functionning like array_key_exists() and isset() which is > >>> returning false on defined, null values. Especially since isset() calls > >>> offsetExists() only. > >>> > >>> I would argue that the correct way to fix it is to have isset()/empty() > >>> call offsetGet() as well if it exists. So in that sense I feel like > your > >>> patch is not addressing the right issue. In a sense ArrayObject does a > hack > >>> to circumvent that in the first place, and you are trying to fix the > hack > >>> to make it look more like what is supposed to happen. > >>> > >>> > >> Apart from this underlying "design" issue, it is true an overridden > >> version of ArrayObject is not functionally equivalent to the original > >> class. So it seems worth fixing independently from this hack. > >> -- > >> Etienne Kneuss > >> > > > > > > > > -- > > -- > > Tjerk > > > > > > -- > -- > Tjerk > Could you actually make that into a sane macro or would that just be more trouble than it's worth? --047d7bf0c106a3d44404f41b29f7--