query($stmt,true,'Executing repair query: '); } } echo "

{$mod_strings['LBL_REPAIR_DATABASE_SYNCED']}

"; } } else { if (!$export && empty ($_REQUEST['repair_silent'])) { if ( empty($hideModuleMenu) ) echo getClassicModuleTitle($mod_strings['LBL_REPAIR_DATABASE'], array($mod_strings['LBL_REPAIR_DATABASE']), true); echo "

{$mod_strings['LBL_REPAIR_DATABASE_PROCESSING']}

"; ob_flush(); } $sql = ''; VardefManager::clearVardef(); $repairedTables = array(); foreach ($beanFiles as $bean => $file) { if(file_exists($file)){ require_once ($file); unset($GLOBALS['dictionary'][$bean]); $focus = new $bean (); if (($focus instanceOf SugarBean) && !isset($repairedTables[$focus->table_name])) { $sql .= $db->repairTable($focus, $execute); $repairedTables[$focus->table_name] = true; } //Repair Custom Fields if (($focus instanceOf SugarBean) && $focus->hasCustomFields() && !isset($repairedTables[$focus->table_name . '_cstm'])) { $df = new DynamicField($focus->module_dir); //Need to check if the method exists as during upgrade an old version of Dynamic Fields may be loaded. if (method_exists($df, "repairCustomFields")) { $df->bean = $focus; $sql .= $df->repairCustomFields($execute); $repairedTables[$focus->table_name . '_cstm'] = true; } } } } $olddictionary = $dictionary; unset ($dictionary); include ('modules/TableDictionary.php'); foreach ($dictionary as $meta) { if ( !isset($meta['table']) || isset($repairedTables[$meta['table']])) continue; $tablename = $meta['table']; $fielddefs = $meta['fields']; $indices = $meta['indices']; $engine = isset($meta['engine'])?$meta['engine']:null; $sql .= $db->repairTableParams($tablename, $fielddefs, $indices, $execute, $engine); $repairedTables[$tablename] = true; } $dictionary = $olddictionary; if (empty ($_REQUEST['repair_silent'])) { echo ""; if (isset ($sql) && !empty ($sql)) { $qry_str = ""; foreach (explode("\n", $sql) as $line) { if (!empty ($line) && substr($line, -2) != "*/") { $line .= ";"; } $qry_str .= $line . "\n"; } $ss = new Sugar_Smarty(); $ss->assign('MOD', $GLOBALS['mod_strings']); $ss->assign('qry_str', $qry_str); echo $ss->fetch('modules/Administration/templates/RepairDatabase.tpl'); } else { echo "

{$mod_strings['LBL_REPAIR_DATABASE_SYNCED']}

"; } } } } else { sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); }