Skip to content

Commit 9b0928b

Browse files
committed
fix: controllo su campi personalizzati per moduli premium
1 parent 94e8c52 commit 9b0928b

2 files changed

Lines changed: 40 additions & 4 deletions

File tree

modules/aggiornamenti/database.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,27 @@ function settings_diff($expected, $current)
9191
break;
9292
}
9393

94+
// Carica il file di riferimento principale per il database
95+
$data = [];
9496
if (file_exists(base_dir().'/'.$file_to_check_database)) {
9597
$contents = file_get_contents(base_dir().'/'.$file_to_check_database);
9698
$data = json_decode($contents, true);
97-
} else {
98-
$data = [];
99+
}
100+
101+
// Carica e accoda le definizioni del database dai file mysql.json presenti nelle sottocartelle di modules/
102+
$modules_dir = base_dir().'/modules/';
103+
$database_json_files = glob($modules_dir.'*/'.$file_to_check_database);
104+
105+
if (!empty($database_json_files)) {
106+
foreach ($database_json_files as $database_json_file) {
107+
$database_contents = file_get_contents($database_json_file);
108+
$database_data = json_decode($database_contents, true);
109+
110+
if (!empty($database_data) && is_array($database_data)) {
111+
// Accoda le definizioni del database del modulo a quelle principali
112+
$data = array_merge($data, $database_data);
113+
}
114+
}
99115
}
100116

101117
if (empty($data)) {

modules/aggiornamenti/edit.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,28 @@ function highlightDifferences($current, $expected)
660660

661661
try {
662662
if (!$database_file_missing) {
663-
$contents = file_get_contents(base_dir().'/'.$file_to_check_database);
664-
$data = json_decode($contents, true);
663+
// Carica il file di riferimento principale per il database
664+
$data = [];
665+
if (file_exists(base_dir().'/'.$file_to_check_database)) {
666+
$contents = file_get_contents(base_dir().'/'.$file_to_check_database);
667+
$data = json_decode($contents, true);
668+
}
669+
670+
// Carica e accoda le definizioni del database dai file mysql.json presenti nelle sottocartelle di modules/
671+
$modules_dir = base_dir().'/modules/';
672+
$database_json_files = glob($modules_dir.'*/'.$file_to_check_database);
673+
674+
if (!empty($database_json_files)) {
675+
foreach ($database_json_files as $database_json_file) {
676+
$database_contents = file_get_contents($database_json_file);
677+
$database_data = json_decode($database_contents, true);
678+
679+
if (!empty($database_data) && is_array($database_data)) {
680+
// Accoda le definizioni del database del modulo a quelle principali
681+
$data = array_merge($data, $database_data);
682+
}
683+
}
684+
}
665685

666686
if (!empty($data)) {
667687
$info = Update::getDatabaseStructure();

0 commit comments

Comments
 (0)