If this is your first visit, check our documentation. To post, register or login.
Forums / Bug Reports / *[Done v1.6.0] Fresh install or upgrade using Latin1 still results in utf8

*[Done v1.6.0] Fresh install or upgrade using Latin1 still results in utf8

Locked

Started by lat9 on 25 Sep 2012, 11:32 AM · Views: 2,754

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
25 Sep 2012, 11:32 AM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,140
Plugin Contributions:
56

*[Done v1.6.0] Fresh install or upgrade using Latin1 still results in utf8

If you perform a fresh install of v1.5.1 (or v1.5.0) into an empty database created using latin1_general_ci collation and select "Latin1" as the database collation type during the install, the resulting database uses only utf8_general_ci collation. If you perform an upgrade of a pre-v1.5.0 database that uses latin1 collation and select "Latin1" as the database collation type, the new admin-related database tables are created using utf8_general_ci collation.

Don't get me wrong, I'm in the process of converting ***all ***my sites to use utf8 ... but if a feature is provided it should work properly.

The problem is in the file /zc_install/includes/installer_params.php:

<?php
/**
 * @package Installer
 * @access private
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: installer_params.php 18819 2011-05-31 20:25:53Z drbyte $
 */

/**
 * Runtime Parameters used by browser interface
 */
//  $session_save_path = (@ini_get('session.save_path') && is_writable(ini_get('session.save_path')) ) ? ini_get('session.save_path') : realpath('../cache');
  $session_save_path = (is_writable(realpath('../cache')) ) ? realpath('../cache') : ini_get('session.save_path');
  define('SESSION_WRITE_DIRECTORY', $session_save_path);
  define('DEBUG_LOG_FOLDER', realpath('../cache'));

  // Set the following to TRUE if having problems (blank pages, etc). Best to leave at FALSE for normal use.
  define('STRICT_ERROR_REPORTING', FALSE);


  // optionally set this to 'latin1':
  define('DB_CHARSET', 'utf8');

  // optionally uncomment the following line if choosing 'utf8' or 'latin1' above are causing problems:
  // define('IGNORE_DB_CHARSET', TRUE);

The DB_CHARSET define is used by the CREATE_TABLE clause of the select statement of the executeSQL function within /zc_install/includes/functions/general.php and is set (if not already defined) by the dbActivate function within /zc_install/includes/classes/installer.php to reflect the value specified by the drop-down box within the Database Configuration step of the install.

The problem is that DB_CHARSET is already defined during the inclusion of the installer_parms.php file ... the net result being that a fresh install of v1.5.1 or v1.5.0 ALWAYS uses a utf8_general_ci collation regardless of the value chosen by the user during the install.

The fix is to simply comment out the define statement in the installer_parms.php file:

<?php
/**
 * @package Installer
 * @access private
 * @copyright Copyright 2003-2011 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: installer_params.php 18819 2011-05-31 20:25:53Z drbyte $
 */

/**
 * Runtime Parameters used by browser interface
 */
//  $session_save_path = (@ini_get('session.save_path') && is_writable(ini_get('session.save_path')) ) ? ini_get('session.save_path') : realpath('../cache');
  $session_save_path = (is_writable(realpath('../cache')) ) ? realpath('../cache') : ini_get('session.save_path');
  define('SESSION_WRITE_DIRECTORY', $session_save_path);
  define('DEBUG_LOG_FOLDER', realpath('../cache'));

  // Set the following to TRUE if having problems (blank pages, etc). Best to leave at FALSE for normal use.
  define('STRICT_ERROR_REPORTING', FALSE);


  // optionally set this to 'latin1':
//  define('DB_CHARSET', 'utf8');

  // optionally uncomment the following line if choosing 'utf8' or 'latin1' above are causing problems:
  // define('IGNORE_DB_CHARSET', TRUE);
25 Sep 2012, 5:33 PM
#2
dw08gm avatar

dw08gm

Totally Zenned

Join Date:
Sep 2008
Location:
DownUnder, overlooking South Pole.
Posts:
1,022
Plugin Contributions:
2

Re: *[Done v1.6.0] Fresh install or upgrade using Latin1 still results in utf8

FWIW I initially setup my database as utf8_unicode_ci, and then for consistency changed line 150 in zc_install\includes\functions\general.php

from
$collateSuffix = (strtoupper($param[3]) == 'AS' || (isset($param[6]) && strtoupper($param[6]) == 'AS')) ? '' : ' COLLATE ' . DB_CHARSET . '_general_ci';

to
$collateSuffix = (strtoupper($param[3]) == 'AS' || (isset($param[6]) && strtoupper($param[6]) == 'AS')) ? '' : ' COLLATE ' . DB_CHARSET . '_unicode_ci';

25 Sep 2012, 6:37 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: *[Done v1.6.0] Fresh install or upgrade using Latin1 still results in utf8

lat9, you had posted the same thing already at: http://www.zen-cart.com/showthread.php?198284-Fresh-install-of-v1-5-0-database-CHARSET-anomoly&p=1143929#post1143929
It was slated to be commented out in v1.5.1.
But, a mistake was made between pre-release testing of v1.5.1 and preparation of the final commits ... and the line you suggested being commented out got uncommented.

It will be commented out again in the next release. Apologies for the oversight. :blush:

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

26 Sep 2012, 7:55 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,140
Plugin Contributions:
56

Re: *[Done v1.6.0] Fresh install or upgrade using Latin1 still results in utf8

DrByte, apologies for the additional post; I thought that since it wasn't posted/moved to the bug reports area that it was being ignored. Next time, I'll ask in the initial thread before re-posting.