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
4b71afe7
Commit
4b71afe7
authored
Apr 18, 2010
by
Roman S. Borschel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improving metadata caching performance by only serializing what is absolutely necessary.
parent
4b39705c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
170 additions
and
30 deletions
+170
-30
Parser.php
lib/Doctrine/Common/Annotations/Parser.php
+1
-3
AssociationMapping.php
lib/Doctrine/ORM/Mapping/AssociationMapping.php
+54
-1
ClassMetadata.php
lib/Doctrine/ORM/Mapping/ClassMetadata.php
+49
-20
ManyToManyMapping.php
lib/Doctrine/ORM/Mapping/ManyToManyMapping.php
+21
-2
OneToManyMapping.php
lib/Doctrine/ORM/Mapping/OneToManyMapping.php
+21
-2
OneToOneMapping.php
lib/Doctrine/ORM/Mapping/OneToOneMapping.php
+22
-2
ClassMetadataTest.php
tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
+2
-0
No files found.
lib/Doctrine/Common/Annotations/Parser.php
View file @
4b71afe7
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -250,7 +248,7 @@ class Parser
// Is it really an annotation class?
if
(
(
!
$this
->
_isNestedAnnotation
&&
$this
->
_lexer
->
lookahead
!=
null
&&
(
!
$this
->
_isNestedAnnotation
&&
$this
->
_lexer
->
lookahead
!=
null
&&
!
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_OPEN_PARENTHESIS
)
&&
!
$this
->
_lexer
->
isNextToken
(
Lexer
::
T_AT
))
||
!
class_exists
(
$name
,
false
)
...
...
lib/Doctrine/ORM/Mapping/AssociationMapping.php
View file @
4b71afe7
...
...
@@ -340,5 +340,58 @@ abstract class AssociationMapping
?
$platform
->
quoteIdentifier
(
$this
->
joinTable
[
'name'
])
:
$this
->
joinTable
[
'name'
];
}
/**
* Determines which fields get serialized.
*
* It is only serialized what is necessary for best unserialization performance.
* That means any metadata properties that are not set or empty or simply have
* their default value are NOT serialized.
*
* @return array The names of all the fields that should be serialized.
*/
public
function
__sleep
()
{
$serialized
=
array
(
'sourceEntityName'
,
'targetEntityName'
,
'sourceFieldName'
);
if
(
$this
->
isCascadeDetach
)
{
$serialized
[]
=
'isCascadeDetach'
;
}
if
(
$this
->
isCascadeMerge
)
{
$serialized
[]
=
'isCascadeMerge'
;
}
if
(
$this
->
isCascadePersist
)
{
$serialized
[]
=
'isCascadePersist'
;
}
if
(
$this
->
isCascadeRefresh
)
{
$serialized
[]
=
'isCascadeRefresh'
;
}
if
(
$this
->
isCascadeRemove
)
{
$serialized
[]
=
'isCascadeRemove'
;
}
if
(
!
$this
->
isOwningSide
)
{
$serialized
[]
=
'isOwningSide'
;
}
if
(
$this
->
mappedBy
)
{
$serialized
[]
=
'mappedBy'
;
}
if
(
$this
->
inversedBy
)
{
$serialized
[]
=
'inversedBy'
;
}
if
(
$this
->
joinTable
)
{
$serialized
[]
=
'joinTable'
;
}
if
(
$this
->
inherited
)
{
$serialized
[]
=
'inherited'
;
}
if
(
$this
->
declared
)
{
$serialized
[]
=
'declared'
;
}
return
$serialized
;
}
}
lib/Doctrine/ORM/Mapping/ClassMetadata.php
View file @
4b71afe7
...
...
@@ -264,8 +264,12 @@ class ClassMetadata extends ClassMetadataInfo
/**
* Determines which fields get serialized.
*
* It is only serialized what is necessary for best unserialization performance.
* That means any metadata properties that are not set or empty or simply have
* their default value are NOT serialized.
*
* Parts that are NOT serialized because they can not be properly unserialized:
* Parts that are
also
NOT serialized because they can not be properly unserialized:
* - reflClass (ReflectionClass)
* - reflFields (ReflectionProperty array)
*
...
...
@@ -273,31 +277,56 @@ class ClassMetadata extends ClassMetadataInfo
*/
public
function
__sleep
()
{
return
array
(
'associationMappings'
,
// unserialization "bottleneck" with many associations
'
changeTrackingPolicy
'
,
// This metadata is always serialized/cached.
$serialized
=
array
(
'
associationMappings
'
,
'columnNames'
,
//TODO: Not really needed. Can use fieldMappings[$fieldName]['columnName']
'customRepositoryClassName'
,
'discriminatorColumn'
,
'discriminatorValue'
,
'discriminatorMap'
,
'fieldMappings'
,
//TODO: Not all of this stuff needs to be serialized. Only type, columnName and fieldName.
'fieldNames'
,
'generatorType'
,
'fieldMappings'
,
'fieldNames'
,
'identifier'
,
'idGenerator'
,
//TODO: Does not really need to be serialized. Could be moved to runtime.
'inheritanceType'
,
'isIdentifierComposite'
,
'isMappedSuperclass'
,
'isVersioned'
,
'lifecycleCallbacks'
,
'isIdentifierComposite'
,
// TODO: REMOVE
'name'
,
'parentClasses'
,
'table'
,
'rootEntityName'
,
'subClasses'
,
'versionField'
'idGenerator'
,
//TODO: Does not really need to be serialized. Could be moved to runtime.
);
// The rest of the metadata is only serialized if necessary.
if
(
$this
->
changeTrackingPolicy
!=
self
::
CHANGETRACKING_DEFERRED_IMPLICIT
)
{
$serialized
[]
=
'changeTrackingPolicy'
;
}
if
(
$this
->
customRepositoryClassName
)
{
$serialized
[]
=
'customRepositoryClassName'
;
}
if
(
$this
->
inheritanceType
!=
self
::
INHERITANCE_TYPE_NONE
)
{
$serialized
[]
=
'inheritanceType'
;
$serialized
[]
=
'discriminatorColumn'
;
$serialized
[]
=
'discriminatorValue'
;
$serialized
[]
=
'discriminatorMap'
;
$serialized
[]
=
'parentClasses'
;
$serialized
[]
=
'subClasses'
;
}
if
(
$this
->
generatorType
!=
self
::
GENERATOR_TYPE_NONE
)
{
$serialized
[]
=
'generatorType'
;
}
if
(
$this
->
isMappedSuperclass
)
{
$serialized
[]
=
'isMappedSuperclass'
;
}
if
(
$this
->
isVersioned
)
{
$serialized
[]
=
'isVersioned'
;
$serialized
[]
=
'versionField'
;
}
if
(
$this
->
lifecycleCallbacks
)
{
$serialized
[]
=
'lifecycleCallbacks'
;
}
return
$serialized
;
}
/**
...
...
lib/Doctrine/ORM/Mapping/ManyToManyMapping.php
View file @
4b71afe7
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -182,4 +180,25 @@ class ManyToManyMapping extends AssociationMapping
{
return
true
;
}
/**
* Determines which fields get serialized.
*
* It is only serialized what is necessary for best unserialization performance.
* That means any metadata properties that are not set or empty or simply have
* their default value are NOT serialized.
*
* @return array The names of all the fields that should be serialized.
*/
public
function
__sleep
()
{
$serialized
=
parent
::
__sleep
();
$serialized
[]
=
'joinTableColumns'
;
$serialized
[]
=
'relationToSourceKeyColumns'
;
$serialized
[]
=
'relationToTargetKeyColumns'
;
if
(
$this
->
orderBy
)
{
$serialized
[]
=
'orderBy'
;
}
return
$serialized
;
}
}
lib/Doctrine/ORM/Mapping/OneToManyMapping.php
View file @
4b71afe7
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -136,4 +134,25 @@ class OneToManyMapping extends AssociationMapping
$persister
->
loadOneToManyCollection
(
$this
,
$conditions
,
$targetCollection
);
}
/**
* Determines which fields get serialized.
*
* It is only serialized what is necessary for best unserialization performance.
* That means any metadata properties that are not set or empty or simply have
* their default value are NOT serialized.
*
* @return array The names of all the fields that should be serialized.
*/
public
function
__sleep
()
{
$serialized
=
parent
::
__sleep
();
if
(
$this
->
orderBy
)
{
$serialized
[]
=
'orderBy'
;
}
if
(
$this
->
orphanRemoval
)
{
$serialized
[]
=
'orphanRemoval'
;
}
return
$serialized
;
}
}
lib/Doctrine/ORM/Mapping/OneToOneMapping.php
View file @
4b71afe7
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...
...
@@ -187,4 +185,26 @@ class OneToOneMapping extends AssociationMapping
return
$targetEntity
;
}
/**
* Determines which fields get serialized.
*
* It is only serialized what is necessary for best unserialization performance.
* That means any metadata properties that are not set or empty or simply have
* their default value are NOT serialized.
*
* @return array The names of all the fields that should be serialized.
*/
public
function
__sleep
()
{
$serialized
=
parent
::
__sleep
();
$serialized
[]
=
'joinColumns'
;
$serialized
[]
=
'joinColumnFieldNames'
;
$serialized
[]
=
'sourceToTargetKeyColumns'
;
$serialized
[]
=
'targetToSourceKeyColumns'
;
if
(
$this
->
orphanRemoval
)
{
$serialized
[]
=
'orphanRemoval'
;
}
return
$serialized
;
}
}
tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
View file @
4b71afe7
...
...
@@ -20,8 +20,10 @@ class ClassMetadataTest extends \Doctrine\Tests\OrmTestCase
$this
->
assertEquals
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
$cm
->
rootEntityName
);
$this
->
assertEquals
(
array
(),
$cm
->
subClasses
);
$this
->
assertEquals
(
array
(),
$cm
->
parentClasses
);
$this
->
assertEquals
(
ClassMetadata
::
INHERITANCE_TYPE_NONE
,
$cm
->
inheritanceType
);
// Customize state
$cm
->
setInheritanceType
(
ClassMetadata
::
INHERITANCE_TYPE_SINGLE_TABLE
);
$cm
->
setSubclasses
(
array
(
"One"
,
"Two"
,
"Three"
));
$cm
->
setParentClasses
(
array
(
"UserParent"
));
$cm
->
setCustomRepositoryClass
(
"UserRepository"
);
...
...
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