Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25338 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2555 invoked by uid 1010); 13 Aug 2006 12:48:30 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 2540 invoked from network); 13 Aug 2006 12:48:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2006 12:48:30 -0000 Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; domainkeys=good DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 66.249.92.170 ug-out-1314.google.com Linux 2.4/2.6 Received: from ([66.249.92.170:60044] helo=ug-out-1314.google.com) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 57/FF-19138-D361FD44 for ; Sun, 13 Aug 2006 08:08:29 -0400 Received: by ug-out-1314.google.com with SMTP id k3so1312584ugf for ; Sun, 13 Aug 2006 05:08:26 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=a5aP4laNYGnInVOod4oD70N2XIHxLOy3ryyRHUiKDKElHZDIshE/xnFCZBn5Z/zlin+rQafPF7iCLliVoumPpJmz6653HTtFJHBH4HVtkSdVAILQXfNxExSqHfRM7xK+6BYufiDvNUqDCGzy/Em3e7W4tlmlTzeF33+LravWiR4= Received: by 10.66.221.19 with SMTP id t19mr6679254ugg; Sun, 13 Aug 2006 05:08:26 -0700 (PDT) Received: by 10.66.248.15 with HTTP; Sun, 13 Aug 2006 05:08:26 -0700 (PDT) Message-ID: Date: Sun, 13 Aug 2006 14:08:26 +0200 To: "Matt W" Cc: internals@lists.php.net In-Reply-To: <005301c6bec7$783e5c80$0201a8c0@pc1> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <005301c6bec7$783e5c80$0201a8c0@pc1> Subject: Re: [PHP-DEV] [PATCH] array_count_values bug: mishandling of numbers with leading whitespace From: pierre.php@gmail.com (Pierre) Hello, On 8/13/06, Matt W wrote: > Hi there, > > I didn't know whether to make an official bug report or send to the list -- > so I'm trying this first. :-) You already tried in the previous thread about is_numeric. > var_dump(array_count_values(array(' 001', 1, ' 1 ', '1'))); > > Expected result (and what PHP 4 gives): > array(3) { > [" 001"]=> > int(1) > [1]=> > int(2) > [" 1 "]=> > int(1) > } > > Actual result: > array(2) { > [1]=> > int(3) > [" 1 "]=> > int(1) > } > Can this patch please be applied for 5.2's release? To maintain what I'm > sure is the correct behavior from PHP 4, the function needs to use the > zend_[u_]symtable* functions, which take care of *correctly* handling > numeric strings, as zend_hash_[find|update] did in 4.x. If they would've > been used in 5+ in the first place, there wouldn't have been bugs like > #34723 (still present with leading whitespace, as you can see), #30833, > #29808, etc. (I guess that's all, actually). :-) > The updated code should be faster, too... As I said in the previous discussion (why in the world have you splitted it out?), I don't think it is reasonable or safe to apply this patch in 5.2. Secondly it seems to wrong address the problem. You work around the actual is_numeric "problems" by suppressing its usage. Doing so reintroduce the numeric string keys problem (what addresses the removed code). > http://realplain.com/php/array_count_values_bug.diff > http://realplain.com/php/array_count_values_bug_5_2.diff I think it is much more safer to first determine the general policy for is_numeric and then address this problem. It is too late in the game to change such behaviors in 5.x (I care little about 4.x compatibility). Cheers, --Pierre