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
91f65efc
Commit
91f65efc
authored
Sep 30, 2010
by
Lukas Kahwe Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent changing savepoint behavior inside an open transaction
parent
6107a68f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
0 deletions
+15
-0
Connection.php
lib/Doctrine/DBAL/Connection.php
+4
-0
ConnectionException.php
lib/Doctrine/DBAL/ConnectionException.php
+5
-0
ConnectionTest.php
tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
+6
-0
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
91f65efc
...
@@ -754,6 +754,10 @@ class Connection implements DriverConnection
...
@@ -754,6 +754,10 @@ class Connection implements DriverConnection
*/
*/
public
function
setNestTransactionsWithSavepoints
(
$nestTransactionsWithSavepoints
)
public
function
setNestTransactionsWithSavepoints
(
$nestTransactionsWithSavepoints
)
{
{
if
(
$this
->
_transactionNestingLevel
>
0
)
{
throw
ConnectionException
::
mayNotAlterNestedTransactionWithSavepointsInTransaction
();
}
if
(
$nestTransactionsWithSavepoints
&&
!
$this
->
_platform
->
supportsSavepoints
())
{
if
(
$nestTransactionsWithSavepoints
&&
!
$this
->
_platform
->
supportsSavepoints
())
{
ConnectionException
::
savepointsNotSupported
();
ConnectionException
::
savepointsNotSupported
();
}
}
...
...
lib/Doctrine/DBAL/ConnectionException.php
View file @
91f65efc
...
@@ -46,4 +46,9 @@ class ConnectionException extends DBALException
...
@@ -46,4 +46,9 @@ class ConnectionException extends DBALException
{
{
return
new
self
(
"Savepoints are not supported transaction."
);
return
new
self
(
"Savepoints are not supported transaction."
);
}
}
public
static
function
mayNotAlterNestedTransactionWithSavepointsInTransaction
()
{
return
new
self
(
"May not alter the nested transaction with savepoints behavior while a transaction is open."
);
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
View file @
91f65efc
...
@@ -77,6 +77,12 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
...
@@ -77,6 +77,12 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
//no rethrow
//no rethrow
}
}
$this
->
assertFalse
(
$this
->
_conn
->
isRollbackOnly
());
$this
->
assertFalse
(
$this
->
_conn
->
isRollbackOnly
());
try
{
$this
->
_conn
->
setNestTransactionsWithSavepoints
(
false
);
$this
->
fail
(
'Should not be able to disable savepoints in usage for nested transactions inside an open transaction.'
);
}
catch
(
ConnectionException
$e
)
{
$this
->
assertTrue
(
$this
->
_conn
->
getNestTransactionsWithSavepoints
());
}
$this
->
_conn
->
commit
();
// should not throw exception
$this
->
_conn
->
commit
();
// should not throw exception
}
catch
(
ConnectionException
$e
)
{
}
catch
(
ConnectionException
$e
)
{
$this
->
fail
(
'Transaction commit after failed nested transaction should not fail when using savepoints.'
);
$this
->
fail
(
'Transaction commit after failed nested transaction should not fail when using savepoints.'
);
...
...
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