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

Add --defaults flag to allow loading of MySQL configuration #157

Merged
merged 9 commits into from
Jan 9, 2020
Merged

Add --defaults flag to allow loading of MySQL configuration #157

merged 9 commits into from
Jan 9, 2020

Conversation

ChrisWiegman
Copy link
Contributor

@ChrisWiegman ChrisWiegman commented Dec 12, 2019

This fix addresses issue #155

The Problem

The --no-defaults flag tells MySQL to ignore all .cnf files passed to it. While this works great in many situations, there are scenarios where it can break MySQL such as when the .cnf specifies an alternative socket file or other environment specific configuration items.

The Proposed Solution

This PR, after talking with @schlessera, fixes the issue by re-introducind the --defaults flag to the wp db command. When present, the --no-defaults flag normally passed to all MySQL commands is removed thereby allowing MySQL to make use of the MYSQL_HOME or other config variables.

@ChrisWiegman ChrisWiegman requested a review from a team as a code owner December 12, 2019 15:53
Copy link
Member

@schlessera schlessera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, this does what it should while keeping things consistent.

I have a few nitpicks I added as review comments. All of these apply to every instance of their corresponding usage across all sub commands, of course.

Also, I understand you were using private static for the helper method to keep with the current conventions. However, I intend to change some of these conventions that I "inherited"... ;)

README.md Outdated Show resolved Hide resolved
features/db-check.feature Show resolved Hide resolved
src/DB_Command.php Outdated Show resolved Hide resolved
src/DB_Command.php Outdated Show resolved Hide resolved
features/db-check.feature Outdated Show resolved Hide resolved
ChrisWiegman and others added 5 commits December 13, 2019 07:56
Co-Authored-By: Alain Schlesser <alain.schlesser@gmail.com>
Co-Authored-By: Alain Schlesser <alain.schlesser@gmail.com>
Co-Authored-By: Alain Schlesser <alain.schlesser@gmail.com>
@ChrisWiegman
Copy link
Contributor Author

@schlessera, I do believe I've addressed all your concerns. Per the static method issue, I had shared the concern but went with the existing paradigm. The new fixes change that but, note, also required a change to another private static method that had been calling the flags method. All tests still work, but I did want to call that out just in case. Please let me know if you find any further issues.

@ChrisWiegman
Copy link
Contributor Author

@schlessera, thank you for the clarification on the negation of flags. I didn't realize that from your initial comment. I've updated the flag login and added tests as appropriate.

@schlessera
Copy link
Member

@ChrisWiegman The PR works now and does what it should, thanks for keeping at it!

When opening it up in PHPStorm (and seeing more of the big picture of the file than here in the GitHub PR view), I realized that the file currently is a mess in terms of how it handles MySQL arguments, with one command passing all of them through, most others passing a subset, ...

As this is not directly related to your PR, I'll merge yours now, and then create a separate one to refactor a bit, so don't be surprised if I'm immediately swapping things around again after this was merged.

(Note to self: I should always open PRs in PHPStorm. It seems so convenient to only look in here, but you easily miss the bigger problems as large parts are just hidden by GH)

@schlessera schlessera added this to the 2.0.6 milestone Jan 9, 2020
@schlessera schlessera changed the title fix: Add usage of --defaults flag to allow loading of MySQL configs. Add --defaults flag to allow loading of MySQL configuration Jan 9, 2020
@schlessera schlessera merged commit 11895a7 into wp-cli:master Jan 9, 2020
@schlessera
Copy link
Member

Thanks for the PR, @ChrisWiegman !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants