Filter empty database parameters to prevent MySQL command failures #308
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
MySQL commands fail when
DB_HOST,DB_USER,DB_PASSWORD, orDB_CHARSETare defined as empty strings inwp-config.php. Empty values are passed as--host= --user= --default-character-set=, which MySQL rejects with errors likeCharacter set '' is not a compiled character set.Changes
DB_Command::run(): Addedarray_filterto strip empty strings and null values from the$requiredarray before passing to MySQL commands'0'and integer0are kept (valid for ports/values)DB_CHARSETdoesn't generate invalid command-line argumentsImplementation
Applies to all commands using the
run()method:check,optimize,repair,cli,query,export,import, etc.Original prompt
This section details on the original issue you should resolve
<issue_title>mysqlcheck: Character set '' is not a compiled character set</issue_title>
<issue_description>## Bug Report
When running commands related to
dbat hostinger, I get the following error.Hostinger support said it's a bug with the wp-cli, and my debug shows the same..
Describe the current, buggy behavior
When running
wp db checkin any of my wp installs at hostinger, I get the following:With debug...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.