Use full paths for table checking and creating

This commit is contained in:
Kijin Sung 2021-01-09 00:17:01 +09:00
parent b136b3e0c7
commit cdfd2196ec
2 changed files with 12 additions and 7 deletions

View file

@ -531,20 +531,21 @@ class installController extends install
foreach ($schema_files as $filename)
{
if (!preg_match('/^([a-zA-Z0-9_]+)\.xml$/', $filename, $matches))
if (!preg_match('/\/([a-zA-Z0-9_]+)\.xml$/', $filename, $matches))
{
continue;
}
if (!preg_match('/<table\s[^>]*deleted="true"/i', file_get_contents($schema_dir . $filename)))
if (preg_match('/<table\s[^>]*deleted="true"/i', file_get_contents($filename)))
{
continue;
}
$table_name = $matches[1];
if($oDB->isTableExists($table_name))
{
continue;
}
$output = $oDB->createTable($schema_dir . $filename);
$output = $oDB->createTable($filename);
if(!$output->toBool())
{
throw new Exception(lang('msg_create_table_failed') . ': ' . $table_name . ': ' . $oDB->getError()->getMessage());

View file

@ -1443,10 +1443,10 @@ class moduleModel extends module
// Get the number of xml files to create a table in schemas
$table_count = 0;
$schema_files = FileHandler::readDir($path.'schemas', '/(\.xml)$/');
$schema_files = FileHandler::readDir($path.'schemas', '/(\.xml)$/', false, true);
foreach ($schema_files as $filename)
{
if (!preg_match('/<table\s[^>]*deleted="true"/i', file_get_contents($path . 'schemas/' . $filename)))
if (!preg_match('/<table\s[^>]*deleted="true"/i', file_get_contents($filename)))
{
$table_count++;
}
@ -1456,8 +1456,12 @@ class moduleModel extends module
$created_table_count = 0;
foreach ($schema_files as $filename)
{
list($table_name, $unused) = explode('.', $filename);
if($oDB->isTableExists($table_name))
if (!preg_match('/\/([a-zA-Z0-9_]+)\.xml$/', $filename, $matches))
{
continue;
}
if($oDB->isTableExists($matches[1]))
{
$created_table_count++;
}