Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up utf8 parameter usage #6868

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions other/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1060,24 +1060,21 @@ function ForumSettings()
require(dirname(__FILE__) . '/Settings.php');

// UTF-8 requires a setting to override the language charset.
if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8'])))
if (!$databases[$db_type]['utf8_support']())
{
if (!$databases[$db_type]['utf8_support']())
{
$incontext['error'] = sprintf($txt['error_utf8_support']);
return false;
}
$incontext['error'] = sprintf($txt['error_utf8_support']);
return false;
}

if (!empty($databases[$db_type]['utf8_version_check']) && version_compare($databases[$db_type]['utf8_version'], preg_replace('~\-.+?$~', '', eval($databases[$db_type]['utf8_version_check'])), '>'))
{
$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
return false;
}
else
// Set the character set here.
installer_updateSettingsFile(array('db_character_set' => 'utf8'));
if (!empty($databases[$db_type]['utf8_version_check']) && version_compare($databases[$db_type]['utf8_version'], preg_replace('~\-.+?$~', '', eval($databases[$db_type]['utf8_version_check'])), '>'))
{
$incontext['error'] = sprintf($txt['error_utf8_version'], $databases[$db_type]['utf8_version']);
return false;
}

// Set the character set here.
installer_updateSettingsFile(array('db_character_set' => 'utf8'));

// Good, skip on.
return true;
}
Expand Down Expand Up @@ -1186,12 +1183,9 @@ function DatabasePopulation()
$replaces['{$engine}'] = $has_innodb ? 'InnoDB' : 'MyISAM';
$replaces['{$memory}'] = (!$has_innodb && in_array('MEMORY', $engines)) ? 'MEMORY' : $replaces['{$engine}'];

// If the UTF-8 setting was enabled, add it to the table definitions.
if (!empty($databases[$db_type]['utf8_support']) && (!empty($databases[$db_type]['utf8_required']) || isset($_POST['utf8'])))
{
$replaces['{$engine}'] .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
$replaces['{$memory}'] .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
}
// UTF-8 is required.
$replaces['{$engine}'] .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';
$replaces['{$memory}'] .= ' DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci';

// One last thing - if we don't have InnoDB, we can't do transactions...
if (!$has_innodb)
Expand Down Expand Up @@ -1288,8 +1282,7 @@ function DatabasePopulation()
}

// Make sure UTF will be used globally.
if ((!empty($databases[$db_type]['utf8_support']) && !empty($databases[$db_type]['utf8_required'])) || (empty($databases[$db_type]['utf8_required']) && !empty($databases[$db_type]['utf8_support']) && isset($_POST['utf8'])))
$newSettings[] = array('global_character_set', 'UTF-8');
$newSettings[] = array('global_character_set', 'UTF-8');

// Are we allowing stat collection?
if (!empty($_POST['stats']) && substr($boardurl, 0, 16) != 'http://localhost' && empty($modSettings['allow_sm_stats']) && empty($modSettings['enable_sm_stats']))
Expand Down
3 changes: 1 addition & 2 deletions other/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2021,8 +2021,7 @@ function($errno, $errstr, $errfile, $errline) use ($support_js)
$last_step = '';

// Make sure all newly created tables will have the proper characters set; this approach is used throughout upgrade_2-1_mysql.php
if (isset($db_character_set) && $db_character_set === 'utf8')
$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);
$lines = str_replace(') ENGINE=MyISAM;', ') ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;', $lines);

// Count the total number of steps within this file - for progress.
$file_steps = substr_count(implode('', $lines), '---#');
Expand Down