Make bug-fix code for #3167733 (PHP 7.4 notice in views node wizard if a taxonomy field widget is hidden) more efficient

Created on 10 December 2020, over 4 years ago
Updated 21 March 2025, 19 days ago

(This is a follow-up on PHP 7.4 notice in views node wizard if a taxonomy field widget is hidden β†’ )

In the above issue a bug fix was made for hidden taxonomy field widgets in the views node wizard.

As point out by @alexpott here β†’ the code that fixes the bug can be made more efficient:

+++ b/core/modules/node/src/Plugin/views/wizard/Node.php
@@ -279,7 +279,7 @@ protected function buildFilters(&$form, FormStateInterface $form_state) {
         $widget = $display->getComponent($field_name);
         // We define "tag-like" taxonomy fields as ones that use the
         // "Autocomplete (Tags style)" widget.
-        if ($widget['type'] == 'entity_reference_autocomplete_tags') {
+        if (!empty($widget) && $widget['type'] == 'entity_reference_autocomplete_tags') {
           $tag_fields[$field_name] = $field;
         }

The logic above here is looping around this already... so we're doing more loops than is really necessary.

We can combine the two by doing...

      $tag_fields += array_filter($this->entityFieldManager->getFieldDefinitions($this->entityTypeId, $bundle), function (FieldDefinitionInterface $field_definition) use ($display) {
        if ($field_definition->getType() == 'entity_reference' && $field_definition->getSetting('target_type') == 'taxonomy_term') {
          $widget = $display->getComponent($field_definition->getName());
          return isset($widget['type']) && $widget['type'] == 'entity_reference_autocomplete_tags';
        }
        return FALSE;
      });

Can you open a follow-up for this? Shouldn't be part of the change here.

This issue was created to "efficiencify" the code from #3167733 according to the proposed code above.

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
Node systemΒ  β†’

Last updated about 3 hours ago

No maintainer
Created by

πŸ‡³πŸ‡±Netherlands spokje

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024