Skip to content

Commit 907a44e

Browse files
committed
Resolve #845
1 parent eef6d90 commit 907a44e

4 files changed

Lines changed: 35 additions & 12 deletions

File tree

assets/modules/store/installer/sqlParser.class.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ class SqlParser {
77
var $conn, $installFailed, $sitename, $adminname, $adminemail, $adminpass, $managerlanguage;
88
var $mode, $fileManagerPath, $imgPath, $imgUrl;
99
var $connection_charset, $connection_method;
10+
public $database_collation;
1011

1112
public function __construct() {
1213
$adminname='';
13-
$adminemail='';
14-
$adminpass='';
15-
$connection_charset= 'utf8';
16-
$managerlanguage='english';
17-
$connection_method = 'SET CHARACTER SET';
14+
$adminemail='';
15+
$adminpass='';
16+
$connection_charset= 'utf8';
17+
$managerlanguage='english';
18+
$connection_method = 'SET CHARACTER SET';
1819
$auto_template_logic = 'parent';
1920
$this->adminname = $adminname;
2021
$this->adminemail = $adminemail;
@@ -27,7 +28,7 @@ public function __construct() {
2728

2829
function process($filename) {
2930
global $modx_version,$modx;
30-
31+
3132
// check to make sure file exists
3233
if (!file_exists($filename)) {
3334
$this->mysqlErrors[] = array("error" => "File '$filename' not found");
@@ -53,6 +54,7 @@ function process($filename) {
5354

5455
// replace {} tags
5556
$idata = str_replace('{PREFIX}', $modx->db->config['table_prefix'], $idata);
57+
$idata = str_replace('{TABLEENCODING}', $this->getTableEncoding(), $idata);
5658
$idata = str_replace('{ADMIN}', $this->adminname, $idata);
5759
$idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata);
5860
$idata = str_replace('{ADMINPASS}', $this->adminpass, $idata);
@@ -82,9 +84,17 @@ function process($filename) {
8284
$num = $num + 1;
8385
if ($sql_do) $modx->db->query($sql_do, false);
8486
}
85-
86-
87+
88+
8789
}
88-
}
8990

90-
?>
91+
public function getTableEncoding()
92+
{
93+
$out = 'DEFAULT CHARSET=' . $this->connection_charset;
94+
if (!empty($this->database_collation)) {
95+
$out .= ' COLLATE=' . $this->database_collation;
96+
}
97+
98+
return $out;
99+
}
100+
}

install/instprocessor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155
include "{$setupPath}/setup.info.php";
156156
include "{$setupPath}/sqlParser.class.php";
157157
$sqlParser = new SqlParser($database_server, $database_user, $database_password, str_replace("`", "", $dbase), $table_prefix, $adminname, $adminemail, $adminpass, $database_connection_charset, $managerlanguage, $database_connection_method, $auto_template_logic);
158+
$sqlParser->database_collation = $database_collation;
158159
$sqlParser->mode = ($installMode < 1) ? "new" : "upd";
159160
/* image and file manager paths now handled via settings screen in Manager
160161
$sqlParser->imageUrl = 'http://' . $_SERVER['SERVER_NAME'] . $base_url . "assets/";

install/setup.data.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ REPLACE INTO `{PREFIX}webgroup_names` VALUES ('2','Registered Users');
170170
#
171171

172172

173-
CREATE TABLE IF NOT EXISTS `{PREFIX}jot_content` (`id` int(10) NOT NULL auto_increment, `title` varchar(255) default NULL, `tagid` varchar(50) default NULL, `published` int(1) NOT NULL default '0', `uparent` int(10) NOT NULL default '0', `parent` int(10) NOT NULL default '0', `flags` varchar(25) default NULL, `secip` varchar(32) default NULL, `sechash` varchar(32) default NULL, `content` mediumtext, `customfields` mediumtext, `mode` int(1) NOT NULL default '1', `createdby` int(10) NOT NULL default '0', `createdon` int(20) NOT NULL default '0', `editedby` int(10) NOT NULL default '0', `editedon` int(20) NOT NULL default '0', `deleted` int(1) NOT NULL default '0', `deletedon` int(20) NOT NULL default '0', `deletedby` int(10) NOT NULL default '0', `publishedon` int(20) NOT NULL default '0', `publishedby` int(10) NOT NULL default '0', PRIMARY KEY (`id`), KEY `parent` (`parent`), KEY `secip` (`secip`), KEY `tagidx` (`tagid`), KEY `uparent` (`uparent`)) ENGINE=MyISAM;
173+
CREATE TABLE IF NOT EXISTS `{PREFIX}jot_content` (`id` int(10) NOT NULL auto_increment, `title` varchar(255) default NULL, `tagid` varchar(50) default NULL, `published` int(1) NOT NULL default '0', `uparent` int(10) NOT NULL default '0', `parent` int(10) NOT NULL default '0', `flags` varchar(25) default NULL, `secip` varchar(32) default NULL, `sechash` varchar(32) default NULL, `content` mediumtext, `customfields` mediumtext, `mode` int(1) NOT NULL default '1', `createdby` int(10) NOT NULL default '0', `createdon` int(20) NOT NULL default '0', `editedby` int(10) NOT NULL default '0', `editedon` int(20) NOT NULL default '0', `deleted` int(1) NOT NULL default '0', `deletedon` int(20) NOT NULL default '0', `deletedby` int(10) NOT NULL default '0', `publishedon` int(20) NOT NULL default '0', `publishedby` int(10) NOT NULL default '0', PRIMARY KEY (`id`), KEY `parent` (`parent`), KEY `secip` (`secip`), KEY `tagidx` (`tagid`), KEY `uparent` (`uparent`)) ENGINE=MyISAM {TABLEENCODING};
174174

175175

176176
#
@@ -204,5 +204,5 @@ REPLACE INTO `{PREFIX}jot_content` VALUES ('15','I\'m untrusted','','0','9','0',
204204
#
205205

206206

207-
CREATE TABLE IF NOT EXISTS `{PREFIX}jot_subscriptions` (`id` mediumint(10) NOT NULL auto_increment, `uparent` mediumint(10) NOT NULL default '0', `tagid` varchar(50) NOT NULL default '', `userid` mediumint(10) NOT NULL default '0', PRIMARY KEY (`id`), KEY `uparent` (`uparent`), KEY `tagid` (`tagid`), KEY `userid` (`userid`)) ENGINE=MyISAM;
207+
CREATE TABLE IF NOT EXISTS `{PREFIX}jot_subscriptions` (`id` mediumint(10) NOT NULL auto_increment, `uparent` mediumint(10) NOT NULL default '0', `tagid` varchar(50) NOT NULL default '', `userid` mediumint(10) NOT NULL default '0', PRIMARY KEY (`id`), KEY `uparent` (`uparent`), KEY `tagid` (`tagid`), KEY `userid` (`userid`)) ENGINE=MyISAM {TABLEENCODING};
208208

install/sqlParser.class.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class SqlParser {
2727
public $connection_method;
2828
public $ignoreDuplicateErrors;
2929
public $autoTemplateLogic;
30+
public $database_collation;
3031

3132
public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') {
3233
$this->host = $host;
@@ -92,6 +93,7 @@ public function process($filename) {
9293

9394
// replace {} tags
9495
$idata = str_replace('{PREFIX}', $this->prefix, $idata);
96+
$idata = str_replace('{TABLEENCODING}', $this->getTableEncoding(), $idata);
9597
$idata = str_replace('{ADMIN}', $this->adminname, $idata);
9698
$idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata);
9799
$idata = str_replace('{ADMINPASS}', $this->adminpass, $idata);
@@ -139,6 +141,16 @@ public function process($filename) {
139141
}
140142
}
141143

144+
public function getTableEncoding()
145+
{
146+
$out = 'DEFAULT CHARSET=' . $this->connection_charset;
147+
if (!empty($this->database_collation)) {
148+
$out .= ' COLLATE=' . $this->database_collation;
149+
}
150+
151+
return $out;
152+
}
153+
142154
public function close() {
143155
mysqli_close($this->conn);
144156
}

0 commit comments

Comments
 (0)