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
85ec5066
Commit
85ec5066
authored
Jul 06, 2007
by
gnat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some an infinite recursion when deleting records that reference each other with ownsOne
parent
56768b61
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
5 deletions
+67
-5
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+10
-1
Record.php
lib/Doctrine/Record.php
+3
-3
LockTestCase.php
tests/Record/LockTestCase.php
+52
-0
run.php
tests/run.php
+2
-1
No files found.
lib/Doctrine/Connection/UnitOfWork.php
View file @
85ec5066
...
...
@@ -221,8 +221,12 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
$event
=
new
Doctrine_Event
(
$this
,
Doctrine_Event
::
RECORD_DELETE
);
$record
->
preDelete
(
$event
);
$record
->
state
(
Doctrine_Record
::
STATE_LOCKED
);
$this
->
deleteComposites
(
$record
);
$record
->
state
(
Doctrine_Record
::
STATE_TDIRTY
);
if
(
!
$event
->
skipOperation
)
{
$this
->
conn
->
transaction
->
addDelete
(
$record
);
...
...
@@ -329,7 +333,12 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
case
Doctrine_Relation
::
ONE_COMPOSITE
:
case
Doctrine_Relation
::
MANY_COMPOSITE
:
$obj
=
$record
->
get
(
$fk
->
getAlias
());
$obj
->
delete
(
$this
->
conn
);
if
(
$obj
instanceof
Doctrine_Record
&&
$obj
->
state
()
!=
Doctrine_Record
::
STATE_LOCKED
)
{
$obj
->
delete
(
$this
->
conn
);
}
break
;
}
}
...
...
lib/Doctrine/Record.php
View file @
85ec5066
...
...
@@ -65,10 +65,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count
*/
const
STATE_TCLEAN
=
5
;
/**
*
DELET
ED STATE
* a Doctrine_Record
turns into deleted state when it is deleted
*
LOCK
ED STATE
* a Doctrine_Record
is temporarily locked during deletes
*/
const
STATE_
DELET
ED
=
6
;
const
STATE_
LOCK
ED
=
6
;
/**
* @var object Doctrine_Table $_table the factory that created this data access object
*/
...
...
tests/Record/LockTestCase.php
0 → 100644
View file @
85ec5066
<?php
class
Doctrine_Record_Lock_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareTables
()
{
$this
->
tables
[]
=
'rec1'
;
$this
->
tables
[]
=
'rec2'
;
parent
::
prepareTables
();
}
public
function
prepareData
()
{
}
public
function
testDeleteRecords
()
{
$rec1
=
new
Rec1
();
$rec1
->
first_name
=
'Some name'
;
$rec1
->
Account
=
new
Rec2
();
$rec1
->
Account
->
address
=
'Some address'
;
$rec1
->
save
();
$rec1
->
delete
();
$this
->
pass
();
}
}
class
Rec1
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'first_name'
,
'string'
,
128
,
array
());
}
public
function
setUp
()
{
$this
->
ownsOne
(
'Rec2 as Account'
,
array
(
'local'
=>
'id'
,
'foreign'
=>
'user_id'
));
}
}
class
Rec2
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'user_id'
,
'integer'
,
10
,
array
(
'unique'
=>
true
,));
$this
->
hasColumn
(
'address'
,
'string'
,
150
,
array
());
}
public
function
setUp
()
{
$this
->
ownsOne
(
'Rec1 as User'
,
'Rec2.user_id'
);
}
}
tests/run.php
View file @
85ec5066
...
...
@@ -280,7 +280,8 @@ $test->addTestCase(new Doctrine_NewCore_TestCase());
$test
->
addTestCase
(
new
Doctrine_Record_State_TestCase
());
// This test used to segfault php because of infinite recursion in Connection/UnitOfWork
$test
->
addTestCase
(
new
Doctrine_Record_Lock_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Tokenizer_TestCase
());
...
...
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