diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index d3d8364b810..06d14be0720 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -111,6 +111,7 @@ print 'Option clean_menus is '.(GETPOST('clean_menus', 'alpha') ? GETPOST('clean print 'Option clean_orphelin_dir is '.(GETPOST('clean_orphelin_dir', 'alpha') ? GETPOST('clean_orphelin_dir', 'alpha') : 'undefined').'
'."\n"; print 'Option clean_product_stock_batch is '.(GETPOST('clean_product_stock_batch', 'alpha') ? GETPOST('clean_product_stock_batch', 'alpha') : 'undefined').'
'."\n"; print 'Option clean_perm_table is '.(GETPOST('clean_perm_table', 'alpha') ? GETPOST('clean_perm_table', 'alpha') : 'undefined').'
'."\n"; +print 'Option clean_ecm_files_table is '.(GETPOST('clean_ecm_files_table', 'alpha') ? GETPOST('clean_ecm_files_table', 'alpha') : 'undefined').'
'."\n"; print 'Option repair_link_dispatch_lines_supplier_order_lines, is '.(GETPOST('repair_link_dispatch_lines_supplier_order_lines', 'alpha') ? GETPOST('repair_link_dispatch_lines_supplier_order_lines', 'alpha') : 'undefined').'
'."\n"; // Init data print 'Option set_empty_time_spent_amount is '.(GETPOST('set_empty_time_spent_amount', 'alpha') ? GETPOST('set_empty_time_spent_amount', 'alpha') : 'undefined').'
'."\n"; @@ -205,7 +206,7 @@ $conf->global->MAIN_ENABLE_LOG_TO_HTML = 1; $oneoptionset = 0; $oneoptionset = (GETPOST('standard', 'alpha') || GETPOST('restore_thirdparties_logos', 'alpha') || GETPOST('clean_linked_elements', 'alpha') || GETPOST('clean_menus', 'alpha') || GETPOST('clean_orphelin_dir', 'alpha') || GETPOST('clean_product_stock_batch', 'alpha') || GETPOST('set_empty_time_spent_amount', 'alpha') || GETPOST('rebuild_product_thumbs', 'alpha') - || GETPOST('clean_perm_table', 'alpha') + || GETPOST('clean_perm_table', 'alpha') || GETPOST('clean_ecm_files_table', 'alpha') || GETPOST('force_disable_of_modules_not_found', 'alpha') || GETPOST('force_utf8_on_tables', 'alpha') || GETPOST('force_utf8mb4_on_tables', 'alpha') || GETPOST('force_collation_from_conf_on_tables', 'alpha') || GETPOST('rebuild_sequences', 'alpha') || GETPOST('recalculateinvoicetotal', 'alpha')); @@ -1294,6 +1295,55 @@ if ($ok && GETPOST('clean_perm_table', 'alpha')) { } +// clean_old_module_entries: Clean data into const when files of module were removed without being +if ($ok && GETPOST('clean_ecm_files_table', 'alpha')) { + print '
*** Clean table ecm_files from lines of entries whose physical files does not exists anymore (emplemented for entity 1 only)'; + + $MAXTODELETE = 100; + + $sql = "SELECT rowid, filename, filepath, entity from ".MAIN_DB_PREFIX."ecm_files"; + $sql .= " WHERE entity = 1"; + $sql .= " ORDER BY rowid ASC"; + + $nbfile = 0; + $nbfiletodelete = 0; + + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + if ($num) { + $i = 0; + while ($i < $num && $nbfiletodelete < $MAXTODELETE) { + $obj = $db->fetch_object($resql); + if ($obj->rowid > 0) { + $filetocheck = DOL_DATA_ROOT.'/'.$obj->filepath.'/'.$obj->filename; + $nbfile++; + if (!dol_is_file($filetocheck)) { + $nbfiletodelete++; + print 'Found line with id '.$obj->rowid.', entity '.$obj->entity.', file "'.$filetocheck.'" to delete'; + if (GETPOST('clean_ecm_files_table', 'alpha') == 'confirmed') { + $sqldelete = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files WHERE rowid = ".((int) $obj->rowid); + $resqldelete = $db->query($sqldelete); + if (!$resqldelete) { + dol_print_error($db); + } + print ' - deleted'; + } + print ''; + } + } + $i++; + } + } + if ($nbfiletodelete > $MAXTODELETE) { + print 'There is more than '.$MAXTODELETE.' invalid entries into ecm_files index table (among '.$nbfile.' analyzed) with no valid physical files. Run the page several time to process all of them.'; + } else { + print 'Nb of entries processed into ecm_files index table: '.$nbfile.', number of invalid record: '.$nbfiletodelete.''; + } + } else { + dol_print_error($db); + } +} // force utf8 on tables if ($ok && GETPOST('force_utf8_on_tables', 'alpha')) {