Skip to content
Snippets Groups Projects
Commit 616f8dda authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

New: Add a repair function to restore data into ecm_directories table

that was not sanitized.
parent fad501d7
No related branches found
No related tags found
No related merge requests found
......@@ -109,4 +109,38 @@ function checkLinkedElements($sourcetype, $targettype)
return $out;
}
/**
* Clean data into ecm_directories table
*
* @return void
*/
function clean_data_ecm_directories()
{
global $db, $langs;
// Clean data from ecm_directories
$sql="SELECT rowid, label FROM ".MAIN_DB_PREFIX."ecm_directories";
$resql=$db->query($sql);
if ($resql)
{
while($obj=$db->fetch_object($resql))
{
$id=$obj->rowid;
$label=$obj->label;
$newlabel=dol_sanitizeFileName($label);
if ($label != $newlabel)
{
$sqlupdate="UPDATE ".MAIN_DB_PREFIX."ecm_directories set label='".$newlabel."' WHERE rowid=".$id;
print '<tr><td>'.$sqlupdate."</td></tr>\n";
$resqlupdate=$db->query($sqlupdate);
if (! $resqlupdate) dol_print_error($db,'Failed to update');
}
}
}
else dol_print_error($db,'Failed to run request');
return;
}
?>
......@@ -181,7 +181,7 @@ if ($ok)
foreach($filelist as $file)
{
print '<tr><td nowrap>';
print $langs->trans("ChoosedMigrateScript").'</td><td align="right">'.$file.'</td></tr>';
print $langs->trans("Script").'</td><td align="right">'.$file.'</td></tr>';
$name = substr($file, 0, dol_strlen($file) - 4);
......@@ -262,6 +262,10 @@ foreach($listofmodulesextra as $tablename => $elementtype)
}
// Clean data into ecm_directories table
clean_data_ecm_directories();
// Check and clean linked elements
if (GETPOST('clean_linked_elements'))
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment