Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89288 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7331 invoked from network); 21 Nov 2015 22:47:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Nov 2015 22:47:41 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.41 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 74.125.82.41 mail-wm0-f41.google.com Received: from [74.125.82.41] ([74.125.82.41:35587] helo=mail-wm0-f41.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/21-23339-B84F0565 for ; Sat, 21 Nov 2015 17:47:40 -0500 Received: by wmuu63 with SMTP id u63so14933035wmu.0 for ; Sat, 21 Nov 2015 14:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=7XGFv4dGch53bgzOHrASe3pfahP0OzSXu7p7PvrKaNo=; b=Ge/vrPIF2LBsi9gneXOonxrPVmB5Q3PQ558AXHcCfFlszEOBIPihRaYHnN8svBWbwR V+vKFIr/L3LK0DvvMiANCbqDAPrOKMrN4pAEBDC7j/33xB4IrG8gAKh2Ep0Ds1/0bjza aWu5cju7/8dJ2cSzCGVGTI/Q7tdLQzF7PyC5viuRz6Y4KR9+U4sov49bdEG64jErvqnX eZdP35BFK8NCP5gac7Y3wlQf6e4BZovuCAdfCa1laxMbHsZFfi/jVUmlV49JkgdHFRcr rj/9nnZV7eFDWTI4qbEMecd0fWeVoC1sK06n3AA9sTFjg/b9OzmsvhKlXpurnu8pzY9L y3cw== MIME-Version: 1.0 X-Received: by 10.28.182.134 with SMTP id g128mr8244112wmf.95.1448146057247; Sat, 21 Nov 2015 14:47:37 -0800 (PST) Received: by 10.28.226.10 with HTTP; Sat, 21 Nov 2015 14:47:37 -0800 (PST) Date: Sat, 21 Nov 2015 17:47:37 -0500 Message-ID: To: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: INDRECT in arrays causes count() to become unpredictable From: ircmaxell@gmail.com (Anthony Ferrara) All, It appears that in our efforts to optimize PHP 7 we've introduced an inconsistency into array handling. This is demonstrated by this script: https://3v4l.org/hVcAB $a = 1; unset($a); var_dump(count($GLOBALS), $GLOBALS); The result is that the count doesn't match the contents of the array. It also affects objects casted to arrays in certain cases. Here, the array has 1 element, but should have 0. Trying to access the "1" element "a" results in a notice. This means that the count is incorrect. This is due to the fact that the "a" element follows an IS_INDIRECT type pointing to the other symbol table. A potential solution would be to make count() an O(n) operation in the case that the hashtable is a symbol table or if it has INDIRECT elements. Meaning that we'd compute the real count at runtime. This obviously has performance ramifications, but we shouldn't sacrifice consistency and behavior for performance IMHO. Especially when it comes to core data structures. I think this is significant enough to be a blocker to gold and that we should fix it prior to release. Thoughts? Anthony