Warning: Undefined array key "position" in Drupal\facets_summary\Plugin\facets_summary\processor\ResetFacetsProcessor->build() (line 111 of modules/contrib/facets/modules/facets_summary/src/Plugin/facets_summary/processor/ResetFacetsProcessor.php).

Created on 9 May 2023, over 1 year ago
Updated 10 April 2024, 7 months ago

Problem/Motivation

There are massive warning messages when accessing facets:
Warning: Undefined array key "position" in Drupal\facets_summary\Plugin\facets_summary\processor\ResetFacetsProcessor->build() (line 111 of modules/contrib/facets/modules/facets_summary/src/Plugin/facets_summary/processor/ResetFacetsProcessor.php).

This warning is pointing to this code:
// Place link at necessary position.
if ($configuration['settings']['position'] == static::POSITION_BEFORE) {
array_unshift($build['#items'], $item);
}
elseif ($configuration['settings']['position'] == static::POSITION_AFTER) {
$build['#items'][] = $item;
}
else {
$build['#items'] = [
$item,
];
}

Any idea where can i find the settings for $configuration['settings']['position'] ? nothing like that i can find within the facet settings.

The only thing I can think of fixing this is to check if $configuration['settings']['position'] isset at all, but I am not sure if I am missing out something by just blocking that.

Anyone encountered this?

🐛 Bug report
Status

Needs work

Version

2.0

Component

Facet summary

Created by

🇳🇿New Zealand janpongos

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

Comments & Activities

  • Issue created by @janpongos
  • 🇳🇱Netherlands thomasdik

    As no one has answered this question.
    This is due to a change in config.

    You probably have this:

    processor_configs:
      reset_facets:
        processor_id: reset_facets
        weights:
          build: '30'
        settings:
          link_text: 'Reset all filters'
    

    Somewhere in your config files like facets_summary.facets_summary.[content_type]_facet_summary.yml
    It should look like this:

    processor_configs:
      reset_facets:
        processor_id: reset_facets
        weights:
          build: '30'
        settings:
          link_text: 'Reset all filters'
          position: null
    

    And the position can be either null/before/after/replace please have a look at the ResetFacetsProcessor for details.
    But this should fix your issue.

    Kind regards,

    Thomas Dik

  • 🇦🇹Austria runzipel

    on my side resaving the facet summary widget helped.

  • 🇵🇹Portugal joao.ramos.costa

    Did you facets_summary_update_8002() run on update ?
    Kr

  • 🇵🇹Portugal joao.ramos.costa

    But, answering

    Any idea where can i find the settings for $configuration['settings']['position'] ? nothing like that i can find within the facet settings.

    should be here:
    /admin/config/search/facets/facet-summary/{facets_summary}/edit

  • 🇮🇳India mohd sahzad

    i have fixed this issue Warning: Undefined array key "position" in Drupal\facets_summary\Plugin\facets_summary\processor\ResetFacetsProcessor->build() (line 111 of modules/contrib/facets/modules/facets_summary/src/Plugin/facets_summary/processor/ResetFacetsProcessor.php).

  • Status changed to Needs review about 1 year ago
  • 🇺🇸United States DamienMcKenna NH, USA

    Mohd: Thanks for putting together a patch for this. As a reminder, when you upload a patch (or create a merge request) please update the status to "needs review", that will trigger the automated tests and let others know there's a potential fix available.

  • 🇺🇸United States DamienMcKenna NH, USA

    I'm not sure the patch in #6 covers the scenarios correctly - if the variable exists but is not the values 'before' or 'after' then it won't hit the "else" statement.

    How about this?

  • Status changed to Needs work 7 months ago
  • 🇺🇸United States smustgrave

    Can steps to reproduce be added.

Production build 0.71.5 2024