Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25337 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86803 invoked by uid 1010); 13 Aug 2006 11:18:59 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 86788 invoked from network); 13 Aug 2006 11:18:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Aug 2006 11:18:59 -0000 X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 69.179.208.43 msa3-mx.centurytel.net Linux 2.4/2.6 Received: from ([69.179.208.43:56174] helo=msa3-mx.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id F9/DE-19138-0F50FD44 for ; Sun, 13 Aug 2006 06:58:58 -0400 Received: from pc1 (d19-198.rt-bras.wnvl.centurytel.net [69.179.146.198]) by msa3-mx.centurytel.net (8.13.6/8.13.6) with SMTP id k7DAwru0014673 for ; Sun, 13 Aug 2006 05:58:53 -0500 Message-ID: <005301c6bec7$783e5c80$0201a8c0@pc1> To: Date: Sun, 13 Aug 2006 05:58:54 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Subject: [PATCH] array_count_values bug: mishandling of numbers with leading whitespace From: php_lists@realplain.com ("Matt W") Hi there, I didn't know whether to make an official bug report or send to the list -- so I'm trying this first. :-) 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... http://realplain.com/php/array_count_values_bug.diff http://realplain.com/php/array_count_values_bug_5_2.diff Thanks, Matt