From f66ac935c8b72d22255a42aeeac80d0eb839e65c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 24 Jan 2018 20:00:27 +0100 Subject: [PATCH] Fix migration for files from modules --- htdocs/install/upgrade.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index d6460672e41..fce91f7925d 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -356,16 +356,22 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 } else { + $listoffileprocessed=array(); // Protection to avoid to process twice the same file + // Loop on each migrate files foreach($filelist as $file) { + if (in_array($dir.$file, $listoffileprocessed)) continue; + print '
'; print ''.$langs->trans("ChoosedMigrateScript").''.$file.''."\n"; // Run sql script $ok=run_sql($dir.$file, 0, '', 1); + $listoffileprocessed[$dir.$file]=$dir.$file; - // Scan if there is migration scripts for modules htdocs/module/sql or htdocs/custom/module/sql + // Scan if there is migration scripts that depends of Dolibarr version + // for modules htdocs/module/sql or htdocs/custom/module/sql (files called "dolibarr_x.y.z-a.b.c.sql") $modulesfile = array(); foreach ($conf->file->dol_document_root as $type => $dirroot) { @@ -377,9 +383,9 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 if (! preg_match('/\./',$filemodule) && is_dir($dirroot.'/'.$filemodule.'/sql')) // We exclude filemodule that contains . (are not directories) and are not directories. { //print "Scan for ".$dirroot . '/' . $filemodule . '/sql/'.$file; - if (is_file($dirroot . '/' . $filemodule . '/sql/'.$file)) + if (is_file($dirroot . '/' . $filemodule . '/sql/dolibarr_'.$file)) { - $modulesfile[$dirroot . '/' . $filemodule . '/sql/'.$file] = '/' . $filemodule . '/sql/'.$file; + $modulesfile[$dirroot . '/' . $filemodule . '/sql/dolibarr_'.$file] = '/' . $filemodule . '/sql/dolibarr_'.$file; } } } @@ -389,13 +395,15 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09 foreach ($modulesfile as $modulefilelong => $modulefileshort) { + if (in_array($modulefilelong, $listoffileprocessed)) continue; + print '
'; print ''.$langs->trans("ChoosedMigrateScript").' (external modules)'.$modulefileshort.''."\n"; // Run sql script $okmodule=run_sql($modulefilelong, 0, '', 1); // Note: Result of migration of external module should not decide if we continue migration of Dolibarr or not. + $listoffileprocessed[$modulefilelong]=$modulefilelong; } - } } } @@ -415,7 +423,9 @@ if (! $ok && isset($argv[1])) $ret=1; dol_syslog("Exit ".$ret); dolibarr_install_syslog("--- upgrade: end ".((! $ok && empty($_GET["ignoreerrors"])) || $dirmodule)); -pFooter(((! $ok && empty($_GET["ignoreerrors"])) || $dirmodule)?2:0,$setuplang); +$nonext = (! $ok && empty($_GET["ignoreerrors"]))?2:0; +if ($dirmodule) $nonext=1; +pFooter($nonext,$setuplang); if ($db->connected) $db->close();