Title: PHP Warning (PHP 8 issue?)
Last modified: April 20, 2023

---

# PHP Warning (PHP 8 issue?)

 *  [nathaningram](https://wordpress.org/support/users/nathaningram/)
 * (@nathaningram)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/php-warning-php-8-issue/)
 * Multiple instances of this error in the error log:
 *     ```wp-block-code
       PHP Warning: Undefined array key "HTTP_USER_AGENT" in /XXXXXXXXXXX/public_html/wp-content/plugins/zapier/zapier.php on line 176
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [tunjic](https://wordpress.org/support/users/tunjic/)
 * (@tunjic)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/php-warning-php-8-issue/#post-16825070)
 * 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.
 *  [tunjic](https://wordpress.org/support/users/tunjic/)
 * (@tunjic)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/php-warning-php-8-issue/#post-16825153)
 * It looks like the error occurs in the function:
 *     ```wp-block-code
           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
 *     ```wp-block-code
       $is_zapier_request = $_SERVER['HTTP_USER_AGENT'] === 'Zapier' && isset($_SERVER['HTTP_X_ZAPIER_AUTH']);
       ```
   
 * to
 *     ```wp-block-code
       $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. 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘PHP Warning (PHP 8 issue?)’ is closed to new replies.

 * ![](https://ps.w.org/zapier/assets/icon.svg?rev=3043272)
 * [Zapier for WordPress](https://wordpress.org/plugins/zapier/)
 * [Support Threads](https://wordpress.org/support/plugin/zapier/)
 * [Active Topics](https://wordpress.org/support/plugin/zapier/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/zapier/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/zapier/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [tunjic](https://wordpress.org/support/users/tunjic/)
 * Last activity: [2 years, 11 months ago](https://wordpress.org/support/topic/php-warning-php-8-issue/#post-16825153)
 * Status: not resolved