security update for entity_reference
This commit is contained in:
@@ -19,9 +19,13 @@ function _entityreference_devel_generate($object, $field, $instance, $bundle) {
|
||||
// Get all the entity that are referencable here.
|
||||
$referencable_entity = entityreference_get_selection_handler($field, $instance)->getReferencableEntities();
|
||||
if (is_array($referencable_entity) && !empty($referencable_entity)) {
|
||||
// Get a random key.
|
||||
foreach ($referencable_entity as $type => $eids) {
|
||||
$object_field['target_id'] = array_rand($eids);
|
||||
// $referencable_entity is keyed by bundle type.
|
||||
$random_bundle = array_rand($referencable_entity);
|
||||
if (!empty($random_bundle)) {
|
||||
$target_id = array_rand($referencable_entity[$random_bundle]);
|
||||
if (!empty($referencable_entity[$random_bundle][$target_id])) {
|
||||
$object_field['target_id'] = $target_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $object_field;
|
||||
|
||||
Reference in New Issue
Block a user