} } else { echo "*******************************************************************************\n"; echo "*** ERROR: 4th parameter must be a valid admin user.\n"; echo $usage; echo "FAILURE\n"; exit(1); } /////retrieve admin user global $sugar_config; $configOptions = $sugar_config['dbconfig']; /////////////////////////////////////////////////////////////////////////////// //// UPGRADE PREP prepSystemForUpgradeSilent(); //repair tabledictionary.ext.php file if needed repairTableDictionaryExtFile(); $unzip_dir = sugar_cached("upgrades/temp"); $install_file = $sugar_config['upload_dir'] . "/upgrades/patch/" . basename($argv[1]); $_SESSION['unzip_dir'] = $unzip_dir; $_SESSION['install_file'] = $install_file; $_SESSION['zip_from_dir'] = $zip_from_dir; if (is_dir($unzip_dir . '/scripts')) { rmdir_recursive($unzip_dir . '/scripts'); } if (is_file($unzip_dir . '/manifest.php')) { rmdir_recursive($unzip_dir . '/manifest.php'); } mkdir_recursive($unzip_dir); if (!is_dir($unzip_dir)) { echo "\n{$unzip_dir} is not an available directory\nFAILURE\n"; fwrite(STDERR, "\n{$unzip_dir} is not an available directory\nFAILURE\n");
function testRepairTableDictionaryExtFile() { require_once 'ModuleInstall/ModuleInstaller.php'; repairTableDictionaryExtFile(); if (function_exists('sugar_fopen')) { $fp = @sugar_fopen($this->tableDictionaryExtFile1, 'r'); } else { $fp = fopen($this->tableDictionaryExtFile1, 'r'); } $matches = 0; if ($fp) { while ($line = fgets($fp)) { if (preg_match('/\\s*include\\s*\\(\\s*[\'|\\"](.*?)[\'\\"]\\s*\\)\\s*;/', $line, $match)) { $matches++; $this->assertTrue(file_exists($match[1]), 'Assert that entry for file ' . $line . ' exists'); } } fclose($fp); } $this->assertEquals($matches, 1, 'Assert that there was one match for correct entries in file ' . $this->tableDictionaryExtFile1); if (function_exists('sugar_fopen')) { $fp = @sugar_fopen($this->tableDictionaryExtFile2, 'r'); } else { $fp = fopen($this->tableDictionaryExtFile2, 'r'); } $matches = 0; if ($fp) { while ($line = fgets($fp)) { if (preg_match('/\\s*include\\s*\\(\\s*[\'|\\"](.*?)[\'\\"]\\s*\\)\\s*;/', $line, $match)) { $matches++; $this->assertTrue(file_exists($match[1]), 'Assert that entry for file ' . $line . ' exists'); } } fclose($fp); } $this->assertEquals($matches, 1, 'Assert that there was one match for correct entries in file ' . $this->tableDictionaryExtFile2); if (function_exists('sugar_fopen')) { $fp = @sugar_fopen($this->corruptExtModuleFile, 'r'); } else { $fp = fopen($this->corruptExtModuleFile, 'r'); } $matches = 0; if ($fp) { while ($line = fgets($fp)) { if (preg_match('/\\s*include\\s*\\(\\s*[\'|\\"](.*?)[\'\\"]\\s*\\)\\s*;/', $line, $match)) { $matches++; $this->assertTrue(file_exists($match[1]), 'Assert that entry for file ' . $line . ' exists'); } } fclose($fp); } $this->assertEquals($matches, 0, 'Assert that there was one match for correct entries in file ' . $this->corruptExtModuleFile); }