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

[5.1] Give appropriate warning when changing columns if Doctrine DBAL is not available. #10002

Merged

Conversation

simensen
Copy link
Contributor

Obvious in the docs is one thing. Obvious when writing code and you hadn't seen it in the docs is another. Somewhat related to #590, I thought it would have been super helpful if the exception I was shown in the console output had told me more about what was wrong than just fatalling because Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found.

I could have put the exception in getDoctrineConnection (and still could, probably) but I thought that adding isDoctrineAvailable would let things further out do more meaningful messages when something requires Doctrine but it is not available. For example, I now see Changing columns for table "lesson_templates" requires Doctrine DBAL; install "doctrine/dbal". which tells me exactly why Doctrine is required, not just that it needs to be installed.

Happy to adjust this as needed. Happy to throw a more general exception in getDoctrineConnection as well, either as a part of this PR or in a follow-up PR.

@@ -279,6 +279,13 @@ protected function getDoctrineTableDiff(Blueprint $blueprint, SchemaManager $sch
*/
public function compileChange(Blueprint $blueprint, Fluent $command, Connection $connection)
{
if (! $connection->isDoctrineAvailable()) {
throw new \RuntimeException(sprintf(
Copy link
Member

Choose a reason for hiding this comment

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

import this please

@GrahamCampbell
Copy link
Member

This is breaking so should probably go to 5.2 not 5.1. Don't do anything yet though. Taylor might not agree with me. Ping @taylorotwell.

@GrahamCampbell GrahamCampbell changed the title Give appropriate warning when changing columns if Doctrine DBAL is not available. [5.1] Give appropriate warning when changing columns if Doctrine DBAL is not available. Aug 20, 2015
@simensen
Copy link
Contributor Author

@GrahamCampbell Is this breaking? Is it because I added a method to a class? The other thing I could have done here would be to have done the class exists call in Grammar itself. If that makes it non-breaking I'd be happier doing that as I think it would be useful for people in 5.1 as well. I'm not exactly sure how things are ported between versions. :)

If it is breaking because it throws an exception, I'm not sure that is true. It would have / should have thrown an exception or fatal anyway; this just does it earlier than it would have with a more developer-friendly message.

@GrahamCampbell
Copy link
Member

It's breaking because the behaviour has been changed.

@simensen
Copy link
Contributor Author

@GrahamCampbell ok. if throwing an exception instead of letting a fatal happen is enough to cause this to be a breaking change and if @taylorotwell says to target 5.2 instead i'm all in! :)

@GrahamCampbell
Copy link
Member

What I'm saying is, sure, it's a breaking change, but, Taylor might be ok with it, given the context. :)

taylorotwell added a commit that referenced this pull request Aug 21, 2015
…arning

[5.1] Give appropriate warning when changing columns if Doctrine DBAL is not available.
@taylorotwell taylorotwell merged commit 800d2f3 into laravel:5.1 Aug 21, 2015
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