Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73004 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 34698 invoked from network); 8 Mar 2014 09:56:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Mar 2014 09:56:33 -0000 Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.177 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.128.177 mail-ve0-f177.google.com Received: from [209.85.128.177] ([209.85.128.177:33882] helo=mail-ve0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 66/B0-27033-F49EA135 for ; Sat, 08 Mar 2014 04:56:32 -0500 Received: by mail-ve0-f177.google.com with SMTP id sa20so5145378veb.8 for ; Sat, 08 Mar 2014 01:56:28 -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=JtpJMWpqueJCtsMiPj6p3lbkoTg937iGR3VmBQGqbLE=; b=ZPuOV/gcfnxOpYPLXhaxs4wAEpcfzwEaCEZevAdyXxxs8LtFr5NbDzpXENEQzJf7Gp 3F6QEou30lxud+uGpGod1kKrvwsrfFrfkfQhFzHaNJJvUOKaD2WEFSWAmVtPzX8k1nOf 6SSLKb36Vn7RD7lEKtqWFXjRVMKbI+F4QRcblyPjZAALyy2UdjDHkcBoAfu9tVtISQlX 6zzs2/7wdLdbGHyHv8XXGhGixZknrr/OID7C12XNMiwc0Pfs/1HxAr7+DvV0RVFxiOQz 86OPJ/uyXU4FgvALzw8IOPTaPdMoT34n/RrmHtNSDwNJeHSQwWkbLUKxALrbqyrkjslk c1VQ== MIME-Version: 1.0 X-Received: by 10.220.103.141 with SMTP id k13mr58884vco.25.1394272588466; Sat, 08 Mar 2014 01:56:28 -0800 (PST) Received: by 10.58.55.131 with HTTP; Sat, 8 Mar 2014 01:56:28 -0800 (PST) In-Reply-To: References: Date: Sat, 8 Mar 2014 17:56:28 +0800 Message-ID: To: Etienne Kneuss Cc: Julien Pauli , PHP Internals Content-Type: multipart/alternative; boundary=047d7b342d305b122d04f4156260 Subject: Re: [PHP-DEV] [PR 614] ArrayObject and isset() / empty() behaviour From: tjerk.meesters@gmail.com (Tjerk Meesters) --047d7b342d305b122d04f4156260 Content-Type: text/plain; charset=ISO-8859-1 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 --047d7b342d305b122d04f4156260--