(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.

CommentFileSizeAuthor
#13 3187643-nr-bot.txt1.28 KBneeds-review-queue-bot

Issue fork drupal-3187643

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Spokje created an issue. See original summary.

spokje’s picture

Title: Make bug-fix code for #3167733 (PHP 7.4 notice in views node wizard if a taxonomy field widget is hidden) more efficient » [PP-1 ]Make bug-fix code for #3167733 (PHP 7.4 notice in views node wizard if a taxonomy field widget is hidden) more efficient
Status: Needs work » Postponed
spokje’s picture

Title: [PP-1 ]Make bug-fix code for #3167733 (PHP 7.4 notice in views node wizard if a taxonomy field widget is hidden) more efficient » [PP-1] Make bug-fix code for #3167733 (PHP 7.4 notice in views node wizard if a taxonomy field widget is hidden) more efficient
spokje’s picture

Assigned: spokje » Unassigned
spokje’s picture

Title: [PP-1] Make bug-fix code for #3167733 (PHP 7.4 notice in views node wizard if a taxonomy field widget is hidden) more efficient » Make bug-fix code for #3167733 (PHP 7.4 notice in views node wizard if a taxonomy field widget is hidden) more efficient
Assigned: Unassigned » spokje
Status: Postponed » Needs work

spokje’s picture

Assigned: spokje » Unassigned
Status: Needs work » Needs review

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

spokje’s picture

Rerolled against 9.3.x

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new1.28 KB

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley made their first commit to this issue’s fork.

acbramley’s picture

Status: Needs work » Needs review

Rebased onto 11.x and fixed the double (triple?) loop

quietone’s picture

Issue tags: +Needs title update

Can the title be simplified? Referring to a previous issue in the commit message is uncommon. Maybe 'Make X more efficient' ?

acbramley’s picture

Title: Make bug-fix code for #3167733 (PHP 7.4 notice in views node wizard if a taxonomy field widget is hidden) more efficient » Make Node views wizard buildFilters more efficient
Issue tags: -Needs title update

Done

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems pretty straight forward.

  • catch committed cb230b71 on 11.x
    Issue #3187643 by spokje, acbramley, quietone: Make Node views wizard...
catch’s picture

Category: Feature request » Task
Status: Reviewed & tested by the community » Fixed

This is a lot more readable, changing to a task - no new feature is added.

Committed/pushed to 11.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.