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
ec6da750
Commit
ec6da750
authored
Nov 07, 2014
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
DBAL-920 - Merge branch 'hotfix/#714-disable-prepares-on-pgsql-for-php-5.6'
Close #714
parents
6458b0bd
cbf95ea0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
1 deletion
+111
-1
Driver.php
lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
+12
-1
DriverTest.php
tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
+99
-0
No files found.
lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php
View file @
ec6da750
...
...
@@ -23,6 +23,7 @@ use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use
Doctrine\DBAL\Driver\PDOConnection
;
use
Doctrine\DBAL\DBALException
;
use
PDOException
;
use
PDO
;
/**
* Driver that connects through pdo_pgsql.
...
...
@@ -37,12 +38,22 @@ class Driver extends AbstractPostgreSQLDriver
public
function
connect
(
array
$params
,
$username
=
null
,
$password
=
null
,
array
$driverOptions
=
array
())
{
try
{
return
new
PDOConnection
(
$pdo
=
new
PDOConnection
(
$this
->
_constructPdoDsn
(
$params
),
$username
,
$password
,
$driverOptions
);
if
(
PHP_VERSION_ID
>=
50600
&&
(
!
isset
(
$driverOptions
[
PDO
::
PGSQL_ATTR_DISABLE_PREPARES
])
||
true
===
$driverOptions
[
PDO
::
PGSQL_ATTR_DISABLE_PREPARES
]
)
)
{
$pdo
->
setAttribute
(
PDO
::
PGSQL_ATTR_DISABLE_PREPARES
,
true
);
}
return
$pdo
;
}
catch
(
PDOException
$e
)
{
throw
DBALException
::
driverException
(
$this
,
$e
);
}
...
...
tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php
View file @
ec6da750
...
...
@@ -4,6 +4,8 @@ namespace Doctrine\Tests\DBAL\Driver\PDOPgSql;
use
Doctrine\DBAL\Driver\PDOPgSql\Driver
;
use
Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest
;
use
PDO
;
use
PDOException
;
class
DriverTest
extends
AbstractPostgreSQLDriverTest
{
...
...
@@ -12,8 +14,105 @@ class DriverTest extends AbstractPostgreSQLDriverTest
$this
->
assertSame
(
'pdo_pgsql'
,
$this
->
driver
->
getName
());
}
/**
* @group DBAL-920
*/
public
function
testConnectionDisablesPreparesOnPhp56
()
{
$this
->
skipWhenNotUsingPhp56AndPdoPgsql
();
$connection
=
$this
->
createDriver
()
->
connect
(
array
(
'host'
=>
$GLOBALS
[
'db_host'
],
'port'
=>
$GLOBALS
[
'db_port'
]
),
$GLOBALS
[
'db_username'
],
$GLOBALS
[
'db_password'
]
);
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Driver\PDOConnection'
,
$connection
);
try
{
$this
->
assertTrue
(
$connection
->
getAttribute
(
PDO
::
PGSQL_ATTR_DISABLE_PREPARES
));
}
catch
(
PDOException
$ignored
)
{
/** @link https://bugs.php.net/bug.php?id=68371 */
$this
->
markTestIncomplete
(
'See https://bugs.php.net/bug.php?id=68371'
);
}
}
/**
* @group DBAL-920
*/
public
function
testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined
()
{
$this
->
skipWhenNotUsingPhp56AndPdoPgsql
();
$connection
=
$this
->
createDriver
()
->
connect
(
array
(
'host'
=>
$GLOBALS
[
'db_host'
],
'port'
=>
$GLOBALS
[
'db_port'
]
),
$GLOBALS
[
'db_username'
],
$GLOBALS
[
'db_password'
],
array
(
PDO
::
PGSQL_ATTR_DISABLE_PREPARES
=>
false
)
);
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Driver\PDOConnection'
,
$connection
);
try
{
$this
->
assertNotSame
(
true
,
$connection
->
getAttribute
(
PDO
::
PGSQL_ATTR_DISABLE_PREPARES
));
}
catch
(
PDOException
$ignored
)
{
/** @link https://bugs.php.net/bug.php?id=68371 */
$this
->
markTestIncomplete
(
'See https://bugs.php.net/bug.php?id=68371'
);
}
}
/**
* @group DBAL-920
*/
public
function
testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplicitlyDefined
()
{
$this
->
skipWhenNotUsingPhp56AndPdoPgsql
();
$connection
=
$this
->
createDriver
()
->
connect
(
array
(
'host'
=>
$GLOBALS
[
'db_host'
],
'port'
=>
$GLOBALS
[
'db_port'
]
),
$GLOBALS
[
'db_username'
],
$GLOBALS
[
'db_password'
],
array
(
PDO
::
PGSQL_ATTR_DISABLE_PREPARES
=>
true
)
);
$this
->
assertInstanceOf
(
'Doctrine\DBAL\Driver\PDOConnection'
,
$connection
);
try
{
$this
->
assertTrue
(
$connection
->
getAttribute
(
PDO
::
PGSQL_ATTR_DISABLE_PREPARES
));
}
catch
(
PDOException
$ignored
)
{
/** @link https://bugs.php.net/bug.php?id=68371 */
$this
->
markTestIncomplete
(
'See https://bugs.php.net/bug.php?id=68371'
);
}
}
/**
* {@inheritDoc}
*/
protected
function
createDriver
()
{
return
new
Driver
();
}
/**
* @throws \PHPUnit_Framework_SkippedTestError
*/
private
function
skipWhenNotUsingPhp56AndPdoPgsql
()
{
if
(
PHP_VERSION_ID
<
50600
)
{
$this
->
markTestSkipped
(
'Test requires PHP 5.6+'
);
}
if
(
!
(
isset
(
$GLOBALS
[
'db_type'
])
&&
$GLOBALS
[
'db_type'
]
===
'pdo_pgsql'
))
{
$this
->
markTestSkipped
(
'Test enabled only when using pdo_pgsql specific phpunit.xml'
);
}
}
}
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