Guard db-engine remove from dropping panel DB; restore VERSION

This commit is contained in:
2026-06-08 16:05:03 +00:00
parent 6217c3b9f9
commit 237c19c13d
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -1 +1 @@
5251494 1.0.0
+10
View File
@@ -570,6 +570,16 @@ match ($action) {
if (!in_array($engine, ['mysql','mariadb','postgresql'])) Response::error("Invalid engine"); if (!in_array($engine, ['mysql','mariadb','postgresql'])) Response::error("Invalid engine");
if (!in_array($action, ['install','remove','start','stop','restart','set-active'])) Response::error("Invalid action"); if (!in_array($action, ['install','remove','start','stop','restart','set-active'])) Response::error("Invalid action");
// Safety: never remove the engine that is currently hosting the NovaCPX panel DB
if ($action === 'remove') {
$activeConn = strtolower(DB_HOST === 'localhost' ? 'mysql' : '');
$isMariaDB = str_contains(strtolower(shell_exec("mysql --version 2>/dev/null") ?: ''), 'mariadb');
$runningEngine = $isMariaDB ? 'mariadb' : 'mysql';
if ($engine === $runningEngine || ($engine === 'mysql' && $isMariaDB) || ($engine === 'mariadb' && !$isMariaDB)) {
Response::error("Cannot remove $engine — it is currently hosting the NovaCPX panel database. Migrate first.", 409);
}
}
$out = ''; $out = '';
if ($action === 'install') { if ($action === 'install') {
$pkg = match($engine) { $pkg = match($engine) {