Skip to content

Smartsearch: collation issue when searching in back-end index#8307

Merged
rdeutz merged 2 commits intojoomla:stagingfrom
infograf768:finder_indexdate
Nov 9, 2015
Merged

Smartsearch: collation issue when searching in back-end index#8307
rdeutz merged 2 commits intojoomla:stagingfrom
infograf768:finder_indexdate

Conversation

@infograf768
Copy link
Copy Markdown
Member

This solves #8298

Create an article with title in Hebrew
ביו
then purge and run smartsearch indexer (I used snowball as indexer)
When done, enter the title in the search box (still in the indexer page):
screen shot 2015-11-06 at 17 31 15

we get

500 Illegal mix of collations for operation 'like' SQL=SELECT COUNT() FROM `#__finder_links` AS l INNER JOIN `#__finder_types` AS t ON t.id = l.type_id WHERE l.type_id = 4 AND l.title LIKE '%ביו%' OR l.url LIKE '%ביו%' OR l.indexdate LIKE '%ביו%' Illegal mix of collations for operation 'like' SQL=SELECT l.,t.title AS t_title FROM `#__finder_links` AS l INNER JOIN `#__finder_types` AS t ON t.id = l.type_id WHERE l.type_id = 4 AND l.title LIKE '%ביו%' OR l.url LIKE '%ביו%' OR l.indexdate LIKE '%ביו%' LIMIT 0, 20 Illegal mix of collations for operation 'like' SQL=SELECT COUNT() FROM `#__finder_links` AS l INNER JOIN `#__finder_types` AS t ON t.id = l.type_id WHERE l.type_id = 4 AND l.title LIKE '%ביו%' OR l.url LIKE '%ביו%' OR l.indexdate LIKE '%ביו%' Illegal mix of collations for operation 'like' SQL=SELECT COUNT() FROM `#__finder_links` AS l INNER JOIN `#__finder_types` AS t ON t.id = l.type_id WHERE l.type_id = 4 AND l.title LIKE '%ביו%' OR l.url LIKE '%ביו%' OR l.indexdate LIKE '%ביו%'

the issue comes from the fact that the search query includes the indexdate while it is anyway useless here.
See: http://stackoverflow.com/questions/18629094/illegal-mix-of-collations-for-operation-like-while-searching-with-ignited-data for explanation.

After getting the 500, logout, login again and patch.
try again.
You should get :
screen shot 2015-11-07 at 08 58 21

@pe7er
Copy link
Copy Markdown
Contributor

pe7er commented Nov 7, 2015

I have tested this item ✅ successfully on bf3c49e

I was able to reproduce the error. This PR fixes it. Thanks JM!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8307.

@dgrammatiko
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on bf3c49e


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8307.

@infograf768
Copy link
Copy Markdown
Member Author

2 good test: RTC


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8307.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Nov 7, 2015
@zero-24 zero-24 added this to the Joomla! 3.5.0 milestone Nov 7, 2015
@wilsonge
Copy link
Copy Markdown
Contributor

wilsonge commented Nov 7, 2015

@infograf768 if you just remove the like rather than the whole query does it work? Iirc you can't use LIKE for a database date time object. And it would still allow filtering by date for those who want it (sorry travelling on a train so can't test myself to see if it would work)

@infograf768
Copy link
Copy Markdown
Member Author

@wilsonge
We just do not need that query there. No need to go further imho.

@infograf768
Copy link
Copy Markdown
Member Author

I meant we do not need ' OR l.indexdate LIKE ' . $search which is only part of the query

@infograf768
Copy link
Copy Markdown
Member Author

oh, you mean just letting `' OR l.indexdate'). Hmm...
I do not see how anyone would need that in the back-end search...

@wilsonge
Copy link
Copy Markdown
Contributor

wilsonge commented Nov 7, 2015

I mean like OR l.indexdate = $search yeah

I'm not sure either. But if there is a use case at least it would still work?

@infograf768
Copy link
Copy Markdown
Member Author

If someone hacks core admin it is his/her problem

@wilsonge
Copy link
Copy Markdown
Contributor

wilsonge commented Nov 7, 2015

It's not a hack! This is a thing that can be used at the moment?

@infograf768
Copy link
Copy Markdown
Member Author

The only way to keep a search by date is to preg_match $search to make sure it does not contain unicode characters.
One can indeed search by 2015-11-07 in that case and this whatever the date format for the language used in back-end (in French the column would show 7/11/15 but it would not fit the indexdate in the column.
I doubt anybody would have ever used that in the Indexer page...
Anyway, this would work

        // Check the search phrase.
        if ($this->getState('filter.search') != '')
        {
            $search = $db->quote('%' . str_replace(' ', '%', $db->escape(trim($this->getState('filter.search')), true) . '%'));

            // Do not filter by indexdate if $search contains non-ascii characters
            if (preg_match('/[^\x00-\x7F]/', $search))
            {
                $query->where('l.title LIKE ' . $search . ' OR l.url LIKE ' . $search);
            }
            else
            {
                $query->where('l.title LIKE ' . $search . ' OR l.url LIKE ' . $search . ' OR l.indexdate LIKE  ' . $search);
            }
        }

Would you be satisfied with this?

@joomla-cms-bot
Copy link
Copy Markdown

This PR has received new commits.

CC: @DGT41, @pe7er


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8307.

@fontanil
Copy link
Copy Markdown

fontanil commented Nov 8, 2015

I have tested this item ✅ successfully on 00f2a62

Tested on 3.5.0 beta1: successfull on date and unicode. Thanks


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8307.

@infograf768
Copy link
Copy Markdown
Member Author

@DGT41, @pe7er, @wilsonge
One test more please to get this in.

@waader
Copy link
Copy Markdown
Contributor

waader commented Nov 9, 2015

I have tested this item ✅ successfully on 00f2a62

Thanks,infograf768!


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8307.

rdeutz added a commit that referenced this pull request Nov 9, 2015
Smartsearch: collation issue when searching in back-end index
@rdeutz rdeutz merged commit 1d3a872 into joomla:staging Nov 9, 2015
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Nov 9, 2015
@ertinet
Copy link
Copy Markdown

ertinet commented Nov 9, 2015

Thank you all for your assistance
We've tested it and it work perfectly

Thanks and Regards
Rose ERTINET

@infograf768 infograf768 deleted the finder_indexdate branch November 9, 2015 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants