|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-11-04 14:27 UTC] nikic@php.net
-Status: Open
+Status: Feedback
[2021-11-04 14:27 UTC] nikic@php.net
[2021-11-04 14:40 UTC] anton at cpp dot in
-Status: Feedback
+Status: Open
[2021-11-04 14:40 UTC] anton at cpp dot in
[2021-11-04 15:10 UTC] nikic@php.net
-Status: Open
+Status: Verified
[2021-11-04 15:10 UTC] nikic@php.net
[2021-11-04 15:15 UTC] nikic@php.net
-Status: Verified
+Status: Analyzed
[2021-11-04 15:15 UTC] nikic@php.net
[2021-11-04 15:25 UTC] git@php.net
[2021-11-04 15:25 UTC] git@php.net
-Status: Analyzed
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 14:00:01 2025 UTC |
Description: ------------ We had a few 500 pages without any traces in php.log after updating from 7.4 to 8.0. The reason was a parameter type mismatch of in_array and array_key_exists functions, but TypeError was not logged if a warning previously occurred at the same line. We had these warnings silenced with @$_REQUEST['whatever'], so no log messages were produced as a result of the crash. While this pattern is ugly and should be refactored with proper checking and casting (and it was), I believe TypeError should be generated and properly logged in this case nonetheless. Test script: --------------- <?php error_reporting(E_ALL); $not_array = false; // Case #1, incorrect: only 'PHP Warning: Undefined array key "nonexistant"' is logged echo (array_key_exists($_REQUEST['nonexistant'], $not_array) ? "yes" : "no"); // Case #2, correct: 'PHP Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, bool given' is logged $nonexistant = NULL; echo (array_key_exists($nonexistant, $not_array) ? "yes" : "no"); // Case #3, correct: both Warning and Fatal error are logged function my_ake(string|int $key, array $array): bool {return array_key_exists($key, $array);} echo (my_ake($_REQUEST['nonexistant'], $not_array) ? "yes" : "no");