Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $(function () {
} else if ($dbPrefix.val() && !$dbPrefix.val().match(/[_]$/)) {
alert(bcI18n.message5);
result = false;
} else if ($dbPrefix.val() && !$dbPrefix.val().match(/^[a-zA-z0-9_]+_$/)) {
} else if ($dbPrefix.val() && !$dbPrefix.val().match(/^[a-z0-9_]+_$/)) {
alert(bcI18n.message6);
result = false;
} else if ($dbName.val().match(/^.*\..*$/)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
'message3' => __d('baser_core', 'データベース名を入力してください。'),
'message4' => __d('baser_core', '他のアプリケーションと重複しないプレフィックスを入力してください。(例)mysite_'),
'message5' => __d('baser_core', 'プレフィックスの末尾はアンダースコアにしてください。(例)mysite_'),
'message6' => __d('baser_core', 'プレフィックスは英数字とアンダースコアの組み合わせにしてください。(例)mysite_'),
'message6' => __d('baser_core', 'プレフィックスは半角英小文字・数字・アンダースコアの組み合わせにしてください。(例)mysite_'),
'message7' => __d('baser_core', 'ドット(.)を含むデータベース名にはインストールできません。'),
'message8' => __d('baser_core', 'データベースのポートナンバーを入力してください。')
]);
Expand Down Expand Up @@ -91,7 +91,7 @@
<small><?php echo __d('baser_core', 'ポート') ?></small>
</div>
<br style="clear:both"/><br>
<small>※ <?php echo __d('baser_core', 'プレフィックスは英数字とアンダースコアの組み合わせとし末尾はアンダースコアにしてください。<br />※ ホスト名、データベース名、ポートは実際の環境に合わせて書き換えてください。') ?></small>
<small>※ <?php echo __d('baser_core', 'プレフィックスは半角英小文字・数字・アンダースコアの組み合わせとし末尾はアンダースコアにしてください。<br />※ ホスト名、データベース名、ポートは実際の環境に合わせて書き換えてください。') ?></small>
</li>
</ul>
</div>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,18 @@ public function step3(InstallationsAdminServiceInterface $service)
$this->setRequest($this->request->withParsedBody($service->getDefaultValuesStep3($this->getRequest())));
} else {
$service->writeDbSettingToSession($this->getRequest(), $this->getRequest()->getData());
$dbPrefix = $this->request->getData('dbPrefix');
$dbPrefix = is_string($dbPrefix) ? $dbPrefix : '';
$invalidPrefix = $dbPrefix !== '' && !preg_match('/^[a-z0-9_]+_$/', $dbPrefix);
$invalidPrefixMessage = __d('baser_core', 'プレフィックスは半角英小文字・数字・アンダースコアの組み合わせとし末尾はアンダースコアにしてください。(例)mysite_');
switch($this->request->getData('mode')) {
case 'back':
return $this->redirect(['action' => 'step2']);
case 'checkDb':
if ($invalidPrefix) {
$this->BcMessage->setError($invalidPrefixMessage);
break;
}
try {
$service->testConnectDb($service->readDbSetting($this->getRequest()));
$this->BcMessage->setInfo(__d('baser_core', 'データベースへの接続に成功しました。'));
Expand All @@ -125,6 +133,10 @@ public function step3(InstallationsAdminServiceInterface $service)
}
break;
case 'createDb':
if ($invalidPrefix) {
$this->BcMessage->setError($invalidPrefixMessage);
break;
}
ini_set("max_execution_time", 180);
try {
$service->deleteAllTables($this->getRequest());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,66 @@ public function testStep3()
Configure::write("BcEnv.isInstalled", true);
}

/**
* Step 3: データベースの接続設定(無効なプレフィックス / mode=checkDb)
*/
public function testStep3InvalidPrefixCheckDb()
{
$this->enableSecurityToken();
$this->enableCsrfToken();
Configure::write("BcEnv.isInstalled", false);

$config = [
'mode' => 'checkDb',
'dbType' => 'mysql',
'dbHost' => 'localhost',
'dbPrefix' => 'MySite_',
'dbPort' => '3306',
'dbUsername' => 'dbUsername',
'dbPassword' => 'dbPassword',
'dbSchema' => 'dbSchema',
'dbName' => 'basercms',
'dbEncoding' => 'utf-8',
'dbDataPattern' => 'BcThemeSample.default'
];

$this->post('/baser/admin/bc-installer/installations/step3', $config);
$this->assertResponseCode(200);
$this->assertResponseContains('プレフィックスは半角英小文字・数字・アンダースコアの組み合わせとし末尾はアンダースコアにしてください。');

Configure::write("BcEnv.isInstalled", true);
}

/**
* Step 3: データベースの接続設定(無効なプレフィックス / mode=createDb)
*/
public function testStep3InvalidPrefixCreateDb()
{
$this->enableSecurityToken();
$this->enableCsrfToken();
Configure::write("BcEnv.isInstalled", false);

$config = [
'mode' => 'createDb',
'dbType' => 'mysql',
'dbHost' => 'localhost',
'dbPrefix' => 'MySite_',
'dbPort' => '3306',
'dbUsername' => 'dbUsername',
'dbPassword' => 'dbPassword',
'dbSchema' => 'dbSchema',
'dbName' => 'basercms',
'dbEncoding' => 'utf-8',
'dbDataPattern' => 'BcThemeSample.default'
];

$this->post('/baser/admin/bc-installer/installations/step3', $config);
$this->assertResponseCode(200);
$this->assertResponseContains('プレフィックスは半角英小文字・数字・アンダースコアの組み合わせとし末尾はアンダースコアにしてください。');

Configure::write("BcEnv.isInstalled", true);
}

/**
* Step 4: データベース生成/管理者ユーザー作成
*/
Expand Down
Loading