Issue #1864720 by yched: Minor hysteresis in field_info_instances().
parent
eea79f9b44
commit
ca2f0a8c0d
|
@ -364,9 +364,15 @@ class FieldInfo {
|
||||||
}
|
}
|
||||||
unset($info['fields']);
|
unset($info['fields']);
|
||||||
|
|
||||||
// Save in the "static" cache.
|
// Store the instance definitions in the "static" cache'. Empty (or
|
||||||
|
// non-existent) bundles are stored separately, so that they do not
|
||||||
|
// pollute the global list returned by getInstances().
|
||||||
|
if ($info['instances']) {
|
||||||
$this->bundleInstances[$entity_type][$bundle] = $info['instances'];
|
$this->bundleInstances[$entity_type][$bundle] = $info['instances'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->emptyBundles[$entity_type][$bundle] = TRUE;
|
||||||
|
}
|
||||||
return $info['instances'];
|
return $info['instances'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,16 @@ class FieldInfoTest extends FieldTestBase {
|
||||||
$this->assertIdentical($instances, $expected, format_string("field_info_instances('user') returns %expected.", array('%expected' => var_export($expected, TRUE))));
|
$this->assertIdentical($instances, $expected, format_string("field_info_instances('user') returns %expected.", array('%expected' => var_export($expected, TRUE))));
|
||||||
$instances = field_info_instances('user', 'user');
|
$instances = field_info_instances('user', 'user');
|
||||||
$this->assertIdentical($instances, array(), "field_info_instances('user', 'user') returns an empty array.");
|
$this->assertIdentical($instances, array(), "field_info_instances('user', 'user') returns an empty array.");
|
||||||
|
|
||||||
|
// Test that querying for invalid entity types does not add entries in the
|
||||||
|
// list returned by field_info_instances().
|
||||||
|
field_info_cache_clear();
|
||||||
|
field_info_instances('invalid_entity', 'invalid_bundle');
|
||||||
|
// Simulate new request by clearing static caches.
|
||||||
|
drupal_static_reset();
|
||||||
|
field_info_instances('invalid_entity', 'invalid_bundle');
|
||||||
|
$instances = field_info_instances();
|
||||||
|
$this->assertFalse(isset($instances['invalid_entity']), 'field_info_instances() does not contain entries for the invalid entity type that was queried before');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue