[php-src] PR #11468: Fix #80332: Completely broken array access functionality with DOMNamedNodeMap
| From: | nielsdos | Date: | Sat, 17 Jun 2023 16:22:57 +0000 |
| Subject: | [php-src] PR #11468: Fix #80332: Completely broken array access functionality with DOMNamedNodeMap | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-22750@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/11468
Author: nielsdos
The problem is the usage of zval_get_long(). In particular, if the
string is non-numeric the result of zval_get_long() will be 0 *without
giving an error or warning*. This is misleading for users: users get the
impression that they can use strings to access the map because it
coincidentally works for the first item (which is at index 0). Of
course, this fails with any other index which causes confusion and bugs.
This patch adds proper support for using string offsets while accessing
the map. It does so by detecting if it's a non-numeric string, and then
using the getNamedItem() method instead of item().
I plan on refactoring this for 8.3 to avoid the double function call
and useless object construction for notations.