The website encountered an unexpected error. Please try again later.

LogicException: Route pattern "/search-items/test/{keys}/{keys}" cannot reference variable name "keys" more than once. in Symfony\Component\Routing\RouteCompiler::compilePattern() (line 102 of vendor/symfony/routing/RouteCompiler.php).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sriharsha.uppuluri created an issue. See original summary.

apaderno’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

Please provide more details about the error you are getting. What were you doing before to get that exception?

sriharsha.uppuluri’s picture

FileSize
142.77 KB

I have created one search page as "search-page" and another as "search-page-test". After creation of second search page "search-page-test" getting an error as attached.

sriharsha.uppuluri’s picture

Status: Postponed (maintainer needs more info) » Active
swentel’s picture

Hmm, I can't reproduce the error. Are you entering something specific in the path or so ?

swentel’s picture

Ok, I think I see the problem: you're probably entering "search-page/{keys}" as the path. But you can't add {keys}, that's going to clash with symfony, and it's not necessary either.

sriharsha.uppuluri’s picture

I have just given

search-test

in path. Getting error message as search-test/{keys}/{keys} is it creating two keys for second search page.

sriharsha.uppuluri’s picture

When I disable clean URL's configuration in settings its creating without any problem.

swentel’s picture

FileSize
724 bytes

I was finally able to reproduce this and fix it. Patch attached, but already committed and pushed!

  • swentel committed ecfe47b on 8.x-1.x
    Issue #2696607 by swentel: Unable to create more than one search page
    
swentel’s picture

Status: Active » Fixed
Evaldas Užkuras’s picture

Status: Fixed » Needs work

The patch, which is committed, is bad and makes other problems.

Now there are this if statement.

if (empty($path)) {
  $path = $default_path;
}
else {
 $path = $default_path;
}

it is equal to

$path = $default_path;

and it rewrites previously declared $path variable.

My proposed solution is to remove that if statement and just change one line
- $default_path = $search_api_page->getPath();
+ $path = $search_api_page->getPath();

Sagar Ramgade’s picture

I agree with @Evaldas Užkuras, patch attached removes the extra non-required code.

swentel’s picture

Status: Needs work » Fixed

What's the other problem ?

As confusing as it looks, there's actually a case in multilingual sites where the config override returns null. Granted, they all use the same variable name, so it could be made more clear. Reverting would break it again, so the patch in #13 is wrong.

Closing for now. Please open an issue if there are other bugs, but other than that it confuses, nothing is actually wrong with it.

Evaldas Užkuras’s picture

Made some testings and found. that now the paths is not generated for languages.
Then using Configuration translation and having more then 1 language it is possible to enter search page path for each language.
And now the default path is used.

It's because my early mentioned if statement always overrides $path with default value, instead of keeping one, that was returned from language config override.

Adding patch, which fixes this problem.

swentel’s picture

Status: Needs review » Fixed

committed and pushed, thanks!

Status: Fixed » Closed (fixed)

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