Adding a facet search to a menu leads to fatal errors.

Created on 5 April 2022, over 2 years ago
Updated 7 August 2024, 5 months ago

Problem/Motivation

I'm Trying to add a menu link to a pre-selected facet page, but it is throwing a fatal for the route parameters being too long

Drupal\Core\Entity\EntityStorageException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'route_param_key' at row 1

The param key is full of empty values:
f0=&f1=&f2=&f3=&f4=&f5=&f6=&f7=&f8=&f9=&f10=&f11=&f12=&f13=&f14=&f15=&f16=&f17=&f18=&f19=&f20=&f21=&f22=&f23=&f24=&f25=&f26=&f27=&f28=&f29=&f30=&f31=&f32=&f33=&f34=&f35=&f36=&f37=&f38=&f39=&facets_query=category/frames-5734/riding-type/dirt_jump_slopestyle

This looks to be the way it's allowing facet pretty paths to work in the first place?

FacetsRequestTrait:

  public function pushRequest(RequestStack $request_stack, $route_title, $filters) {
    // We need to use a dummy, albeit existing route (in this case system.admin)
    // so that Url objects can be built for this route. Otherwise, calls to Url
    // will not work as the route does not exist.
    $route = new Route('admin/{facets_query}/{f0}/{f1}/{f2}/{f3}/{f4}/{f5}/{f6}/{f7}/{f8}/{f9}/{f10}/{f11}/{f12}/{f13}/{f14}/{f15}/{f16}/{f17}/{f18}/{f19}/{f20}/{f21}/{f22}/{f23}/{f24}/{f25}/{f26}/{f27}/{f28}/{f29}/{f30}/{f31}/{f32}/{f33}/{f34}/{f35}/{f36}/{f37}/{f38}');
    $route->setDefault('_title', $route_title);
    $route->setRequirement('facets_query', '.*');
    $route->setDefault('facets_query', '');

There has to be a better way here?

🐛 Bug report
Status

Postponed

Version

1.0

Component

Code

Created by

🇨🇦Canada b_sharpe

Live updates comments and jobs are added and updated live.
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.

  • 🇳🇿New Zealand andyd328 Lyttelton, NZ 🇳🇿

    Thanks for posting the link & workaround, very much appreciated!

  • 🇧🇪Belgium fernly

    This long route makes this feature basically unusable. Fatal errors popping up all over the website due to this long route. Any updates on this?
    It's hard to make a webmaster use base:... in all kinds of places on the website. However, thanks for this workaround.

Production build 0.71.5 2024