Yep. I’m seeing this too for a site on PHP 8.1
Got error ‘PHP message: PHP Warning: Undefined array key “HTTP_USER_AGENT” in /wp-content/plugins/zapier/zapier.php on line 176
It seems tied to an IP address receiving a 404 Get.
It looks like the error occurs in the function:
public function determine_current_user($user)
{
$rest_api_slug = rest_get_url_prefix();
$is_valid_rest_api_uri = strpos($_SERVER['REQUEST_URI'], $rest_api_slug);
$is_valid_token_uri = strpos($_SERVER['REQUEST_URI'], $this->namespace . '/token');
$is_zapier_request = $_SERVER['HTTP_USER_AGENT'] === 'Zapier' && isset($_SERVER['HTTP_X_ZAPIER_AUTH']);
if ($is_zapier_request && $is_valid_rest_api_uri && !$is_valid_token_uri) {
$user_id = $this->get_user_from_token();
if ($user_id) {
return $user_id;
}
}
return $user;
}
because the “HTTP_USER_AGENT” key is not present in the $_SERVER superglobal array.
So change line 176 from
$is_zapier_request = $_SERVER['HTTP_USER_AGENT'] === 'Zapier' && isset($_SERVER['HTTP_X_ZAPIER_AUTH']);
to
$is_zapier_request = isset($_SERVER['HTTP_USER_AGENT']) && $_SERVER['HTTP_USER_AGENT'] === 'Zapier' && isset($_SERVER['HTTP_X_ZAPIER_AUTH']);
That seems to clear things up. At least until the plugin is updated. 🙂