Manage the case where `$_SERVER[‘HTTP_USER_AGENT’]` is undefined

[ad_1]

Hi,

In the file /wp-content/plugins/eps-301-redirects/eps-301-redirects.php, line 969:

$last['user_agent'] = @strip_tags($_SERVER['HTTP_USER_AGENT']);

it displays two warnings in the log file when HTTP_USER_AGENT is undefined:

PHP Error: [2] Undefined array key "HTTP_USER_AGENT" in /wp-content/plugins/eps-301-redirects/eps-301-redirects.php on line 969
Stack trace:
#0 /wp-content/plugins/eps-301-redirects/eps-301-redirects.php(969): custom_error_handler(integer, string, string, integer)
#1 /wp-includes/class-wp-hook.php(324): EPS_Redirects->check_404(string)
#2 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(boolean, array)
#3 /wp-includes/plugin.php(517): WP_Hook->do_action(array)
#4 /wp-includes/template-loader.php(13): do_action(string)
#5 /wp-blog-header.php(19): require_once(string)
#6 /index.php(17): require(string)

PHP Error: [8192] strip_tags(): Passing null to parameter #1 ($string) of type string is deprecated in /wp-content/plugins/eps-301-redirects/eps-301-redirects.php on line 969
Stack trace:
#1 /wp-content/plugins/eps-301-redirects/eps-301-redirects.php(969): strip_tags(NULL)
#2 /wp-includes/class-wp-hook.php(324): EPS_Redirects->check_404(string)
#3 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(boolean, array)
#4 /wp-includes/plugin.php(517): WP_Hook->do_action(array)
#5 /wp-includes/template-loader.php(13): do_action(string)
#6 /wp-blog-header.php(19): require_once(string)
#7 /index.php(17): require(string)

I’m using 301 Redirects v2.76, WordPress 6.5.5 and PHP 8.1.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer