Advanced search  

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

Pages: [1]   Go Down

Author Topic: Set default collation of the database tables during initial install  (Read 5834 times)

0 Members and 1 Guest are viewing this topic.

Freder

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • Galerie Fotografii - Alfred Broda

CHANGED to 'Set default collation of the database tables during initial install'

Unfortunately CPG (as of 1.4.10) lacks this kind of functionality. I use it with the 'Polish' language setting, but any Polish characters sent to the database return as any variation of '?' signs... I patched my version like so (in functions.inc.php):
Code: [Select]
function cpg_db_connect()
{
        global $CONFIG;
        $result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
        if (!$result) {
                return false;
        }
        if (!mysql_select_db($CONFIG['dbname']))
                return false;
        mysql_query("SET NAMES 'latin2'");
        return $result;
}

After manually changing the encoding of the fields in the tables to 'latin2_bin' it works.

I suppose this is a 'hack' kind of solution, I suggest connecting this to the language selection in the configuration panel and using UTF-8 or some similar clean solution.
« Last Edit: February 08, 2007, 11:23:53 am by Freder »
Logged

Nibbler

  • Guest
Re: Language specific special character support
« Reply #1 on: February 07, 2007, 03:59:19 pm »

Coppermine already uses UTF-8 exclusively.
Logged

Freder

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • Galerie Fotografii - Alfred Broda
Re: Language specific special character support
« Reply #2 on: February 07, 2007, 04:38:56 pm »

Yes, it does for displaying text, it does not during transactions with MySQL. This causes corruption of Polish (and any other unusual) characters. I suppose this can be fixed by setting the defaults in the database, but this 'per session' setting overrides it anyway, so setting it would create minimum overhead and guarantee correct characters (as long as the tables are set up correctly).

I suppose I will investigate this phenomenon further.

EDIT:

Yes, utf8 works without my hack. But only if the database is set to perform all transactions in 'utf8_unicode_ci' (or any variation of utf8_ )and the collation for fields in the tables are set to 'utf8_unicode_ci' (same as previous).

I'll take a look at the functions creating the databases to confirm where the problem lies (the fields had some strange collation in my DB; 'latin1_swedish_ci')
« Last Edit: February 07, 2007, 05:01:26 pm by Freder »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Language specific special character support in Database
« Reply #3 on: February 08, 2007, 08:28:16 am »

It's not surprising imo that you need to set the collation of your database to utf-8 if you want to store utf-8 content in it.
Logged

Freder

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • Galerie Fotografii - Alfred Broda
Re: Language specific special character support in Database
« Reply #4 on: February 08, 2007, 10:34:47 am »

You are right. My bad in not finding that out earlier, that would save me a lot of fixing right now. :-)

Anyway, I checked the 'shema.sql' and 'install.php' files, they do not set the collation anywhere. This is why my original install corrupted the stings. After the initial install it is quite some work to fix all the collation settings for the tables (every field has to have it changed). Wouldn't it be easier to set 'DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci' in 'shema.sql' from the start? Or perhaps at least a mention of the issue in the install docs should be made (there is none at the time)...
« Last Edit: February 08, 2007, 11:15:42 am by Freder »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Language specific special character support in Database
« Reply #5 on: February 08, 2007, 11:02:08 am »

OK, let's re-phrase your feature request then: make coppermine set the collation of the database tables up during initial install. OK?
Logged

Freder

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • Galerie Fotografii - Alfred Broda
Re: Language specific special character support in Database
« Reply #6 on: February 08, 2007, 11:21:07 am »

Yes, that would make things much easier for people who have no idea about collation or character sets (and do not have to with UTF-8) like I did when I first installed Coppermine.  :)

BTW thanks for a great Gallery! ;D
Logged

Nibbler

  • Guest
Re: Set default collation of the database tables during initial install
« Reply #7 on: February 08, 2007, 02:09:54 pm »

You can't specify the character set on pre 4.1 versions of mysql - that's why it's not in the schema.sql.
Logged

Freder

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • Galerie Fotografii - Alfred Broda
Re: Set default collation of the database tables during initial install
« Reply #8 on: February 08, 2007, 05:22:37 pm »

True, that produces an error. Maybe the database could be tested to be 'collation compliant'? I suppose somebody can be using pre 4.1 MySQL, but is it likely? I don't think it would be a good idea to duplicate any files (like 'shema.sql')...
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 20 queries.