Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: resolve warnings in php 8 #56

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

heyjones
Copy link

Resolves the following warnings when upgrading to PHP 8:

  • compact(): Undefined variable $server in db.php on line 722
  • Undefined variable $server in db.php on line 726

Resolves the following warnings when upgrading to PHP 8:
-  compact(): Undefined variable $server in db.php on line 722
-  Undefined variable $server in db.php on line 726
@heyjones
Copy link
Author

I’m assuming there’s a better default for this than null but I’m not that familiar with the rest of the code.

@sjinks
Copy link
Member

sjinks commented Jun 19, 2022

@rinatkhaziev could you please take a look as well?

@sjinks sjinks requested a review from rinatkhaziev June 19, 2022 23:33
@rinatkhaziev
Copy link
Contributor

@heyjones could you please provide steps to reproduce the issue? I'm not able to trigger the behavior you describe on a regular request.

@heyjones
Copy link
Author

@rinatkhaziev here are the constants in my wp-config.php:

define( 'DB_NAME', 'local' );
define( 'DB_USER', 'root' );
define( 'DB_PASSWORD', 'root' );
define( 'DB_HOST', 'localhost' );

define( 'RO_NAME', 'local' );
define( 'RO_USER', 'root' );
define( 'RO_PASSWORD', 'root' );
define( 'RO_HOST', 'localhost' );

define( 'WP_ENVIRONMENT_TYPE', 'development' );

They match locally since I only have one db, but in prod they vary. I see this error in wp-admin:

Warning: compact(): Undefined variable $server in /Users/jones/Sites/collectivist.local/app/public/wp-content/db.php on line 722

When applying the code in this PR, the warning is removed. I'm open to suggestions for a better solution, or since I don't have WP_DEBUG set in prod I assume I won't even see these PHP warnings but figured I'd submit this anyways. Thanks!

@heyjones
Copy link
Author

When I tail my logs locally, I do see several instances of this error:

WordPress database error 2022-06-22 14:47:11 Can't select global__r - 
'referrer' => 'wp.local/',
'server' => ,
'host' => localhost,
'error' => ,
'errno' => 0,
'server_state' => down [ > 0.2 ] (61) 'Connection refused'
'lagged_status' => 3 for query 
			SELECT  wp_blogs.blog_id
			FROM wp_blogs 
			WHERE domain = 'wp.local' AND path = '/'
			ORDER BY wp_blogs.blog_id ASC
			LIMIT 1
		 made by WP_Site_Query::get_site_ids

@sonarcloud
Copy link

sonarcloud bot commented Feb 18, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

hj-collab added a commit to hj-collab/HyperDB that referenced this pull request May 31, 2023
@hj-collab hj-collab mentioned this pull request May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants