|
115 | 115 | exit; |
116 | 116 | } |
117 | 117 |
|
| 118 | + // Verifica SQL mode (ONLY_FULL_GROUP_BY deve essere disabilitato) |
| 119 | + if (!empty(post('test_sqlmode'))) { |
| 120 | + ob_end_clean(); |
| 121 | + if ($dbo->isConnected()) { |
| 122 | + $result = $dbo->fetchOne('SELECT @@GLOBAL.sql_mode AS sql_mode'); |
| 123 | + $sql_mode = $result['sql_mode'] ?? ''; |
| 124 | + $has_only_full_group_by = stripos($sql_mode, 'ONLY_FULL_GROUP_BY') !== false; |
| 125 | + echo json_encode([ |
| 126 | + 'connected' => true, |
| 127 | + 'ok' => !$has_only_full_group_by, |
| 128 | + 'sql_mode' => $sql_mode, |
| 129 | + ]); |
| 130 | + } else { |
| 131 | + echo json_encode(['connected' => false, 'ok' => false, 'sql_mode' => '']); |
| 132 | + } |
| 133 | + exit; |
| 134 | + } |
| 135 | + |
118 | 136 | // Creazione della configurazione |
119 | 137 | if ($dbo->isConnected()) { |
120 | 138 | $new_config = file_get_contents(base_dir().'/config.example.php'); |
@@ -350,12 +368,41 @@ function updateNavigationButtons(currentStep) { |
350 | 368 | $("#install").on("click", function(){ |
351 | 369 |
|
352 | 370 | if($(this).closest("form").parsley().validate()){ |
353 | | - prev_html = $("#install").html(); |
354 | | - $("#install").html("<i class=\'fa fa-spinner fa-pulse fa-fw\'></i> '.tr('Attendere').'..."); |
355 | | - $("#install").prop("disabled", true); |
| 371 | + var $installBtn = $("#install"); |
| 372 | + var prev_html_install = $installBtn.html(); |
| 373 | + $installBtn.html("<i class=\'fa fa-spinner fa-pulse fa-fw\'></i> '.tr('Attendere').'..."); |
| 374 | + $installBtn.prop("disabled", true); |
356 | 375 | $("#test").prop("disabled", true); |
357 | 376 |
|
358 | | - $("#config-form").submit(); |
| 377 | + // Prima verifica SQL mode |
| 378 | + $(this).closest("form").ajaxSubmit({ |
| 379 | + url: "'.base_path_osm().'/index.php", |
| 380 | + data: { test_sqlmode: 1 }, |
| 381 | + type: "post", |
| 382 | + success: function(data) { |
| 383 | + var result; |
| 384 | + try { result = JSON.parse(data.trim()); } catch(e) { result = null; } |
| 385 | +
|
| 386 | + if (result && result.connected && !result.ok) { |
| 387 | + // ONLY_FULL_GROUP_BY è attivo: blocca e avvisa |
| 388 | + $installBtn.html(prev_html_install); |
| 389 | + $installBtn.prop("disabled", false); |
| 390 | + $("#test").prop("disabled", false); |
| 391 | + swal( |
| 392 | + "'.tr('Configurazione MySQL incompatibile').'", |
| 393 | + "'.addslashes(tr('La SQL mode del server MySQL contiene ONLY_FULL_GROUP_BY, incompatibile con OpenSTAManager.') . "\n\n" . tr('Aggiungi nel file my.ini nella sezione [mysqld]:') . "\n\nsql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION\n\n" . tr('Poi riavvia MySQL e riprova.')).'", |
| 394 | + "error" |
| 395 | + ); |
| 396 | + } else { |
| 397 | + // SQL mode OK (o non connesso: lascia proseguire) |
| 398 | + $("#config-form").submit(); |
| 399 | + } |
| 400 | + }, |
| 401 | + error: function() { |
| 402 | + // In caso di errore AJAX, lascia proseguire (il server gestirà) |
| 403 | + $("#config-form").submit(); |
| 404 | + } |
| 405 | + }); |
359 | 406 | } |
360 | 407 |
|
361 | 408 | }); |
|
0 commit comments