Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
3c199249
Unverified
Commit
3c199249
authored
Jun 18, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.10.x' into 2.11.x
parents
6131db39
78de4498
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
17 deletions
+44
-17
PortWithoutHost.php
...e/DBAL/Driver/AbstractSQLServerDriver/PortWithoutHost.php
+20
-0
Driver.php
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
+6
-3
Driver.php
lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php
+10
-6
AbstractSQLServerDriverTest.php
...octrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php
+8
-8
No files found.
lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/PortWithoutHost.php
0 → 100644
View file @
3c199249
<?php
declare
(
strict_types
=
1
);
namespace
Doctrine\DBAL\Driver\AbstractSQLServerDriver
;
use
Doctrine\DBAL\Driver\AbstractDriverException
;
/**
* @internal
*
* @psalm-immutable
*/
final
class
PortWithoutHost
extends
AbstractDriverException
{
public
static
function
new
()
:
self
{
return
new
self
(
'Connection port specified without the host'
);
}
}
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
View file @
3c199249
...
...
@@ -3,6 +3,7 @@
namespace
Doctrine\DBAL\Driver\PDOSqlsrv
;
use
Doctrine\DBAL\Driver\AbstractSQLServerDriver
;
use
Doctrine\DBAL\Driver\AbstractSQLServerDriver\PortWithoutHost
;
use
function
is_int
;
use
function
sprintf
;
...
...
@@ -49,10 +50,12 @@ class Driver extends AbstractSQLServerDriver
if
(
isset
(
$params
[
'host'
]))
{
$dsn
.=
$params
[
'host'
];
}
if
(
isset
(
$params
[
'port'
])
&&
!
empty
(
$params
[
'port'
]))
{
$dsn
.=
','
.
$params
[
'port'
];
if
(
isset
(
$params
[
'port'
]))
{
$dsn
.=
','
.
$params
[
'port'
];
}
}
elseif
(
isset
(
$params
[
'port'
]))
{
throw
PortWithoutHost
::
new
();
}
if
(
isset
(
$params
[
'dbname'
]))
{
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php
View file @
3c199249
...
...
@@ -3,6 +3,7 @@
namespace
Doctrine\DBAL\Driver\SQLSrv
;
use
Doctrine\DBAL\Driver\AbstractSQLServerDriver
;
use
Doctrine\DBAL\Driver\AbstractSQLServerDriver\PortWithoutHost
;
/**
* Driver for ext/sqlsrv.
...
...
@@ -14,13 +15,16 @@ class Driver extends AbstractSQLServerDriver
*/
public
function
connect
(
array
$params
,
$username
=
null
,
$password
=
null
,
array
$driverOptions
=
[])
{
if
(
!
isset
(
$params
[
'host'
]))
{
throw
new
SQLSrvException
(
"Missing 'host' in configuration for sqlsrv driver."
);
}
$serverName
=
''
;
if
(
isset
(
$params
[
'host'
]))
{
$serverName
=
$params
[
'host'
];
$serverName
=
$params
[
'host'
];
if
(
isset
(
$params
[
'port'
]))
{
$serverName
.=
', '
.
$params
[
'port'
];
if
(
isset
(
$params
[
'port'
]))
{
$serverName
.=
','
.
$params
[
'port'
];
}
}
elseif
(
isset
(
$params
[
'port'
]))
{
throw
PortWithoutHost
::
new
();
}
if
(
isset
(
$params
[
'dbname'
]))
{
...
...
tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php
View file @
3c199249
...
...
@@ -3,8 +3,7 @@
namespace
Doctrine\Tests\DBAL\Driver
;
use
Doctrine\DBAL\Connection
;
use
Doctrine\DBAL\Driver
;
use
Doctrine\DBAL\Driver\AbstractSQLServerDriver
;
use
Doctrine\DBAL\Driver\AbstractSQLServerDriver\PortWithoutHost
;
use
Doctrine\DBAL\Platforms\AbstractPlatform
;
use
Doctrine\DBAL\Platforms\SQLServer2005Platform
;
use
Doctrine\DBAL\Platforms\SQLServer2008Platform
;
...
...
@@ -13,13 +12,8 @@ use Doctrine\DBAL\Platforms\SQLServerPlatform;
use
Doctrine\DBAL\Schema\AbstractSchemaManager
;
use
Doctrine\DBAL\Schema\SQLServerSchemaManager
;
class
AbstractSQLServerDriverTest
extends
AbstractDriverTest
abstract
class
AbstractSQLServerDriverTest
extends
AbstractDriverTest
{
protected
function
createDriver
()
:
Driver
{
return
$this
->
getMockForAbstractClass
(
AbstractSQLServerDriver
::
class
);
}
protected
function
createPlatform
()
:
AbstractPlatform
{
return
new
SQLServer2008Platform
();
...
...
@@ -64,4 +58,10 @@ class AbstractSQLServerDriverTest extends AbstractDriverTest
[
'12'
,
SQLServer2012Platform
::
class
],
];
}
public
function
testPortWithoutHost
()
:
void
{
$this
->
expectException
(
PortWithoutHost
::
class
);
$this
->
driver
->
connect
([
'port'
=>
1433
]);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment