NEW Suggest a way to run upgrade per entities.
This commit is contained in:
parent
e9d7e216e2
commit
86a8ae8c3d
@ -39,7 +39,7 @@ Following changes may create regressions for some external modules, but were nec
|
|||||||
* Move massaction 'confirm_createbills' from actions_massactions.inc.php to commande/list.php
|
* Move massaction 'confirm_createbills' from actions_massactions.inc.php to commande/list.php
|
||||||
* Method fetch_all_resources(), fetch_all_used(), fetch_all_available() of DolResource has been removed (they were not used by core code).
|
* Method fetch_all_resources(), fetch_all_used(), fetch_all_available() of DolResource has been removed (they were not used by core code).
|
||||||
* Method fetch_all of DolResource has been renamed into fetchAll() to match naming conventions.
|
* Method fetch_all of DolResource has been renamed into fetchAll() to match naming conventions.
|
||||||
|
* The hook 'upgrade' and 'doUpgrade2" has been renamed 'doUpgradeBefore' and 'doUpgradeAfterDB'. A new trigger 'doUpgradeAfterFiles' has been introduced.
|
||||||
|
|
||||||
***** ChangeLog for 15.0.1 compared to 15.0.0 *****
|
***** ChangeLog for 15.0.1 compared to 15.0.0 *****
|
||||||
FIX: #19777 #20281
|
FIX: #19777 #20281
|
||||||
|
|||||||
@ -167,20 +167,17 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
|
|||||||
}
|
}
|
||||||
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
|
$conf->db->dolibarr_main_db_cryptkey = $dolibarr_main_db_cryptkey;
|
||||||
|
|
||||||
// Chargement config
|
|
||||||
if (!$error) {
|
$listofentities = array(1);
|
||||||
$conf->setValues($db);
|
|
||||||
// Reset forced setup after the setValues
|
|
||||||
if (defined('SYSLOG_FILE')) {
|
|
||||||
$conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
|
|
||||||
}
|
|
||||||
$conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the global $hookmanager object
|
// Create the global $hookmanager object
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
|
||||||
$hookmanager = new HookManager($db);
|
$hookmanager = new HookManager($db);
|
||||||
$hookmanager->initHooks(array('upgrade'));
|
$reshook = $hookmanager->initHooks(array('doUpgradeBefore'));
|
||||||
|
if ($reshook >= 0 && is_array($hookmanager->resArray)) {
|
||||||
|
// Example: $hookmanager->resArray = array(2, 3, 10);
|
||||||
|
$listofentities = array_unique(array_merge($listofentities, $hookmanager->resArray));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************************
|
/***************************************************************************************
|
||||||
@ -188,20 +185,6 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
|
|||||||
* Migration of data
|
* Migration of data
|
||||||
*
|
*
|
||||||
***************************************************************************************/
|
***************************************************************************************/
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
if (!$error) {
|
|
||||||
// Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
|
|
||||||
// Version to install is DOL_VERSION
|
|
||||||
$dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : ''));
|
|
||||||
|
|
||||||
// Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec
|
|
||||||
// dans la 1ere colonne, la description de l'action a faire
|
|
||||||
// dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error'
|
|
||||||
|
|
||||||
$versiontoarray = explode('.', $versionto);
|
|
||||||
$versionranarray = explode('.', DOL_VERSION);
|
|
||||||
|
|
||||||
|
|
||||||
// Force to execute this at begin to avoid the new core code into Dolibarr to be broken.
|
// Force to execute this at begin to avoid the new core code into Dolibarr to be broken.
|
||||||
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN birth date';
|
$sql = 'ALTER TABLE '.MAIN_DB_PREFIX.'user ADD COLUMN birth date';
|
||||||
@ -228,6 +211,34 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
|
|||||||
$db->query($sql, 1);
|
$db->query($sql, 1);
|
||||||
|
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
foreach ($listofentities as $entity) {
|
||||||
|
// Set $conf context for entity
|
||||||
|
$conf->setEntityValues($db, $entity);
|
||||||
|
// Reset forced setup after the setValues
|
||||||
|
if (defined('SYSLOG_FILE')) {
|
||||||
|
$conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
|
||||||
|
}
|
||||||
|
$conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
if (count($listofentities) > 1) {
|
||||||
|
print '<tr><td colspan="4">*** '.$langs->trans("Entity").' '.$entity.'</td></tr>'."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Current version is $conf->global->MAIN_VERSION_LAST_UPGRADE
|
||||||
|
// Version to install is DOL_VERSION
|
||||||
|
$dolibarrlastupgradeversionarray = preg_split('/[\.-]/', isset($conf->global->MAIN_VERSION_LAST_UPGRADE) ? $conf->global->MAIN_VERSION_LAST_UPGRADE : (isset($conf->global->MAIN_VERSION_LAST_INSTALL) ? $conf->global->MAIN_VERSION_LAST_INSTALL : ''));
|
||||||
|
|
||||||
|
// Chaque action de migration doit renvoyer une ligne sur 4 colonnes avec
|
||||||
|
// dans la 1ere colonne, la description de l'action a faire
|
||||||
|
// dans la 4eme colonne, le texte 'OK' si fait ou 'AlreadyDone' si rien n'est fait ou 'Error'
|
||||||
|
|
||||||
|
$versiontoarray = explode('.', $versionto);
|
||||||
|
$versionranarray = explode('.', DOL_VERSION);
|
||||||
|
|
||||||
|
|
||||||
$afterversionarray = explode('.', '2.0.0');
|
$afterversionarray = explode('.', '2.0.0');
|
||||||
$beforeversionarray = explode('.', '2.7.9');
|
$beforeversionarray = explode('.', '2.7.9');
|
||||||
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
|
if (versioncompare($versiontoarray, $afterversionarray) >= 0 && versioncompare($versiontoarray, $beforeversionarray) <= 0) {
|
||||||
@ -535,12 +546,12 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Can call a dedicated external upgrade process
|
// Can call a dedicated external upgrade process with hook doUpgradeAfterDB()
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$parameters = array('versionfrom' => $versionfrom, 'versionto' => $versionto);
|
$parameters = array('versionfrom' => $versionfrom, 'versionto' => $versionto, 'conf'=>$conf);
|
||||||
$object = new stdClass();
|
$object = new stdClass();
|
||||||
$action = "upgrade";
|
$action = "upgrade";
|
||||||
$reshook = $hookmanager->executeHooks('doUpgrade2', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doUpgradeAfterDB', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
if ($hookmanager->resNbOfHooks > 0) {
|
if ($hookmanager->resNbOfHooks > 0) {
|
||||||
if ($reshook < 0) {
|
if ($reshook < 0) {
|
||||||
print '<tr><td colspan="4">';
|
print '<tr><td colspan="4">';
|
||||||
@ -550,7 +561,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
} else {
|
} else {
|
||||||
print '<tr class="trforrunsql"><td colspan="4">';
|
print '<tr class="trforrunsql"><td colspan="4">';
|
||||||
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: <span class="ok">OK</span>';
|
print '<b>'.$langs->trans('UpgradeExternalModule').' (DB)</b>: <span class="ok">OK</span>';
|
||||||
print "<!-- (".$reshook.") -->";
|
print "<!-- (".$reshook.") -->";
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
@ -558,15 +569,15 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
|
|||||||
//if (! empty($conf->modules))
|
//if (! empty($conf->modules))
|
||||||
if (!empty($conf->modules_parts['hooks'])) { // If there is at least one module with one hook, we show message to say nothing was done
|
if (!empty($conf->modules_parts['hooks'])) { // If there is at least one module with one hook, we show message to say nothing was done
|
||||||
print '<tr class="trforrunsql"><td colspan="4">';
|
print '<tr class="trforrunsql"><td colspan="4">';
|
||||||
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: '.$langs->trans("None");
|
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: '.$langs->trans("NodoUpgradeAfterDB");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
// Set constant to ask to remake a new ping to inform about upgrade (if first ping was done and OK)
|
// Set constant to ask to remake a new ping to inform about upgrade (if first ping was done and OK)
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'";
|
$sql = 'UPDATE '.MAIN_DB_PREFIX."const SET VALUE = 'torefresh' WHERE name = 'MAIN_FIRST_PING_OK_ID'";
|
||||||
@ -576,7 +587,22 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
|
|||||||
// We always commit.
|
// We always commit.
|
||||||
// Process is designed so we can run it several times whatever is situation.
|
// Process is designed so we can run it several times whatever is situation.
|
||||||
$db->commit();
|
$db->commit();
|
||||||
$db->close();
|
|
||||||
|
|
||||||
|
/***************************************************************************************
|
||||||
|
*
|
||||||
|
* Migration of files
|
||||||
|
*
|
||||||
|
***************************************************************************************/
|
||||||
|
|
||||||
|
foreach ($listofentities as $entity) {
|
||||||
|
// Set $conf context for entity
|
||||||
|
$conf->setEntityValues($db, $entity);
|
||||||
|
// Reset forced setup after the setValues
|
||||||
|
if (defined('SYSLOG_FILE')) {
|
||||||
|
$conf->global->SYSLOG_FILE = constant('SYSLOG_FILE');
|
||||||
|
}
|
||||||
|
$conf->global->MAIN_ENABLE_LOG_TO_HTML = 1;
|
||||||
|
|
||||||
|
|
||||||
// Copy directory medias
|
// Copy directory medias
|
||||||
@ -593,6 +619,36 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ
|
|||||||
// Actions for all versions (no database change but rename some directories)
|
// Actions for all versions (no database change but rename some directories)
|
||||||
migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits');
|
migrate_rename_directories($db, $langs, $conf, '/banque/bordereau', '/bank/checkdeposits');
|
||||||
|
|
||||||
|
|
||||||
|
$parameters = array('versionfrom' => $versionfrom, 'versionto' => $versionto, 'conf'=>$conf);
|
||||||
|
$object = new stdClass();
|
||||||
|
$action = "upgrade";
|
||||||
|
$reshook = $hookmanager->executeHooks('doUpgradeAfterFiles', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
|
if ($hookmanager->resNbOfHooks > 0) {
|
||||||
|
if ($reshook < 0) {
|
||||||
|
print '<tr><td colspan="4">';
|
||||||
|
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: ';
|
||||||
|
print $hookmanager->error;
|
||||||
|
print "<!-- (".$reshook.") -->";
|
||||||
|
print '</td></tr>';
|
||||||
|
} else {
|
||||||
|
print '<tr class="trforrunsql"><td colspan="4">';
|
||||||
|
print '<b>'.$langs->trans('UpgradeExternalModule').' (Files)</b>: <span class="ok">OK</span>';
|
||||||
|
print "<!-- (".$reshook.") -->";
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//if (! empty($conf->modules))
|
||||||
|
if (!empty($conf->modules_parts['hooks'])) { // If there is at least one module with one hook, we show message to say nothing was done
|
||||||
|
print '<tr class="trforrunsql"><td colspan="4">';
|
||||||
|
print '<b>'.$langs->trans('UpgradeExternalModule').'</b>: '.$langs->trans("NodoUpgradeAfterFiles");
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
$silent = 0;
|
$silent = 0;
|
||||||
if (!$silent) {
|
if (!$silent) {
|
||||||
print '<table width="100%">';
|
print '<table width="100%">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user