note 128374 added to function.spl-object-hash
| From: | Asimpledeveloper at main dot php dot net | Date: | Thu, 06 Apr 2023 08:10:30 +0000 |
| Subject: | note 128374 added to function.spl-object-hash | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220329@lists.php.net to get a copy of this message | ||
Attention when comparing object hashes in PHP >= 8.1
In PHP 8.1 (I think) the output of spl_object_hash() changed (see pull request https://github.com/php/php-src/pull/7010).
This lead to a strange misbehaviour of our application, as we stored object hashes in an array to
check, if we processed object already. A simple in_array() check returned true, even though the
current object hash was NOT actually in array.
Actual problem: New hashes are much more simple and can be something like
"0000000000000e600000000000000000" or "0000000000000e490000000000000000", which
PHP will interpret as numeric (exponent).
in_array() will compare non type-safe by default and will interpret named hashes as "0".
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.130 (proxied: 217.91.157.62)
----
Manual Page -- https://php.net/manual/en/function.spl-object-hash.php
Edit -- https://main.php.net/note/edit/128374
Del: integrated -- https://main.php.net/note/delete/128374/integrated
Del: useless -- https://main.php.net/note/delete/128374/useless
Del: bad code -- https://main.php.net/note/delete/128374/bad+code
Del: spam -- https://main.php.net/note/delete/128374/spam
Del: non-english -- https://main.php.net/note/delete/128374/non-english
Del: in docs -- https://main.php.net/note/delete/128374/in+docs
Del: other reasons-- https://main.php.net/note/delete/128374
Reject -- https://main.php.net/note/reject/128374
Search -- https://main.php.net/manage/user-notes.php