Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
fee42cb6
Commit
fee42cb6
authored
10 years ago
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2247095
by yched, xjm, alexpott: Optimize loading of deleted fields.
parent
6e70062d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/field/src/FieldConfigStorage.php
+16
-10
16 additions, 10 deletions
core/modules/field/src/FieldConfigStorage.php
core/modules/field/src/FieldInstanceConfigStorage.php
+16
-10
16 additions, 10 deletions
core/modules/field/src/FieldInstanceConfigStorage.php
with
32 additions
and
20 deletions
core/modules/field/src/FieldConfigStorage.php
+
16
−
10
View file @
fee42cb6
...
@@ -97,19 +97,25 @@ public function loadByProperties(array $conditions = array()) {
...
@@ -97,19 +97,25 @@ public function loadByProperties(array $conditions = array()) {
$include_deleted
=
isset
(
$conditions
[
'include_deleted'
])
?
$conditions
[
'include_deleted'
]
:
FALSE
;
$include_deleted
=
isset
(
$conditions
[
'include_deleted'
])
?
$conditions
[
'include_deleted'
]
:
FALSE
;
unset
(
$conditions
[
'include_deleted'
]);
unset
(
$conditions
[
'include_deleted'
]);
// Get fields stored in configuration.
$fields
=
array
();
if
(
isset
(
$conditions
[
'entity_type'
])
&&
isset
(
$conditions
[
'field_name'
]))
{
// Optimize for the most frequent case where we do have a specific ID.
// Get fields stored in configuration. If we are explicitly looking for
$id
=
$conditions
[
'entity_type'
]
.
$conditions
[
'field_name'
];
// deleted fields only, this can be skipped, because they will be retrieved
$fields
=
$this
->
loadMultiple
(
array
(
$id
));
// from state below.
}
if
(
empty
(
$conditions
[
'deleted'
]))
{
else
{
if
(
isset
(
$conditions
[
'entity_type'
])
&&
isset
(
$conditions
[
'field_name'
]))
{
// No specific ID, we need to examine all existing fields.
// Optimize for the most frequent case where we do have a specific ID.
$fields
=
$this
->
loadMultiple
();
$id
=
$conditions
[
'entity_type'
]
.
$conditions
[
'field_name'
];
$fields
=
$this
->
loadMultiple
(
array
(
$id
));
}
else
{
// No specific ID, we need to examine all existing fields.
$fields
=
$this
->
loadMultiple
();
}
}
}
// Merge deleted fields (stored in state) if needed.
// Merge deleted fields (stored in state) if needed.
if
(
$include_deleted
)
{
if
(
$include_deleted
||
!
empty
(
$conditions
[
'deleted'
])
)
{
$deleted_fields
=
$this
->
state
->
get
(
'field.field.deleted'
)
?:
array
();
$deleted_fields
=
$this
->
state
->
get
(
'field.field.deleted'
)
?:
array
();
foreach
(
$deleted_fields
as
$id
=>
$config
)
{
foreach
(
$deleted_fields
as
$id
=>
$config
)
{
$fields
[
$id
]
=
$this
->
create
(
$config
);
$fields
[
$id
]
=
$this
->
create
(
$config
);
...
...
This diff is collapsed.
Click to expand it.
core/modules/field/src/FieldInstanceConfigStorage.php
+
16
−
10
View file @
fee42cb6
...
@@ -104,19 +104,25 @@ public function loadByProperties(array $conditions = array()) {
...
@@ -104,19 +104,25 @@ public function loadByProperties(array $conditions = array()) {
$include_deleted
=
isset
(
$conditions
[
'include_deleted'
])
?
$conditions
[
'include_deleted'
]
:
FALSE
;
$include_deleted
=
isset
(
$conditions
[
'include_deleted'
])
?
$conditions
[
'include_deleted'
]
:
FALSE
;
unset
(
$conditions
[
'include_deleted'
]);
unset
(
$conditions
[
'include_deleted'
]);
// Get instances stored in configuration.
$instances
=
array
();
if
(
isset
(
$conditions
[
'entity_type'
])
&&
isset
(
$conditions
[
'bundle'
])
&&
isset
(
$conditions
[
'field_name'
]))
{
// Optimize for the most frequent case where we do have a specific ID.
// Get instances stored in configuration. If we are explicitly looking for
$id
=
$conditions
[
'entity_type'
]
.
'.'
.
$conditions
[
'bundle'
]
.
'.'
.
$conditions
[
'field_name'
];
// deleted instances only, this can be skipped, because they will be
$instances
=
$this
->
loadMultiple
(
array
(
$id
));
// retrieved from state below.
}
if
(
empty
(
$conditions
[
'deleted'
]))
{
else
{
if
(
isset
(
$conditions
[
'entity_type'
])
&&
isset
(
$conditions
[
'bundle'
])
&&
isset
(
$conditions
[
'field_name'
]))
{
// No specific ID, we need to examine all existing instances.
// Optimize for the most frequent case where we do have a specific ID.
$instances
=
$this
->
loadMultiple
();
$id
=
$conditions
[
'entity_type'
]
.
'.'
.
$conditions
[
'bundle'
]
.
'.'
.
$conditions
[
'field_name'
];
$instances
=
$this
->
loadMultiple
(
array
(
$id
));
}
else
{
// No specific ID, we need to examine all existing instances.
$instances
=
$this
->
loadMultiple
();
}
}
}
// Merge deleted instances (stored in state) if needed.
// Merge deleted instances (stored in state) if needed.
if
(
$include_deleted
)
{
if
(
$include_deleted
||
!
empty
(
$conditions
[
'deleted'
])
)
{
$deleted_instances
=
$this
->
state
->
get
(
'field.instance.deleted'
)
?:
array
();
$deleted_instances
=
$this
->
state
->
get
(
'field.instance.deleted'
)
?:
array
();
$deleted_fields
=
$this
->
state
->
get
(
'field.field.deleted'
)
?:
array
();
$deleted_fields
=
$this
->
state
->
get
(
'field.field.deleted'
)
?:
array
();
foreach
(
$deleted_instances
as
$id
=>
$config
)
{
foreach
(
$deleted_instances
as
$id
=>
$config
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment