Skip to content

Commit

Permalink
Changing implementation to *try* to connect
Browse files Browse the repository at this point in the history
For me, this makes more sense. Without this, if getDatabasePlatform() is called
consistently before connection(), then the platform will *never* connect to
get the version and use the *best* platform - it will always use the fallback.
This *does* use the connection, but doesn't explode for the edge cases when
the connection information is invalid.
  • Loading branch information
weaverryan committed Jan 23, 2015
1 parent 8193333 commit 2db254d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
namespace Doctrine\DBAL;

use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use PDO;
use Closure;
Expand Down Expand Up @@ -429,7 +430,12 @@ private function getDatabasePlatformVersion()
// cause an error in our application when determining the platform
// version is not mission-critical
if (null === $this->_conn) {
return null;
try {
$this->connect();
} catch (DriverException $e) {
// i.e. connection params are invalid or db doesn't exist
return null;
}
}

// Automatic platform version detection.
Expand Down

0 comments on commit 2db254d

Please sign in to comment.