diff --git a/modules/install/install.controller.php b/modules/install/install.controller.php index 8a0c36581..7beb0e337 100644 --- a/modules/install/install.controller.php +++ b/modules/install/install.controller.php @@ -529,17 +529,25 @@ class installController extends install $schema_dir = sprintf('%s/schemas/', $module_path); $schema_files = FileHandler::readDir($schema_dir, NULL, false, true); - $file_cnt = count($schema_files); - for($i=0;$i<$file_cnt;$i++) + foreach ($schema_files as $filename) { - $file = trim($schema_files[$i]); - if(!$file || substr($file,-4)!='.xml') continue; - $table_name = substr(basename($file), 0, -4); - if($oDB->isTableExists($table_name)) continue; - $output = $oDB->createTableByXmlFile($file); - if($output === false) + if (!preg_match('/^([a-zA-Z0-9_]+)\.xml$/', $filename, $matches)) { - throw new Exception(lang('msg_create_table_failed') . ': ' . basename($file) . ': ' . $oDB->getError()->getMessage()); + continue; + } + if (!preg_match('/]*deleted="true"/i', file_get_contents($schema_dir . $filename))) + { + continue; + } + $table_name = $matches[1]; + if($oDB->isTableExists($table_name)) + { + continue; + } + $output = $oDB->createTable($schema_dir . $filename); + if(!$output->toBool()) + { + throw new Exception(lang('msg_create_table_failed') . ': ' . $table_name . ': ' . $oDB->getError()->getMessage()); } } // Create a table and module instance and then execute install() method