public function testCheckForExistingSQL() { $patchToCheck = new stdClass(); $patchToCheck->name = 'abc'; $patchToCheck->id = ''; $GLOBALS['db']->query("INSERT INTO upgrade_history (id, name, md5sum, date_entered) VALUES\n('444','abc','444','2008-12-20 08:08:20') "); $GLOBALS['db']->query("INSERT INTO upgrade_history (id, name, md5sum, date_entered) VALUES\n('555','abc','555','2008-12-20 08:08:20')"); $uh = new UpgradeHistory(); $return = $uh->checkForExisting($patchToCheck); $this->assertContains($return->id, array('444', '555')); $patchToCheck->id = '555'; $return = $uh->checkForExisting($patchToCheck); $this->assertEquals($return->id, '444'); $GLOBALS['db']->query("delete from upgrade_history where id='444'"); $GLOBALS['db']->query("delete from upgrade_history where id='555'"); }
public function run() { require_once 'ModuleInstall/PackageManager/PackageManager.php'; $pm = new PackageManager(); $packages = $pm->getinstalledPackages(array('module')); foreach ($packages as $pack) { if (strpos($pack['name'], 'SugarCRM Upgrader') !== false) { $uh = new UpgradeHistory(); $uh->name = $pack['name']; $history = $uh->checkForExisting($uh); $this->filesToRemove[] = "custom/Extension/application/Ext/Include/{$history->id_name}.php"; $history->delete(); $this->fileToDelete($this->filesToRemove); $this->log("Useless files of {$pack['name']} v{$pack['version']} removed"); } } foreach ($pm->getPackagesInStaging() as $pack) { if (strpos($pack['name'], 'SugarCRM Upgrader') !== false) { $file = UploadStream::getFSPath(hashToFile($pack['file'])); $this->fileToDelete($file); foreach (array('manifest', 'icon') as $meta) { $this->fileToDelete(pathinfo($file, PATHINFO_DIRNAME) . '/' . pathinfo($file, PATHINFO_FILENAME) . "-{$meta}.php"); } } } }
function performUninstall($name) { $uh = new UpgradeHistory(); $uh->name = $name; $uh->id_name = $name; $found = $uh->checkForExisting($uh); if ($found != null) { global $sugar_config; global $mod_strings; global $current_language; $base_upgrade_dir = sugar_cached("/upgrades"); $base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp"; if (!isset($GLOBALS['mi_remove_tables'])) { $GLOBALS['mi_remove_tables'] = true; } $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir); unzip($found->filename, $unzip_dir); $mi = new ModuleInstaller(); $mi->silent = true; $mi->uninstall("{$unzip_dir}"); $found->delete(); unlink(remove_file_extension($found->filename) . '-manifest.php'); unlink($found->filename); } }
function performUninstall($name) { $uh = new UpgradeHistory(); $uh->name = $name; $uh->id_name = $name; $found = $uh->checkForExisting($uh); if ($found != null) { global $sugar_config; global $mod_strings; global $current_language; $base_upgrade_dir = $this->upload_dir . '/upgrades'; $base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp"; if (is_file($found->filename)) { if (!isset($GLOBALS['mi_remove_tables'])) { $GLOBALS['mi_remove_tables'] = true; } $unzip_dir = mk_temp_dir($base_tmp_upgrade_dir); unzip($found->filename, $unzip_dir); $mi = new ModuleInstaller(); $mi->silent = true; $mi->uninstall("{$unzip_dir}"); $found->delete(); unlink(remove_file_extension($found->filename) . '-manifest.php'); unlink($found->filename); } else { //file(s_ have been deleted or are not found in the directory, allow database delete to happen but no need to change filesystem $found->delete(); } } }