rename($custom_file, "{$backup_dir}/{$custom_file}"); } if ($moved) { echo "*** {$moved} customized files were moved aside, please check them in {$backup_dir}. Please see {$logpath} for more details."; } // reenable Shadow ini_set('shadow.enabled', 1); ////////////////COMMIT PROCESS BEGINS/////////////////////////////////////////////////////////////// $trackerManager = TrackerManager::getInstance(); $trackerManager->pause(); $trackerManager->unsetMonitors(); //Clean smarty from cache @deleteCache(); upgrade_check_errors($errors); // Run SQL upgrades runSqlFiles($origVersion, $destVersion); // Set new version writeLog('Updating database version...'); $db->query("DELETE FROM config WHERE category = 'info' AND name = 'sugar_version'"); $db->query("INSERT INTO config (category, name, value) VALUES ('info', 'sugar_version', '{$sugar_version}')"); writeLog('Database version updated'); /////////////////////////////////////////////////////////////////////////////// //// HANDLE DATABASE writeLog('About to repair DB tables.'); //Use Repair and rebuild to update the database. repairTables(); writeLog('DB tables repaired'); /////////////////////////////////////////////////////////////////////////////// //// HANDLE PREINSTALL SCRIPTS writeLog('Starting pre_install()...'); // postinstall script
$fielddefs = $meta['fields']; $indices = $meta['indices']; $sql = $db->repairTableParams($tablename, $fielddefs, $indices, true); if (!empty($sql)) { logThis($sql, $path); $repairedTables[$tablename] = true; } } logThis('database repaired', $path); logThis('Start rebuild relationships.', $path); @rebuildRelations(); logThis('End rebuild relationships.', $path); // Bug 61826 - We need to run these SQL files after the tables are first created. if (version_compare(getSilentUpgradeVar('origVersion'), '6.7.0', '<')) { require_once clean_path($unzip_dir . '/scripts/post_install.php'); runSqlFiles(getSilentUpgradeVar('origVersion'), getSilentUpgradeVar('destVersion'), 'sql_query'); } // End Bug 61826 ///////////////////////////////// //Make sure to call preInstall on database instance to setup additional tables for hierarchies if needed if ($db->supports('recursive_query')) { $db->preInstall(); } require_once 'modules/Administration/Administration.php'; $admin = new Administration(); $admin->saveSetting('system', 'adminwizard', 1); include "{$unzip_dir}/manifest.php"; $ce_to_pro_ent = isset($manifest['name']) && preg_match('/^SugarCE.*?(Pro|Ent|Corp|Ult)$/', $manifest['name']); $sugar_version = getSilentUpgradeVar('origVersion'); if (!$sugar_version) { global $silent_upgrade_vars_loaded; logThis("Error retrieving silent upgrade var for origVersion: cache dir is {$GLOBALS['sugar_config']['cache_dir']} -- full cache for \$silent_upgrade_vars_loaded is " . var_export($silent_upgrade_vars_loaded, true), $path);
function post_install() { global $unzip_dir; global $sugar_config; global $sugar_version; global $path; global $_SESSION; if (!isset($_SESSION['sqlSkippedQueries'])) { $_SESSION['sqlSkippedQueries'] = array(); } initialize_session_vars(); if (!isset($unzip_dir) || $unzip_dir == null) { $unzip_dir = $_SESSION['unzip_dir']; } _logThis('Entered post_install function.', $path); $self_dir = "{$unzip_dir}/scripts"; /////////////////////////////////////////////////////////////////////////// //// PUT DATABASE UPGRADE SCRIPT HANDLING HERE $new_sugar_version = getUpgradeVersion(); $post_action = status_post_install_action('sql_query'); if ($post_action != null) { if ($post_action != 'done') { //continue from where left in previous run runSqlFiles($sugar_version, $new_sugar_version, 'sql_query', $post_action); $currProg['sql_query'] = 'done'; post_install_progress($currProg, 'set'); } } else { //never ran before runSqlFiles($sugar_version, $new_sugar_version, 'sql_query'); $currProg['sql_query'] = 'done'; post_install_progress($currProg, 'set'); } genericFunctions(); upgradeDbAndFileVersion($new_sugar_version); //Remove jssource/src_files sub-directories if they still exist $jssource_dirs = array('jssource/src_files/include/javascript/ext-2.0', 'jssource/src_files/include/javascript/ext-1.1.1', 'jssource/src_files/include/javascript/yui'); foreach ($jssource_dirs as $js_dir) { if (file_exists($js_dir)) { _logThis("Remove {$js_dir} directory"); rmdir_recursive($js_dir); _logThis("Finished removing {$js_dir} directory"); } } }