Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalizing keywords for search index uses wrong language #3046

Closed
wsydney76 opened this issue Jun 28, 2018 · 4 comments

Comments

@wsydney76
Copy link

commented Jun 28, 2018

Description

The keywords for the search index are obviousliy built depending on the current users cp language. That should use the language of the site the entry is in.

Using Craft::$app->language in craft\helpers\Search

Steps to reproduce

  1. Create an entry with a title like 'Zauberflöte' on a site with language = german
  2. Saved by an author with cp language = en, the search index will contain 'zauberflote'. The entry will not be found by a search for 'Zauberflöte' on a german site.
  3. Saved by an author with cp language = de, the search index will contain 'zauberfloete'. Now it can be found.

Additional info

  • Craft version: 3.0.13.2
  • PHP version:
  • Database driver & version:
  • Plugins & versions:
@brandonkelly

This comment has been minimized.

Copy link
Member

commented Jun 30, 2018

I’m not able to reproduce this. I created a Craft install with two sites (EN and DE) with EN being the primary. Then created a section enabled for both sites, and created a new entry with DE selected, title = “Zauberflöte”. As expected the entry will show up in search results for “Zauberflöte” regardless of which site is selected.

Here is the searchkeywords table for the entry:

screen shot 2018-06-29 at 7 26 59 pm

Let me know if you can think of any other variables that could be affecting this on your site. If you’re not sure, please send your composer.json, composer.lock, and a database backup to support@craftcms.com, and tell us which section the bug is occurring on.

@wsydney76

This comment has been minimized.

Copy link
Author

commented Jun 30, 2018

Thanks, but that's not the use case i tried to describe, sorry that my description was misleading.

It's about the language the author selected for his personal use in the backend.

So, if a user has this preferences:

image

and saves the item, the table shows:

image

If you change the preferences to this:

image

and resave the entry, the table content is:

image

and that is what works with this search in the german site:

image

In helpers/Search.php line 88 there is

// This will replace accented chars with non-accented chars
$map = StringHelper::asciiCharMap(true, Craft::$app->language);

where, if i don't get it wrong, $app->language is the language the cp is currently running in, and not the language of the site the entry belongs to.

I could find a temporary workaround with some configuration settings

'customAsciiCharMappingss' => [
    'a' => ['ä', 'Ä'],
    'o' => ['ö', 'Ö'],
    'u' => ['ü', 'Ü'],
    's' => ['ß']
],

but there might be some unwanted side effects (?), and it's deprecated anyway.

Thanks again for your efforts, the multilingual feature was one of the main reasons our clients switched from another wellknown CMS to Craft.

@brandonkelly

This comment has been minimized.

Copy link
Member

commented Jun 30, 2018

Sorry, I missed the oe in zauberfloete. I’m following the issue now – will look into it.

brandonkelly added a commit that referenced this issue Jun 30, 2018
@wsydney76

This comment has been minimized.

Copy link
Author

commented Jul 4, 2018

Works now. Thanks for the quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.