Ticket #2267 (new patch)

Opened 11 months ago

Last modified 2 months ago

Patch to fix i18n and SearchForm not working together

Reported by: mpeel Owned by: ischommer
Priority: medium Milestone: 2.3.1
Component: i18n Version: 2.2.1
Severity: medium effort / impact Keywords:
Cc: Hours:

Description

Problem: You can't search based on the language you're browsing in,

This is a partial fix to this problem. Because it's to fix the search engine, something I know very little about, it needs to be tested a lot. Specifically, my hack to SQLQuery for unlimtedRowCount() is dangerous and 99% doesn't work - however I don't have time right now to get it right, and the site I did this for has no pagination anyway.

The main issues here was that SQLQuery::unlimitedRowCount() doesn't call SiteTree::extend('augmentSQL'), meaning that Translatable::augmentSQL() doesn't fire on that particular cloned SQLQuery, and therefore it gets data from the wrong tables (and looks for fields that don't exist etc).

The other problem was that SearchForm? itself wasn't namespacing the MATCH() declarations, which meant when you joined multiple tables (lang to original lang etc) it would find ambiguous fields.

Attachments

i18n-SearchForm.patch (3.7 kB) - added by mpeel 11 months ago.
i18n-searchform-entities.patch (3.9 kB) - added by ischommer 2 months ago.

Change History

Changed 11 months ago by mpeel

Changed 4 months ago by ischommer

  • milestone 2.2.3 deleted

Changed 2 months ago by ischommer

I've attached another partial fix based on feedback from the forums: http://www.silverstripe.com/site-builders-forum/flat/74109?showPost=223598

The problem is that we escape some fields to htmlentities in the database (Content), but not others (Title, Meta*). This means we cant use one single MATCH AGAINST statement, but have to formulate one for unescaped and one for escaped content. As this might affect the boolean logic in weird ways, we need to add tests for the different boolean variations of searching before implementing the patches.

My attached patch adds a SearchFormTest? unittest with fixtures, should be fairly easy to build on that for writing further tests. Anyone keen?

Changed 2 months ago by ischommer

Changed 2 months ago by ischommer

Related to #2363

Changed 2 months ago by ischommer

  • milestone set to 2.3.1
Note: See TracTickets for help on using tickets.