fixed error in filter email when headers are not set or not an array

This commit is contained in:
asus
2024-04-15 18:44:09 +02:00
parent 2d6fef598b
commit e07aa0e57f

View File

@@ -125,8 +125,16 @@ function find_user_id_from_headers(&$args) {
if (!isset($args['headers'])) {
return null;
}
$user_id = null;
$headers = $args['headers'];
if (empty($headers)) {
return null;
}
if (!is_array($headers)) {
return null;
}
$user_id = null;
// isset returns false if the key exists but its value is null : 'user_id'=>null : https://stackoverflow.com/questions/3803282/check-if-value-isset-and-null
if (array_key_exists('user_id', $headers)) {
$user_id = $headers['user_id'];