feat(admin): remove legacy setting keys that not defined in defaults

This commit is contained in:
2025-11-02 15:05:52 +03:00
parent 3049bd3101
commit 1077417d71
2 changed files with 17 additions and 6 deletions

View File

@@ -93,7 +93,6 @@ class ControllerExtensionModuleTgshop extends Controller
$hasConfig = $this->config->get('module_tgshop_app_name') !== null;
if ($hasConfig) {
$this->cleanUpConfigs();
$this->updateConfigFromDefaults();
$this->cleanUpOldAssets();
$this->injectVueJs();
@@ -639,6 +638,21 @@ HTML,
$this->config->set($key, $value);
}
}
$diffToDelete = [];
foreach ($settings as $key => $value) {
if (! array_key_exists($key, $defaults)) {
$diffToDelete[] = $key;
}
}
if ($diffToDelete) {
$keys = implode(', ', array_map(function ($key) {
return "'{$key}'";
}, $diffToDelete));
$this->db->query("DELETE FROM " . DB_PREFIX . "setting WHERE `key` IN ($keys)");
$this->log->write('[TELECART] Удалены старые конфиги: ' . $keys);
}
}
private function cleanUpOldAssets(): void
@@ -716,9 +730,4 @@ HTML,
throw new RuntimeException('Unable to load Vuejs frontend.');
}
}
private function cleanUpConfigs(): void
{
//
}
}