security update for entity_reference

This commit is contained in:
2018-04-21 00:03:39 +02:00
parent 85772b4ca7
commit 226561ffd4
18 changed files with 475 additions and 138 deletions

View File

@@ -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;