Skip to content

Commit

Permalink
fix bugs with entity_load and trying to set nonexistent vid
Browse files Browse the repository at this point in the history
  • Loading branch information
herbdool committed Nov 8, 2021
1 parent 171ff1f commit 8c8a440
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion includes/commerce_product.inline_entity_form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ class CommerceProductInlineEntityFormController extends EntityInlineEntityFormCo
* referenced from a line item, or for some other reason), deletes the rest.
*/
public function delete($ids, $context) {
$products = entity_load('commerce_product', $ids);
$products = entity_load_multiple('commerce_product', $ids);
foreach ((array) $products as $product_id => $product) {
if (!commerce_product_can_delete($product)) {
$product->status = FALSE;
Expand Down
6 changes: 0 additions & 6 deletions includes/taxonomy_term.inline_entity_form.inc
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ class TaxonomyTermInlineEntityFormController extends EntityInlineEntityFormContr

$entity = $entity_form['#entity'];

// Set the vocabulary ID.
$vocabularies = taxonomy_vocabulary_get_names();
if (isset($vocabularies[$entity->vocabulary_machine_name])) {
$entity->vid = $vocabularies[$entity->vocabulary_machine_name]->vid;
}

// Separate the description and format.
$entity->format = $entity->description['format'];
$entity->description = $entity->description['value'];
Expand Down
6 changes: 3 additions & 3 deletions inline_entity_form.module
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ function inline_entity_form_field_widget_form(&$form, &$form_state, $field, $ins
}

$delta = 0;
foreach (entity_load($settings['entity_type'], $entity_ids) as $entity) {
foreach (entity_load_multiple($settings['entity_type'], $entity_ids) as $entity) {
$form_state['inline_entity_form'][$ief_id]['entities'][$delta] = array(
'entity' => $entity,
'weight' => $delta,
Expand Down Expand Up @@ -1135,7 +1135,7 @@ function inline_entity_form_reference_form_validate(&$reference_form, &$form_sta
$labels = $controller->labels();

$form_values = backdrop_array_get_nested_value($form_state['values'], $reference_form['#parents']);
$attach_entity = entity_load_single($entity_type, $form_values['entity_id']);
$attach_entity = entity_load($entity_type, $form_values['entity_id']);

// Check to see if entity is already referenced by current IEF widget
if (!empty($attach_entity)) {
Expand Down Expand Up @@ -1166,7 +1166,7 @@ function inline_entity_form_reference_form_submit($reference_form, &$form_state)
$entity_type = $reference_form['#entity_type'];

$form_values = backdrop_array_get_nested_value($form_state['values'], $reference_form['#parents']);
$attach_entity = entity_load_single($entity_type, $form_values['entity_id']);
$attach_entity = entity_load($entity_type, $form_values['entity_id']);

// Determine the correct weight of the new element.
$weight = 0;
Expand Down

0 comments on commit 8c8a440

Please sign in to comment.