Fix #1406 convert 'jp' to 'ja' in lang table

This commit is contained in:
Kijin Sung 2020-10-03 01:30:28 +09:00
parent 0177ee3abe
commit 338951f5c8
5 changed files with 67 additions and 4 deletions

View file

@ -104,6 +104,18 @@ class module extends ModuleObject
if(!$oDB->isColumnExists('action_forward', 'route_regexp')) return true;
if(!$oDB->isColumnExists('action_forward', 'route_config')) return true;
if(!$oDB->isColumnExists('action_forward', 'global_route')) return true;
// check additional indexes on lang table
if(!$oDB->isIndexExists('lang', 'idx_site_srl')) return true;
if(!$oDB->isIndexExists('lang', 'idx_name')) return true;
if(!$oDB->isIndexExists('lang', 'idx_lang_code')) return true;
// check deprecated lang code
$output = executeQuery('module.getLangCount', ['site_srl' => 0, 'lang_code' => 'jp']);
if ($output->data->count > 0)
{
return true;
}
}
/**
@ -173,6 +185,31 @@ class module extends ModuleObject
{
$oDB->addColumn('action_forward', 'global_route', 'char', 1, 'N', true);
}
// check additional indexes on lang table
if(!$oDB->isIndexExists('lang', 'idx_site_srl'))
{
$oDB->addIndex('lang', 'idx_site_srl', array('site_srl'), false);
}
if(!$oDB->isIndexExists('lang', 'idx_name'))
{
$oDB->addIndex('lang', 'idx_name', array('name'), false);
}
if(!$oDB->isIndexExists('lang', 'idx_lang_code'))
{
$oDB->addIndex('lang', 'idx_lang_code', array('lang_code'), false);
}
// check deprecated lang code
$output = executeQuery('module.getLangCount', ['site_srl' => 0, 'lang_code' => 'jp']);
if ($output->data->count > 0)
{
$output = executeQuery('module.updateLangCode', ['lang_code' => 'jp', 'new_lang_code' => 'ja']);
if (!$output->toBool())
{
return $output;
}
}
}
/**

View file

@ -8,5 +8,6 @@
<conditions>
<condition operation="equal" column="site_srl" var="site_srl" notnull="notnull" filter="number" />
<condition operation="equal" column="name" var="name" pipe="and" />
<condition operation="equal" column="lang_code" var="lang_code" pipe="and" />
</conditions>
</query>

View file

@ -0,0 +1,13 @@
<query id="getLangCount" action="select">
<tables>
<table name="lang" />
</tables>
<columns>
<column name="COUNT(*)" alias="count" />
</columns>
<conditions>
<condition operation="equal" column="site_srl" var="site_srl" notnull="notnull" filter="number" />
<condition operation="equal" column="name" var="name" pipe="and" />
<condition operation="equal" column="lang_code" var="lang_code" pipe="and" />
</conditions>
</query>

View file

@ -0,0 +1,11 @@
<query id="updateLangCode" action="update">
<tables>
<table name="lang" />
</tables>
<columns>
<column name="lang_code" var="new_lang_code" notnull="notnull" />
</columns>
<conditions>
<condition operation="equal" column="lang_code" var="lang_code" notnull="notnull" />
</conditions>
</query>

View file

@ -1,6 +1,7 @@
<table name="lang">
<column name="site_srl" type="number" size="11" notnull="notnull" index="idx_lang" />
<column name="name" type="varchar" size="255" notnull="notnull" index="idx_lang" />
<column name="lang_code" type="varchar" size="10" notnull="notnull" index="idx_lang" />
<column name="value" type="text" />
<column name="site_srl" type="number" size="11" notnull="notnull" index="idx_site_srl" />
<column name="name" type="varchar" size="100" notnull="notnull" index="idx_name" />
<column name="lang_code" type="varchar" size="10" notnull="notnull" index="idx_lang_code" />
<column name="value" type="text" />
<index name="idx_lang" columns="site_srl,name,lang_code" />
</table>