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

Add force_disable_of_modules_not_found to clean database and removed

false warning when modules files were removed with disabling it before
parent 474a2692
Branches
No related tags found
No related merge requests found
...@@ -66,8 +66,6 @@ if (! is_object($conf)) dolibarr_install_syslog("repair: conf file not initializ ...@@ -66,8 +66,6 @@ if (! is_object($conf)) dolibarr_install_syslog("repair: conf file not initializ
pHeader('',"upgrade2",GETPOST('action','aZ09')); pHeader('',"upgrade2",GETPOST('action','aZ09'));
$actiondone=0;
// Action to launch the repair script // Action to launch the repair script
$actiondone=1; $actiondone=1;
...@@ -79,6 +77,7 @@ print 'Option clean_orphelin_dir (0 or \'test\' or \'confirmed\') is '.(GETPOST( ...@@ -79,6 +77,7 @@ print 'Option clean_orphelin_dir (0 or \'test\' or \'confirmed\') is '.(GETPOST(
print 'Option clean_product_stock_batch (0 or \'test\' or \'confirmed\') is '.(GETPOST('clean_product_stock_batch','alpha')?GETPOST('clean_product_stock_batch','alpha'):'0').'<br>'."\n"; print 'Option clean_product_stock_batch (0 or \'test\' or \'confirmed\') is '.(GETPOST('clean_product_stock_batch','alpha')?GETPOST('clean_product_stock_batch','alpha'):'0').'<br>'."\n";
print 'Option set_empty_time_spent_amount (0 or \'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount','alpha')?GETPOST('set_empty_time_spent_amount','alpha'):'0').'<br>'."\n"; print 'Option set_empty_time_spent_amount (0 or \'test\' or \'confirmed\') is '.(GETPOST('set_empty_time_spent_amount','alpha')?GETPOST('set_empty_time_spent_amount','alpha'):'0').'<br>'."\n";
print 'Option rebuild_product_thumbs (0 or \'test\' or \'confirmed\') is '.(GETPOST('rebuild_product_thumbs','alpha')?GETPOST('rebuild_product_thumbs','alpha'):'0').'<br>'."\n"; print 'Option rebuild_product_thumbs (0 or \'test\' or \'confirmed\') is '.(GETPOST('rebuild_product_thumbs','alpha')?GETPOST('rebuild_product_thumbs','alpha'):'0').'<br>'."\n";
print 'Option force_disable_of_modules_not_found (0 or \'test\' or \'confirmed\') is '.(GETPOST('force_disable_of_modules_not_found','alpha')?GETPOST('force_disable_of_modules_not_found','alpha'):'0').'<br>'."\n";
print '<br>'; print '<br>';
print '<table cellspacing="0" cellpadding="1" border="0" width="100%">'; print '<table cellspacing="0" cellpadding="1" border="0" width="100%">';
...@@ -316,6 +315,7 @@ if ($ok) ...@@ -316,6 +315,7 @@ if ($ok)
/* From here, actions need a parameter */ /* From here, actions need a parameter */
...@@ -795,6 +795,99 @@ if ($ok && GETPOST('set_empty_time_spent_amount','alpha')) ...@@ -795,6 +795,99 @@ if ($ok && GETPOST('set_empty_time_spent_amount','alpha'))
} }
// clean_old_module_entries: Clean data into const when files of module were removed without being
// clean_linked_elements: Check and clean linked elements
if ($ok && GETPOST('force_disable_of_modules_not_found','alpha'))
{
print '<tr><td colspan="2"><br>*** Force modules not found to be disabled</td></tr>';
$sql ="SELECT DISTINCT name";
$sql.=" FROM ".MAIN_DB_PREFIX."const as c";
$sql.=" WHERE name LIKE 'MAIN_MODULE_%_HOOKS'";
$sql.=" ORDER BY name";
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
$i = 0;
while ($i < $num)
{
$obj=$db->fetch_object($resql);
$majname = $obj->name;
print '<tr><td>';
print $majname;
$db->begin();
if (preg_match('/MAIN_MODULE_(.*)_HOOKS/i', $majname, $reg))
{
$name=strtolower($reg[1]);
if ($name)
{
$reloffile=$name.'/class/actions_'.$name.'.class.php';
$result = dol_include_once($reloffile);
if (! $result)
{
print ' - File of hooks ('.$reloffile.') NOT found, we disable the module.';
if (GETPOST('force_disable_of_modules_not_found') == 'confirmed')
{
$sql2 ="DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."_HOOKS'";
$resql2=$db->query($sql2);
if (! $resql2)
{
$error++;
dol_print_error($db);
}
$sql2 ="DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'MAIN_MODULE_".strtoupper($name)."'";
$resql2=$db->query($sql2);
if (! $resql2)
{
$error++;
dol_print_error($db);
}
else
print " - Cleaned";
}
else
{
print ' - Canceled (test mode)';
}
}
else
{
print ' - File of hooks ('.$reloffile.') found, we do nothing.';
}
}
if (!$error) $db->commit();
else $db->rollback();
}
print'</td></tr>';
if ($error) break;
$i++;
}
}
else
{
print '<tr><td>No active module with missing files found</td></tr>';
}
}
else
{
dol_print_error($db);
}
}
print '</table>'; print '</table>';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment