Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
1d48f07f
Commit
1d48f07f
authored
Aug 01, 2010
by
Dries Buytaert
Browse files
- Patch
#869350
by chx, yched: some field functions are called a bit too often.
parent
d58e32ed
Changes
4
Hide whitespace changes
Inline
Side-by-side
modules/field/field.api.php
View file @
1d48f07f
...
...
@@ -1522,11 +1522,12 @@ function hook_field_storage_details_alter(&$details, $field) {
* loaded.
*/
function hook_field_storage_load($entity_type, &$entities, $age, $fields, $options) {
$field_info = field_info_field_by_ids();
$etid = _field_sql_storage_etid($entity_type);
$load_current = $age == FIELD_LOAD_CURRENT;
foreach ($fields as $field_id => $ids) {
$field
=
field_info
_field_by_id
(
$field_id
)
;
$field =
$
field_info
[
$field_id
]
;
$field_name = $field['field_name'];
$table = $load_current ? _field_sql_storage_tablename($field) : _field_sql_storage_revision_tablename($field);
...
...
modules/field/field.attach.inc
View file @
1d48f07f
...
...
@@ -273,6 +273,7 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b =
'language'
=>
NULL
,
);
$options
+=
$default_options
;
$field_info
=
field_info_field_by_ids
();
$fields
=
array
();
$grouped_instances
=
array
();
...
...
@@ -296,7 +297,7 @@ function _field_invoke_multiple($op, $entity_type, $entities, &$a = NULL, &$b =
foreach
(
$instances
as
$instance
)
{
$field_id
=
$instance
[
'field_id'
];
$field_name
=
$instance
[
'field_name'
];
$field
=
field_info
_field_by_id
(
$field_id
)
;
$field
=
$
field_info
[
$field_id
]
;
$function
=
$options
[
'default'
]
?
'field_default_'
.
$op
:
$field
[
'module'
]
.
'_field_'
.
$op
;
if
(
function_exists
(
$function
))
{
// Add the field to the list of fields to invoke the hook on.
...
...
@@ -583,6 +584,7 @@ function field_attach_form($entity_type, $entity, &$form, &$form_state, $langcod
* non-deleted fields are operated on.
*/
function
field_attach_load
(
$entity_type
,
$entities
,
$age
=
FIELD_LOAD_CURRENT
,
$options
=
array
())
{
$field_info
=
field_info_field_by_ids
();
$load_current
=
$age
==
FIELD_LOAD_CURRENT
;
// Merge default options.
...
...
@@ -660,7 +662,7 @@ function field_attach_load($entity_type, $entities, $age = FIELD_LOAD_CURRENT, $
}
// Collect the storage backend if the field has not been loaded yet.
if
(
!
isset
(
$skip_fields
[
$field_id
]))
{
$field
=
field_info
_field_by_id
(
$field_id
)
;
$field
=
$
field_info
[
$field_id
]
;
$storages
[
$field
[
'storage'
][
'type'
]][
$field_id
][]
=
$load_current
?
$id
:
$vid
;
}
}
...
...
modules/field/field.info.inc
View file @
1d48f07f
...
...
@@ -575,6 +575,25 @@ function field_info_field_by_id($field_id) {
}
}
/**
* Returns the same data as field_info_field_by_id() for every field.
*
* This function is typically used when handling all fields of some entities
* to avoid thousands of calls to field_info_field_by_id().
*
* @return
* An array, each key is a field ID and the values are field arrays as
* returned by field_read_fields(), with an additional element 'bundles',
* whose value is an array of all the bundle this field belongs to.
*
* @see field_info_field()
* @see field_info_field_by_id()
*/
function
field_info_field_by_ids
()
{
$info
=
_field_info_collate_fields
();
return
$info
[
'fields'
];
}
/**
* Retrieves information about field instances.
*
...
...
modules/field/modules/field_sql_storage/field_sql_storage.module
View file @
1d48f07f
...
...
@@ -309,11 +309,12 @@ function field_sql_storage_field_storage_delete_field($field) {
* Implements hook_field_storage_load().
*/
function
field_sql_storage_field_storage_load
(
$entity_type
,
$entities
,
$age
,
$fields
,
$options
)
{
$field_info
=
field_info_field_by_ids
();
$etid
=
_field_sql_storage_etid
(
$entity_type
);
$load_current
=
$age
==
FIELD_LOAD_CURRENT
;
foreach
(
$fields
as
$field_id
=>
$ids
)
{
$field
=
field_info
_field_by_id
(
$field_id
)
;
$field
=
$
field_info
[
$field_id
]
;
$field_name
=
$field
[
'field_name'
];
$table
=
$load_current
?
_field_sql_storage_tablename
(
$field
)
:
_field_sql_storage_revision_tablename
(
$field
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment