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
08694d18
Commit
08694d18
authored
Oct 25, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Some optimizations and small fixes.
parent
ccf27a38
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
26 additions
and
46 deletions
+26
-46
CommitOrderCalculator.php
lib/Doctrine/ORM/Internal/CommitOrderCalculator.php
+10
-11
AssociationMapping.php
lib/Doctrine/ORM/Mapping/AssociationMapping.php
+0
-9
JoinedSubclassPersister.php
lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php
+1
-1
StandardEntityPersister.php
lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
+3
-10
UnitOfWork.php
lib/Doctrine/ORM/UnitOfWork.php
+11
-14
ClassTableInheritanceTest.php
...ctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php
+1
-1
No files found.
lib/Doctrine/ORM/Internal/CommitOrderCalculator.php
View file @
08694d18
...
...
@@ -40,14 +40,14 @@ class CommitOrderCalculator
private
$_sorted
=
array
();
/**
* Clears the current graph
and the last result
.
* Clears the current graph.
*
* @return void
*/
public
function
clear
()
{
$this
->
_
nodes
=
array
();
$this
->
_
sorted
=
array
();
$this
->
_
classes
=
$this
->
_
relatedClasses
=
array
();
}
/**
...
...
@@ -65,12 +65,10 @@ class CommitOrderCalculator
if
(
$nodeCount
==
0
)
{
return
array
();
}
else
if
(
$nodeCount
==
1
)
{
return
array
(
0
=>
array_pop
(
$this
->
_classes
)
);
return
array
_values
(
$this
->
_classes
);
}
// Init
$this
->
_sorted
=
array
();
$this
->
_nodeStates
=
array
();
foreach
(
$this
->
_classes
as
$node
)
{
$this
->
_nodeStates
[
$node
->
name
]
=
self
::
NOT_VISITED
;
}
...
...
@@ -82,7 +80,12 @@ class CommitOrderCalculator
}
}
return
array_reverse
(
$this
->
_sorted
);
$sorted
=
array_reverse
(
$this
->
_sorted
);
$this
->
_sorted
=
$this
->
_nodeStates
=
array
();
return
$sorted
;
}
private
function
_visitNode
(
$node
)
...
...
@@ -94,10 +97,6 @@ class CommitOrderCalculator
if
(
$this
->
_nodeStates
[
$relatedNode
->
name
]
==
self
::
NOT_VISITED
)
{
$this
->
_visitNode
(
$relatedNode
);
}
if
(
$this
->
_nodeStates
[
$relatedNode
->
name
]
==
self
::
IN_PROGRESS
)
{
// back edge => cycle
//TODO: anything to do here?
}
}
}
...
...
lib/Doctrine/ORM/Mapping/AssociationMapping.php
View file @
08694d18
...
...
@@ -51,15 +51,6 @@ abstract class AssociationMapping
*/
const
FETCH_EAGER
=
3
;
/**
* Cascade types enumeration.
*
* @var array
*/
protected
static
$_cascadeTypes
=
array
(
'all'
,
'none'
,
'save'
,
'delete'
,
'refresh'
,
'merge'
);
public
$cascades
=
array
();
public
$isCascadeRemove
;
public
$isCascadePersist
;
...
...
lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php
View file @
08694d18
...
...
@@ -214,7 +214,7 @@ class JoinedSubclassPersister extends StandardEntityPersister
$this
->
_prepareData
(
$entity
,
$updateData
);
$id
=
array_combine
(
$this
->
_class
->
getIdentifier
Field
Names
(),
$this
->
_class
->
getIdentifier
Column
Names
(),
$this
->
_em
->
getUnitOfWork
()
->
getEntityIdentifier
(
$entity
)
);
...
...
lib/Doctrine/ORM/Persisters/StandardEntityPersister.php
View file @
08694d18
...
...
@@ -205,7 +205,7 @@ class StandardEntityPersister
$updateData
=
array
();
$this
->
_prepareData
(
$entity
,
$updateData
);
$id
=
array_combine
(
$this
->
_class
->
identifier
,
$this
->
_class
->
getIdentifierColumnNames
()
,
$this
->
_em
->
getUnitOfWork
()
->
getEntityIdentifier
(
$entity
)
);
$tableName
=
$this
->
_class
->
primaryTable
[
'name'
];
...
...
@@ -251,8 +251,7 @@ class StandardEntityPersister
$sql
=
'UPDATE '
.
$tableName
.
' SET '
.
implode
(
', '
,
$set
)
.
' WHERE '
.
implode
(
' = ? AND '
,
array_keys
(
$where
))
.
' = ?'
;
.
' WHERE '
.
implode
(
' = ? AND '
,
array_keys
(
$where
))
.
' = ?'
;
$result
=
$this
->
_conn
->
executeUpdate
(
$sql
,
$params
);
...
...
@@ -352,7 +351,7 @@ class StandardEntityPersister
}
// Special case: One-one self-referencing of the same class.
if
(
$newVal
!==
null
&&
$assocMapping
->
sourceEntityName
==
$assocMapping
->
targetEntityName
)
{
if
(
$newVal
!==
null
/*&& $assocMapping->sourceEntityName == $assocMapping->targetEntityName*/
)
{
$oid
=
spl_object_hash
(
$newVal
);
$isScheduledForInsert
=
$uow
->
isScheduledForInsert
(
$newVal
);
if
(
isset
(
$this
->
_queuedInserts
[
$oid
])
||
$isScheduledForInsert
)
{
...
...
@@ -363,12 +362,6 @@ class StandardEntityPersister
$field
=>
array
(
null
,
$newVal
)
));
$newVal
=
null
;
}
else
if
(
$isInsert
&&
!
$isScheduledForInsert
&&
$uow
->
getEntityState
(
$newVal
)
==
UnitOfWork
::
STATE_MANAGED
)
{
// $newVal is already fully persisted.
// Schedule an extra update for it, so that the foreign key(s) are properly set.
$uow
->
scheduleExtraUpdate
(
$newVal
,
array
(
$field
=>
array
(
null
,
$entity
)
));
}
}
...
...
lib/Doctrine/ORM/UnitOfWork.php
View file @
08694d18
...
...
@@ -265,15 +265,15 @@ class UnitOfWork implements PropertyChangedListener
$this
->
_orphanRemovals
))
{
return
;
// Nothing to do.
}
// Now we need a commit order to maintain referential integrity
$commitOrder
=
$this
->
_getCommitOrder
();
if
(
$this
->
_orphanRemovals
)
{
foreach
(
$this
->
_orphanRemovals
as
$orphan
)
{
$this
->
remove
(
$orphan
);
}
}
// Now we need a commit order to maintain referential integrity
$commitOrder
=
$this
->
_getCommitOrder
();
$conn
=
$this
->
_em
->
getConnection
();
...
...
@@ -681,7 +681,7 @@ class UnitOfWork implements PropertyChangedListener
}
foreach
(
$this
->
_entityInsertions
as
$oid
=>
$entity
)
{
if
(
get_class
(
$entity
)
==
$className
)
{
if
(
get_class
(
$entity
)
==
=
$className
)
{
$persister
->
addInsert
(
$entity
);
unset
(
$this
->
_entityInsertions
[
$oid
]);
if
(
$hasLifecycleCallbacks
||
$hasListeners
)
{
...
...
@@ -802,15 +802,14 @@ class UnitOfWork implements PropertyChangedListener
$this
->
_entityDeletions
);
}
// TODO: We can cache computed commit orders in the metadata cache!
// Check cache at this point here!
// See if there are any new classes in the changeset, that are not in the
// commit order graph yet (dont have a node).
$newNodes
=
array
();
foreach
(
$entityChangeSet
as
$entity
)
{
$classesInChangeSet
=
array
();
foreach
(
$entityChangeSet
as
$oid
=>
$entity
)
{
$className
=
get_class
(
$entity
);
$classesInChangeSet
[
$className
]
=
true
;
if
(
!
$this
->
_commitOrderCalculator
->
hasClass
(
$className
))
{
$class
=
$this
->
_em
->
getClassMetadata
(
$className
);
$this
->
_commitOrderCalculator
->
addClass
(
$class
);
...
...
@@ -820,14 +819,12 @@ class UnitOfWork implements PropertyChangedListener
// Calculate dependencies for new nodes
foreach
(
$newNodes
as
$class
)
{
foreach
(
$class
->
associationMappings
as
$assocMapping
)
{
//TODO: should skip target classes that are not in the changeset.
if
(
$assocMapping
->
isOwningSide
)
{
$targetClass
=
$this
->
_em
->
getClassMetadata
(
$assocMapping
->
targetEntityName
);
foreach
(
$class
->
associationMappings
as
$assoc
)
{
if
(
$assoc
->
isOwningSide
&&
$assoc
->
isOneToOne
()
&&
isset
(
$classesInChangeSet
[
$assoc
->
targetEntityName
]))
{
$targetClass
=
$this
->
_em
->
getClassMetadata
(
$assoc
->
targetEntityName
);
if
(
!
$this
->
_commitOrderCalculator
->
hasClass
(
$targetClass
->
name
))
{
$this
->
_commitOrderCalculator
->
addClass
(
$targetClass
);
}
// add dependency ($targetClass before $class)
$this
->
_commitOrderCalculator
->
addDependency
(
$targetClass
,
$class
);
}
}
...
...
tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php
View file @
08694d18
...
...
@@ -44,7 +44,7 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
_em
->
clear
();
$query
=
$this
->
_em
->
createQuery
(
"select p from Doctrine\Tests\Models\Company\CompanyPerson p order by p.
id a
sc"
);
$query
=
$this
->
_em
->
createQuery
(
"select p from Doctrine\Tests\Models\Company\CompanyPerson p order by p.
name de
sc"
);
$entities
=
$query
->
getResult
();
...
...
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