Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443488
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
drupal-3443488
Commits
0df5b37a
Commit
0df5b37a
authored
14 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#729186
by catch: _field_info_collate_fields() resource usage.
parent
ef1fd488
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/field/field.info.inc
+39
-35
39 additions, 35 deletions
modules/field/field.info.inc
with
39 additions
and
35 deletions
modules/field/field.info.inc
+
39
−
35
View file @
0df5b37a
...
...
@@ -186,47 +186,46 @@ function _field_info_collate_fields($reset = FALSE) {
if
(
!
isset
(
$info
))
{
if
(
$cached
=
cache_get
(
'field_info_fields'
,
'cache_field'
))
{
$
definitions
=
$cached
->
data
;
$
info
=
$cached
->
data
;
}
else
{
$definitions
=
array
(
'field_ids'
=>
field_read_fields
(
array
(),
array
(
'include_deleted'
=>
1
)),
'instances'
=>
field_read_instances
(),
);
cache_set
(
'field_info_fields'
,
$definitions
,
'cache_field'
);
}
// Populate 'field
_id
s' with all fields.
$info
[
'field
_id
s'
]
=
array
();
foreach
(
$definitions
[
'field_ids'
]
as
$key
=>
$field
)
{
$info
[
'field
_id
s'
][
$key
]
=
$definitions
[
'field_ids'
][
$key
]
=
_field_info_prepare_field
(
$field
);
}
// Populate 'fields' with all fields
, keyed by ID
.
$info
[
'fields'
]
=
array
();
foreach
(
$definitions
[
'field_ids'
]
as
$key
=>
$field
)
{
$info
[
'fields'
][
$key
]
=
$definitions
[
'field_ids'
][
$key
]
=
_field_info_prepare_field
(
$field
);
}
// Populate 'fields' only with non-deleted fields.
$info
[
'fields'
]
=
array
();
foreach
(
$info
[
'field_ids'
]
as
$field
)
{
if
(
!
$field
[
'deleted'
])
{
$info
[
'fields'
][
$field
[
'field_name'
]]
=
$field
;
// Build an array of field IDs for non-deleted fields, keyed by name.
$info
[
'field_ids'
]
=
array
();
foreach
(
$info
[
'fields'
]
as
$key
=>
$field
)
{
if
(
!
$field
[
'deleted'
])
{
$info
[
'field_ids'
][
$field
[
'field_name'
]]
=
$key
;
}
}
}
// Populate 'instances'. Only non-deleted instances are considered.
$info
[
'instances'
]
=
array
();
foreach
(
field_info_bundles
()
as
$entity_type
=>
$bundles
)
{
foreach
(
$bundles
as
$bundle
=>
$bundle_info
)
{
$info
[
'instances'
][
$entity_type
][
$bundle
]
=
array
();
// Populate 'instances'. Only non-deleted instances are considered.
$info
[
'instances'
]
=
array
();
foreach
(
field_info_bundles
()
as
$entity_type
=>
$bundles
)
{
foreach
(
$bundles
as
$bundle
=>
$bundle_info
)
{
$info
[
'instances'
][
$entity_type
][
$bundle
]
=
array
();
}
}
}
foreach
(
$definitions
[
'instances'
]
as
$instance
)
{
$field
=
$info
[
'fields'
][
$instance
[
'
field
_name'
]]
;
$in
stance
=
_field_info_prepare_instance
(
$instance
,
$
field
)
;
$info
[
'instances'
][
$instance
[
'entity_type'
]][
$instance
[
'bundle'
]][
$instance
[
'field_name'
]]
=
$instance
;
//
Enrich field definitions with the list of bundles where they have
//
instances. NOTE: Deleted fields in $info['field_ids'] are not
//
enriched because all of their instances are deleted, too, and
// are thus not in $definitions['instances
']
.
$info
[
'fields'
][
$instance
[
'field_name'
]][
'bundles'
][
$instance
[
'entity_type'
]][]
=
$instance
[
'bundle'
];
$info
[
'field_ids'
][
$instance
[
'field_id'
]][
'bundles'
][
$instance
[
'entity_type'
]][]
=
$instance
[
'bundle'
]
;
foreach
(
$definitions
[
'instances'
]
as
$instance
)
{
$field
=
$info
[
'fields'
][
$instance
[
'field_id'
]];
$instance
=
_field_info_prepare_instance
(
$instance
,
$
field
)
;
$in
fo
[
'instances'
][
$instance
[
'entity_type'
]][
$instance
[
'bundle'
]][
$instance
[
'
field
_name'
]]
=
$instance
;
// Enrich field definitions with the list of bundles where they have
//
instances. NOTE: Deleted fields in $info['field_ids'] are not
//
enriched because all of their instances are deleted, too, and
//
are thus not in $definitions['instances'].
$info
[
'fields'
][
$instance
[
'field_id'
]][
'bundles'
][
$instance
[
'entity_type'
]][]
=
$instance
[
'bundle
'
]
;
}
cache_set
(
'field_info_fields'
,
$info
,
'cache_field'
)
;
}
}
...
...
@@ -525,7 +524,12 @@ function field_info_bundles($entity_type = NULL) {
*/
function
field_info_fields
()
{
$info
=
_field_info_collate_fields
();
return
$info
[
'fields'
];
foreach
(
$info
[
'fields'
]
as
$key
=>
$field
)
{
if
(
!
$field
[
'deleted'
])
{
$fields
[
$field
[
'field_name'
]]
=
$field
;
}
}
return
$fields
;
}
/**
...
...
@@ -544,8 +548,8 @@ function field_info_fields() {
*/
function
field_info_field
(
$field_name
)
{
$info
=
_field_info_collate_fields
();
if
(
isset
(
$info
[
'fields'
][
$field_name
]))
{
return
$info
[
'fields'
][
$field_name
];
if
(
isset
(
$info
[
'field
_id
s'
][
$field_name
]))
{
return
$info
[
'fields'
][
$
info
[
'field_ids'
][
$
field_name
]
]
;
}
}
...
...
@@ -565,8 +569,8 @@ function field_info_field($field_name) {
*/
function
field_info_field_by_id
(
$field_id
)
{
$info
=
_field_info_collate_fields
();
if
(
isset
(
$info
[
'field
_id
s'
][
$field_id
]))
{
return
$info
[
'field
_id
s'
][
$field_id
];
if
(
isset
(
$info
[
'fields'
][
$field_id
]))
{
return
$info
[
'fields'
][
$field_id
];
}
}
...
...
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