Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Searching with UTF-8 Character Set
I have a strange problem in a live installation of Vanilla (which is not public). I hope that someone else had this issue before so he can point me in the right direction.
The forum in question is running perfectly with UTF-8 (as explained by Max_B - thank you for that!). In need of investigating a small but strange problem I have three installations in the meantime – the live forum (running on my client's webspace) an two test installations (locally, on my OS X machine), the latter being copies of the files and the database:
(1) live forum running on:
* Apache 2.0
* PHP 5.2.3
* MySQL 5.0.32
(2) test forum #1 running on:
* Apache 1.3
* PHP 5.2.2
* MySQL 5.0.24a
(3) test forum #2 running on:
* Apache 2.0
* PHP 5.2.3
* MySQL 5.0.45
In the test forums everything works perfectly, but in the live forum the search function does not work if I use special German characters in the search string. So in short:
* any UTF-8 characters are stored and delivered fine, but:
* searching for phrases using special (German) characters gives no results
Here's an example: Let's assume you have an entry with the German word "präsentieren" in the title. In this case
* searching for "prasentieren" (please note there is "a" instead of "ä") will find the article
* searchibg for "präsentieren" (the original phrase) will find nothing
The weird thing about it all is that everything's fine in the test installations. So there must be some incompatibility and/or misconfiguration on the live server, I guess. I did a lot of tests, but could not find the problem.
The problem with the search function (on the live web server) even exists with a completely fresh copy of Vanilla, without any extensions (which is installation #4, of course).
I hope that somebody has an idea where to go from here...
The forum in question is running perfectly with UTF-8 (as explained by Max_B - thank you for that!). In need of investigating a small but strange problem I have three installations in the meantime – the live forum (running on my client's webspace) an two test installations (locally, on my OS X machine), the latter being copies of the files and the database:
(1) live forum running on:
* Apache 2.0
* PHP 5.2.3
* MySQL 5.0.32
(2) test forum #1 running on:
* Apache 1.3
* PHP 5.2.2
* MySQL 5.0.24a
(3) test forum #2 running on:
* Apache 2.0
* PHP 5.2.3
* MySQL 5.0.45
In the test forums everything works perfectly, but in the live forum the search function does not work if I use special German characters in the search string. So in short:
* any UTF-8 characters are stored and delivered fine, but:
* searching for phrases using special (German) characters gives no results
Here's an example: Let's assume you have an entry with the German word "präsentieren" in the title. In this case
* searching for "prasentieren" (please note there is "a" instead of "ä") will find the article
* searchibg for "präsentieren" (the original phrase) will find nothing
The weird thing about it all is that everything's fine in the test installations. So there must be some incompatibility and/or misconfiguration on the live server, I guess. I did a lot of tests, but could not find the problem.
The problem with the search function (on the live web server) even exists with a completely fresh copy of Vanilla, without any extensions (which is installation #4, of course).
I hope that somebody has an idea where to go from here...
0
This discussion has been closed.
Comments
Besides server software version, did you check default php options (magic_quote and the like) and .htaccess also ?
Nevertheless, if phpMyAdmin is ok, you may want to double check you live forum utf-8 configuration.
You told that suhosin patch is on the live server. You must test the simulation flag on this one, not on the local one. If you can't because it's hosted, you may try to install this patch locally and see if it is the culprit.
I see no other clue, right now, beside MySQL version. MySQL doc say something about searching with LIKE operator (Vanilla uses LIKE for search): Be sure to test phpMyAdmin search with a LIKE operator.
OK, this did not work.
To be extra sure, I thought about installing the Suhosin patch on one of my development (OS X) servers. But this is rather tricky stuff, too tricky for me... I'm rather a coder than a programmer.
I tried searching for my user family name (which includes the German letter "ö") with PHPMyAdmin using the LIKE operator: and also Both works fine.
The fact that searching is ok for phpMyAdmin and not Vanilla is the only element we have. Check if both use GET or POST (vanilla may be POST while PMA GET) and set up some testing around this.
Curious if it would be possible to point a local Vanilla installation to the remote DB server to verify this. (It might be inaccessible from the outside...)
Another tool that might help is to upload this file to your installation, and while logged in as administrator visit it and turn on the debug mode (only the administrator roles who toggle this can view it). Then you will be able to see and test the various SQL queries that Vanilla generates at the bottom of the page.
- changing the PHP parameter register_argc_argv does nothing to the phenomenon
- there is no difference using GET or POST parameters. (I verified this using a manually edited search page.)
- the problem is not in the database. As WallPhone suggested, I opened the live database for external connections and connected my development server to this database. Everything worked perfectly. So the problem must be in the Apache/PHP configuration on the live server WORKING TOGETHER with Vanilla. (Everything is OK with PHPMyAdmin, but this Software has been pre-installed by the hosting company somewhere out of the webspace; I have no file access to PHPMyAdmin.)
- I verified that the problem is in Apache/PHP using Vanilla's debug mode. After hitting "search" the German character is still OK in the search field, but obviously it has been garbled on it's way to the database query!
I have written another E-Mail to the hosting company. Unfortunately I have no access to Apache 2 configuration files, I only can switch some PHP configuration options via htaccess. I already tried a lot of PHP options without any success. Maybe the problem is in the Apache config (meaning keith_ is on the right track)?This should not be necessary because Vanilla does output an utf-8 charset header but I have read that some installation override charset someway.
Also, just to keep searching, what are PHP mbstring settings.
In line 35 of /library/Framework/Framework.Class.SqlSearch.php the user query is converted with PHP's 'strtolower' function. This function relies on the current locale setting. This means that in i.e. the default “C†locale, multibyte characters such as "ä" will not be converted properly! Thus the database query will include garbled characters.
On the server in question (Apache/2.0.54 (Debian GNU/Linux) PHP/5.2.3 with Suhosin-Patch DAV/2) the 'locales' seem not to work for the 'strtolower' function! Even adding (immediately before the function call) had no effect. I assume that Debian is not set up correctly. I found out that it needs a package named "locales" in order to properly support locales. Maybe they did not compile this package? I do not know this for sure. Anyway.
I solved the problem by simply removing the mentioned line in the source code. (In my eyes there is no need for it, because MySQL itself will behave case insensitive.)
I wrote the above to the hosting company as well. I will be back here if they have anything interesting to say!