Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
220
Merge Requests
220
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
91acb77f
Commit
91acb77f
authored
Jan 03, 2014
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2027795
by Berdir, amateescu: Optimize content entity serialization.
parent
18828bde
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
4 deletions
+31
-4
core/lib/Drupal/Core/Entity/ContentEntityBase.php
core/lib/Drupal/Core/Entity/ContentEntityBase.php
+17
-4
core/lib/Drupal/Core/Field/ConfigEntityReferenceItemBase.php
core/lib/Drupal/Core/Field/ConfigEntityReferenceItemBase.php
+14
-0
No files found.
core/lib/Drupal/Core/Entity/ContentEntityBase.php
View file @
91acb77f
...
...
@@ -332,15 +332,28 @@ protected function clearTranslationCache() {
}
}
/**
* {@inheritdoc}
*/
public
function
__sleep
()
{
// Get the values of instantiated field objects, only serialize the values.
foreach
(
$this
->
fields
as
$name
=>
$fields
)
{
foreach
(
$fields
as
$langcode
=>
$field
)
{
$this
->
values
[
$name
][
$langcode
]
=
$field
->
getValue
();
}
}
$this
->
fields
=
array
();
$this
->
fieldDefinitions
=
NULL
;
$this
->
clearTranslationCache
();
return
array_keys
(
get_object_vars
(
$this
));
}
/**
* Magic __wakeup() implementation.
*/
public
function
__wakeup
()
{
$this
->
init
();
// @todo This should be done before serializing the entity, but we would
// need to provide the full list of data to be serialized. See the
// dedicated issue at https://drupal.org/node/2027795.
$this
->
clearTranslationCache
();
}
/**
...
...
core/lib/Drupal/Core/Field/ConfigEntityReferenceItemBase.php
View file @
91acb77f
...
...
@@ -33,6 +33,20 @@ public function isEmpty() {
return
TRUE
;
}
/**
* {@inheritdoc}
*/
public
function
getValue
()
{
$values
=
parent
::
getValue
();
// If there is an unsaved entity, return it as part of the field item values
// to ensure idempotency of getValue() / setValue().
if
(
empty
(
$this
->
target_id
)
&&
!
empty
(
$this
->
entity
))
{
$values
[
'entity'
]
=
$this
->
entity
;
}
return
$values
;
}
/**
* {@inheritdoc}
*/
...
...
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