Error causing server to overload and kill WordPress

[ad_1]

Hi,
We are using this plugin All in One SEO Pack but we encountered an issue with our tiny server where some of the request somehow reached a function called “isYandexUserAgent” which uses the variable $_SERVER[‘HTTP_USER_AGENT’], somehow the variable is not provided and is causing an error on the server, and with enough overload of the error, the server just turned off the WordPress server process, although the server ssh itself is still running, restarting the server or the WordPress process could fix the issue, but if continuous requests are made with the same pattern, the website could be down multiple times.

Thus for the code in /app/Common/Traits/Helpers/ThirdParty.php
I would like to suggest a revision from

public function isYandexUserAgent() {
	return preg_match( '#.*Yandex.*#', $_SERVER['HTTP_USER_AGENT'] );
}

to

public function isYandexUserAgent() {
	if(!isset($_SERVER['HTTP_USER_AGENT']))
		return false;
	return preg_match( '#.*Yandex.*#', $_SERVER['HTTP_USER_AGENT'] );
}

 

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