summaryrefslogtreecommitdiff
path: root/modules/field_ui/field_ui.module
diff options
context:
space:
mode:
Diffstat (limited to 'modules/field_ui/field_ui.module')
-rw-r--r--modules/field_ui/field_ui.module23
1 files changed, 15 insertions, 8 deletions
diff --git a/modules/field_ui/field_ui.module b/modules/field_ui/field_ui.module
index 93cbcccc7..5f8bc45ef 100644
--- a/modules/field_ui/field_ui.module
+++ b/modules/field_ui/field_ui.module
@@ -332,23 +332,30 @@ function _field_ui_bundle_admin_path($entity_type, $bundle_name) {
* Identifies inactive fields within a bundle.
*/
function field_ui_inactive_instances($entity_type, $bundle_name = NULL) {
- if (!empty($bundle_name)) {
- $inactive = array($bundle_name => array());
- $params = array('bundle' => $bundle_name);
+ $params = array('entity_type' => $entity_type);
+
+ if (empty($bundle_name)) {
+ $active = field_info_instances($entity_type);
+ $inactive = array();
}
else {
- $inactive = array();
- $params = array();
+ // Restrict to the specified bundle. For consistency with the case where
+ // $bundle_name is NULL, the $active and $inactive arrays are keyed by
+ // bundle name first.
+ $params['bundle'] = $bundle_name;
+ $active = array($bundle_name => field_info_instances($entity_type, $bundle_name));
+ $inactive = array($bundle_name => array());
}
- $params['entity_type'] = $entity_type;
- $active_instances = field_info_instances($entity_type);
+ // Iterate on existing definitions, and spot those that do not appear in the
+ // $active list collected earlier.
$all_instances = field_read_instances($params, array('include_inactive' => TRUE));
foreach ($all_instances as $instance) {
- if (!isset($active_instances[$instance['bundle']][$instance['field_name']])) {
+ if (!isset($active[$instance['bundle']][$instance['field_name']])) {
$inactive[$instance['bundle']][$instance['field_name']] = $instance;
}
}
+
if (!empty($bundle_name)) {
return $inactive[$bundle_name];
}