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

[11.x] Remove isset assumption on MYSQL Schema Connection #51405

Closed
wants to merge 1 commit into from

Conversation

liamh101
Copy link
Contributor

It is common for PDO::MYSQL_ATTR_SSL_CA to be set in database.php but have it disabled or empty, normally controlled by as an environment variable.

In the MySQL schema state, it is assumed that the PDO array element must contain data if it is set.

This causes errors when dumping schema files or importing schema files during migrations.

I've added a check in the original if statement and a test that replicates the original behaviour.

…ections

It's valid for the PDO option is set but an empty string or null, especially on local machines
@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions!

If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response.

@liamh101
Copy link
Contributor Author

Hi @taylorotwell,

This bug fix can't be fixed with an external package and causes an error for all MYSQL 8 users trying to take or import a migration schema dump.

Use Case:

MYSQL 8 requires a Certificate in a production environment; however, local dev isn't needed.

Laravel, by default sets the MYSQL_ATTR_SSL_CA flag on all databases if the PDO extension is loaded and the CA is controlled by the environment variable MYSQL_ATTR_SSL_CA by default in database.php.

The issue occurs when taking schema dumps or imports for migrations. Because MYSQL_ATTR_SSL_CA is always set and controlled by an env variable, the array element is always set. However, because the value inside the element isn't checked, an empty certificate flag is added to the command, causing an error with MYSQL.

Replication

  • Create a new Laravel Project with a MYSQL 8 docker image. (the local docker image does not require a cert)
  • Set up a dummy table with some data.
  • Try to take a schema dump.

Fix

Before appending the flag, ensure the element is set and has data set.

Apologies for the late reply. I've been away all week.

Anymore questions or clarifications, just let me know.

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

2 participants