change condition query options, recovers f=null

Created on 17 May 2018, almost 7 years ago
Updated 11 March 2025, 25 days ago

Hi guys, thanks for the great job!
change condition query options, recovers f=null
#before

 // Because we can't get the desired url trough a url processor method
      // we iterate each result url and remove the facet params that haven't
      // been used on previous crumbs.
      foreach ($facet_results as $res) {
        $facet_url = $res->getUrl();
        /** @var \Drupal\Core\Url $facet_url */
        $query = $facet_url->getOption('query');
        $filter_key = $facet_source->getFilterKey() ?: 'f';
        $source_filter = $query[$filter_key];
        $source_filter = array_unique($source_filter);
        $source_filter = array_filter($source_filter);
        $matches = preg_grep('/^' . implode('|^', $facet_used_result) . '/', $source_filter);
        $query[$filter_key] = $matches;
        $facet_crumb_items[] = $res->getDisplayValue();
      }

#after

// Because we can't get the desired url trough a url processor method
      // we iterate each result url and remove the facet params that haven't
      // been used on previous crumbs.
      foreach ($facet_results as $res) {
        $facet_url = $res->getUrl();
        /** @var \Drupal\Core\Url $facet_url */
        $query = $facet_url->getOption('query');
        if($facet_source->getFilterKey()){
          $filter_key = $facet_source->getFilterKey();
          $source_filter = $query[$filter_key];
          $source_filter = array_unique($source_filter);
          $source_filter = array_filter($source_filter);
          $matches = preg_grep('/^' . implode('|^', $facet_used_result) . '/', $source_filter);
          $query[$filter_key] = $matches;
        }
        $facet_crumb_items[] = $res->getDisplayValue();
      }

if create custom url processor /admin/config/search/facets/facet-sources/search_api_you_facet_source/edit
and select facet value in breadcrumb /catalog/you_facet_alias/you_facet_value?f
Here is this line $filter_key = $facet_source->getFilterKey() ?: 'f';
Why do I need 'f' i'm not undestand
What do you think?
ty

🐛 Bug report
Status

Closed: cannot reproduce

Component

Code

Created by

🇷🇺Russia batkor Irkutsk

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

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