Probable Bug in keyword.inc.php Probable Bug in keyword.inc.php
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Probable Bug in keyword.inc.php

Started by Preludian, January 15, 2006, 01:51:56 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Preludian

Hi, there, I had some problems with the search feature, to be precise it was the keyword listing at the bottom. I have some Umlaute ( äöü) in the keywords and they didn't display correctly there, clicking on a false keyword (k?ln instead of köln) produced no result. But only there! In every other menu the Umlaute work correctly. So after eliminating every other possibility I finally managed to determine the cause.
In the /include/keyword.inc.php in line 40 it states


  // Find unique keywords
  $keywords_array = array();

  while (list($keywords) = mysql_fetch_row($result)) {
      $array = explode(" ",$keywords);

      foreach($array as $word)
      {
[b]       if (!in_array($word =strtolower($word),$keywords_array)) $keywords_array[] = $word;;[/b]
      }
  }


I changed the strtolower to utf_strtolower and everything worked as it should.

Here's the correct line to cut&paste:

if (!in_array($word = utf_strtolower($word),$keywords_array)) $keywords_array[] = $word;

Oh, I have the 1.4.3 stable installed.

bye


CoppertoneStudios

Thanks for this fix!  I was trying to understand why my keywords aren't unique.  Is there any reason this sholdn't be rolled into the main trunk?


Joachim Müller

Quote from: CoppertoneStudios on March 08, 2006, 01:21:05 AM
Is there any reason this sholdn't be rolled into the main trunk?
Threads that are in the bugs board section that are not tagged with "invalid" or "fixed" require looking into by the devs. Ifthe fix is valid and doesn't have a negative impact somewhere else (that's why devs have to look into it), it will go into the core.

Titooy


Joachim Müller

could you summarize the thread you refered to if it helps to fix the issue on this thread?

Titooy

The problem is exacly the same as described above : on the search page, in the keywords list, all accentuated  characters (actually, all the multi-byte characters) are misunderstood. The reason is that strtolower lowercases each byte. For instance, é which is read as é in ascii is transformed to ã© which results in a display. That's why utf_strtolower should be used in keyword.inc.php instead of strtolower as it's already used in keywordmgr.php

Joachim Müller

so does the fix as propossed by Preludian cure the issues?

Titooy


Joachim Müller

added suggested changes to stable and devel branch of svn. Will go into cpg1.4.6