From e827b5a87d7e5bd530495acf7b4c75557fb6a7e9 Mon Sep 17 00:00:00 2001 From: laryn Date: Wed, 8 Nov 2023 23:31:46 -0600 Subject: [PATCH] Fix Warning: Undefined variable $field_state in paragraphs_modal_admin_links(). --- paragraphs.module | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paragraphs.module b/paragraphs.module index 198ce51..f9298b4 100644 --- a/paragraphs.module +++ b/paragraphs.module @@ -1692,6 +1692,7 @@ function paragraphs_modal_admin_links($paragraphs_item) { $field_name = $paragraphs_item->field_name; $langcode = $paragraphs_item->langcode; $field = field_info_field($field_name); + $field_count = count($host_entity->{$field_info['field_name']}[$langcode]); $instance = field_info_instance($host_entity_type, $field_name, $host_entity_bundle); $admin_links = array(); @@ -1755,7 +1756,7 @@ function paragraphs_modal_admin_links($paragraphs_item) { ), ); } - if ($field_info['cardinality'] != '1' && count($host_entity->{$field_info['field_name']}[$langcode]) > 1) { + if ($field_info['cardinality'] != '1' && $field_count > 1) { $admin_links['#links']['paragraphs_admin_sort'] = array( 'title' => t('Sort'), 'href' => 'paragraphs/' . $paragraph_id . '/sort', @@ -1827,7 +1828,7 @@ function paragraphs_modal_admin_links($paragraphs_item) { if (count($select_bundles)) { backdrop_sort($select_bundles, array('weight' => SORT_NUMERIC)); - if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $field_state['real_items_count'] < $field['cardinality']) { + if ($field['cardinality'] == FIELD_CARDINALITY_UNLIMITED || $field_count < $field['cardinality']) { foreach ($select_bundles as $key => $bundle) { $admin_links['#links']['paragraphs_admin_add_' . $key] = array( 'title' => t('Add new') . ' ' . $bundle['name'],