newrelic / newrelic-php-agent

The New Relic PHP Agent
https://opensource.newrelic.com/projects/newrelic/newrelic-php-agent
Apache License 2.0
119 stars 61 forks source link

newrelic-php-agent is breaking my WordPress site when using php 8.1 due to some database deprecation #457

Closed nickchomey closed 2 years ago

nickchomey commented 2 years ago

Description

If I have newrelic-php-agent enabled, I get these errors in my debug log.

PHP Deprecated:  mysqli_real_connect(): Passing null to parameter #5 ($database) of type ?string is deprecated in /home/xyz.com/public_html/wp-includes/wp-db.php on line 1753
[01-Jun-2022 18:28:02 UTC] PHP Stack trace:
[01-Jun-2022 18:28:02 UTC] PHP   1. {main}() /home/xyz.com/public_html/wp-admin/plugins.php:0
[01-Jun-2022 18:28:02 UTC] PHP   2. require_once() /home/xyz.com/public_html/wp-admin/plugins.php:10
[01-Jun-2022 18:28:02 UTC] PHP   3. require_once() /home/xyz.com/public_html/wp-admin/admin.php:34
[01-Jun-2022 18:28:02 UTC] PHP   4. require_once() /home/xyz.com/public_html/wp-load.php:50
[01-Jun-2022 18:28:02 UTC] PHP   5. require_once() /home/xyz.com/public_html/wp-config.php:130
[01-Jun-2022 18:28:02 UTC] PHP   6. require_wp_db() /home/xyz.com/public_html/wp-settings.php:124
[01-Jun-2022 18:28:02 UTC] PHP   7. wpdb->__construct($dbuser = 'abc', $dbpassword = '123', $dbname = 'abc', $dbhost = 'localhost:3306') /home/xyz.com/public_html/wp-includes/load.php:561
[01-Jun-2022 18:28:02 UTC] PHP   8. wpdb->db_connect($allow_bail = *uninitialized*) /home/xyz.com/public_html/wp-includes/wp-db.php:724
[01-Jun-2022 18:28:02 UTC] PHP   9. mysqli_real_connect($mysql = class mysqli { public $client_info = 'mysqlnd 8.1.6'; public $client_version = 80106; public $connect_errno = 0; public $connect_error = NULL; public $errno = 0; public $error = '' }, $hostname = 'localhost', $username = 'abc', $password = '123', $database = NULL, $port = '3306', $socket = NULL, $flags = 0) /home/xyz.com/public_html/wp-includes/wp-db.php:1753

[01-Jun-2022 18:28:02 UTC] PHP Deprecated:  mysqli_real_connect(): Passing null to parameter #7 ($socket) of type ?string is deprecated in /home/xyz.com/public_html/wp-includes/wp-db.php on line 1753
[01-Jun-2022 18:28:02 UTC] PHP Stack trace:
[01-Jun-2022 18:28:02 UTC] PHP   1. {main}() /home/xyz.com/public_html/wp-admin/plugins.php:0
[01-Jun-2022 18:28:02 UTC] PHP   2. require_once() /home/xyz.com/public_html/wp-admin/plugins.php:10
[01-Jun-2022 18:28:02 UTC] PHP   3. require_once() /home/xyz.com/public_html/wp-admin/admin.php:34
[01-Jun-2022 18:28:02 UTC] PHP   4. require_once() /home/xyz.com/public_html/wp-load.php:50
[01-Jun-2022 18:28:02 UTC] PHP   5. require_once() /home/xyz.com/public_html/wp-config.php:130
[01-Jun-2022 18:28:02 UTC] PHP   6. require_wp_db() /home/xyz.com/public_html/wp-settings.php:124
[01-Jun-2022 18:28:02 UTC] PHP   7. wpdb->__construct($dbuser = 'abc', $dbpassword = '123', $dbname = 'abc', $dbhost = 'localhost:3306') /home/xyz.com/public_html/wp-includes/load.php:561
[01-Jun-2022 18:28:02 UTC] PHP   8. wpdb->db_connect($allow_bail = *uninitialized*) /home/xyz.com/public_html/wp-includes/wp-db.php:724
[01-Jun-2022 18:28:02 UTC] PHP   9. mysqli_real_connect($mysql = class mysqli { public $client_info = 'mysqlnd 8.1.6'; public $client_version = 80106; public $connect_errno = 0; public $connect_error = NULL; public $errno = 0; public $error = '' }, $hostname = 'localhost', $username = 'abc', $password = '123', $database = NULL, $port = '3306', $socket = NULL, $flags = 0) /home/xyz.com/public_html/wp-includes/wp-db.php:1753

They're just deprecation notices, so not a big deal. But I'm also getting a strange shift of items on my page.

With newrelic-php-agent enabled: image

With newrelic-php-agent disabled: image

This doesn't happen with newrelic enabled for either php 8.0 or 7.4. So, there's something going on with the newrelic-php-agent for 8.1.

Your Environment

Ubuntu 20.04 server OpenLiteSpeed V1.7.16 Wordpress 6.0

zsistla commented 2 years ago

Hello,

With the recent version of PHP, the default PHP error reporting was set to all like so: error_reporting = E_ALL. Here's a link that shows how to suppress e_deprecated notices by setting error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT. As a workaround, could you please try to suppress e_deprecated notices and see if that helps your issue?

If that doesn't work, we'll need to gather more details about the situation.

nickchomey commented 2 years ago

The problem seems to have gone away. I'm not sure what changed. I'll re-open the issue if it comes back and the ideas you shared fail to fix it. Sorry!

zsistla commented 2 years ago

Sounds good, thanks for keeping us updated :)

abdusfauzi commented 1 year ago

hi @zsistla,

I'm facing the same issue now. Should I open new ticket? Disabling newrelic.enabled = false stopped the Deprecation notice. I want to keep the Deprecation notice enabled.

Specs:

Thank you.

vlad-tanasescu-playmore commented 1 year ago

I'm having the same issue with newrelic active and php 8.1/8.2 The following code can be used to replicate it.

ini_set('display_errors', '1'); error_reporting(E_ALL);

$link = mysqli_init();

define('DB_USER', 'myuser'); define('DB_PASSWORD', 'mypass'); define('DB_NAME', null);

mysqli_real_connect($link, 'localhost', DB_USER, DB_PASSWORD, DB_NAME);