本文整理汇总了PHP中UpgradeHistory::save方法的典型用法代码示例。如果您正苦于以下问题:PHP UpgradeHistory::save方法的具体用法?PHP UpgradeHistory::save怎么用?PHP UpgradeHistory::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UpgradeHistory
的用法示例。
在下文中一共展示了UpgradeHistory::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
// if error was encountered, script should have died before now
$new_upgrade = new UpgradeHistory();
$new_upgrade->filename = $this->context['zip'];
if (!empty($this->context['zip_as_dir'])) {
$new_upgrade->md5sum = trim(file_get_contents($this->context['zip'] . DIRECTORY_SEPARATOR . 'md5sum'));
} else {
if (file_exists($this->context['zip'])) {
$new_upgrade->md5sum = md5_file($this->context['zip']);
} else {
// if file is not there, just md5 the filename
$new_upgrade->md5sum = md5($this->context['zip']);
}
}
$dup = $this->db->getOne("SELECT id FROM upgrade_history WHERE md5sum='{$new_upgrade->md5sum}'");
if ($dup) {
$this->error("Duplicate install for package, md5: {$new_upgrade->md5sum}");
// Not failing it - by now there's no point, we're at the end anyway
return;
}
$new_upgrade->name = pathinfo($this->context['zip'], PATHINFO_FILENAME);
$new_upgrade->description = $this->manifest['description'];
$new_upgrade->type = 'patch';
$new_upgrade->version = $this->to_version;
$new_upgrade->status = "installed";
$new_upgrade->manifest = base64_encode(serialize($this->manifest));
$new_upgrade->save();
}
示例2: UpgradeHistory
// if error was encountered, script should have died before now
$new_upgrade = new UpgradeHistory();
$new_upgrade->filename = $install_file;
$new_upgrade->md5sum = md5_file($install_file);
$new_upgrade->name = $zip_from_dir;
$new_upgrade->description = $manifest['description'];
$new_upgrade->type = 'patch';
$new_upgrade->version = $sugar_version;
$new_upgrade->status = "installed";
$new_upgrade->manifest = !empty($_SESSION['install_manifest']) ? $_SESSION['install_manifest'] : '';
if ($new_upgrade->description == null) {
$new_upgrade->description = "Silent Upgrade was used to upgrade the instance";
} else {
$new_upgrade->description = $new_upgrade->description . " Silent Upgrade was used to upgrade the instance.";
}
$new_upgrade->save();
set_upgrade_progress('commit', 'in_progress', 'upgradeHistory', 'done');
set_upgrade_progress('commit', 'done', 'commit', 'done');
}
}
//Clean modules from cache
$cachedir = sugar_cached('smarty');
if (is_dir($cachedir)) {
$allModFiles = array();
$allModFiles = findAllFiles($cachedir, $allModFiles);
foreach ($allModFiles as $file) {
//$file_md5_ref = str_replace(clean_path(getcwd()),'',$file);
if (file_exists($file)) {
unlink($file);
}
}
示例3: updateUpgradeHistory
/**
* creates UpgradeHistory entries
* @param mode string Install or Uninstall
*/
function updateUpgradeHistory()
{
if (isset($_SESSION['INSTALLED_LANG_PACKS']) && count($_SESSION['INSTALLED_LANG_PACKS']) > 0) {
foreach ($_SESSION['INSTALLED_LANG_PACKS'] as $k => $zipFile) {
$new_upgrade = new UpgradeHistory();
$new_upgrade->filename = $zipFile;
$new_upgrade->md5sum = md5_file($zipFile);
$new_upgrade->type = 'langpack';
$new_upgrade->version = $_SESSION['INSTALLED_LANG_PACKS_VERSION'][$k];
$new_upgrade->status = "installed";
$new_upgrade->manifest = $_SESSION['INSTALLED_LANG_PACKS_MANIFEST'][$k];
$new_upgrade->save();
}
}
}
示例4: performInstall
function performInstall($file, $silent = true)
{
global $sugar_config;
global $mod_strings;
global $current_language;
$base_upgrade_dir = sugar_cached("/upgrades");
$base_tmp_upgrade_dir = "{$base_upgrade_dir}/temp";
if (!file_exists($base_tmp_upgrade_dir)) {
mkdir_recursive($base_tmp_upgrade_dir, true);
}
$GLOBALS['log']->debug("INSTALLING: " . $file);
$mi = new ModuleInstaller();
$mi->silent = $silent;
$mod_strings = return_module_language($current_language, "Administration");
$GLOBALS['log']->debug("ABOUT TO INSTALL: " . $file);
if (preg_match("#.*\\.zip\$#", $file)) {
$GLOBALS['log']->debug("1: " . $file);
// handle manifest.php
$target_manifest = remove_file_extension($file) . '-manifest.php';
include $target_manifest;
$GLOBALS['log']->debug("2: " . $file);
$unzip_dir = mk_temp_dir($base_tmp_upgrade_dir);
unzip($file, $unzip_dir);
$GLOBALS['log']->debug("3: " . $unzip_dir);
$id_name = $installdefs['id'];
$version = $manifest['version'];
$uh = new UpgradeHistory();
$previous_install = array();
if (!empty($id_name) & !empty($version)) {
$previous_install = $uh->determineIfUpgrade($id_name, $version);
}
$previous_version = empty($previous_install['version']) ? '' : $previous_install['version'];
$previous_id = empty($previous_install['id']) ? '' : $previous_install['id'];
if (!empty($previous_version)) {
$mi->install($unzip_dir, true, $previous_version);
} else {
$mi->install($unzip_dir);
}
$GLOBALS['log']->debug("INSTALLED: " . $file);
$new_upgrade = new UpgradeHistory();
$new_upgrade->filename = $file;
$new_upgrade->md5sum = md5_file($file);
$new_upgrade->type = $manifest['type'];
$new_upgrade->version = $manifest['version'];
$new_upgrade->status = "installed";
//$new_upgrade->author = $manifest['author'];
$new_upgrade->name = $manifest['name'];
$new_upgrade->description = $manifest['description'];
$new_upgrade->id_name = $id_name;
$serial_manifest = array();
$serial_manifest['manifest'] = isset($manifest) ? $manifest : '';
$serial_manifest['installdefs'] = isset($installdefs) ? $installdefs : '';
$serial_manifest['upgrade_manifest'] = isset($upgrade_manifest) ? $upgrade_manifest : '';
$new_upgrade->manifest = base64_encode(serialize($serial_manifest));
//$new_upgrade->unique_key = (isset($manifest['unique_key'])) ? $manifest['unique_key'] : '';
$new_upgrade->save();
//unlink($file);
}
//fi
}
示例5: get_required_upgrades
function get_required_upgrades($soapclient, $session)
{
global $sugar_config, $sugar_version;
require_once 'vendor/nusoap//nusoap.php';
$errors = array();
$upgrade_history = new UpgradeHistory();
$upgrade_history->disable_row_level_security = true;
$installeds = $upgrade_history->getAllOrderBy('date_entered ASC');
$history = array();
require_once 'soap/SoapError.php';
$error = new SoapError();
foreach ($installeds as $installed) {
$history[] = array('id' => $installed->id, 'filename' => $installed->filename, 'md5' => $installed->md5sum, 'type' => $installed->type, 'status' => $installed->status, 'version' => $installed->version, 'date_entered' => $installed->date_entered, 'error' => $error->get_soap_array());
}
$result = $soapclient->call('get_required_upgrades', array('session' => $session, 'client_upgrade_history' => $history, 'client_version' => $sugar_version));
$tempdir_parent = create_cache_directory("disc_client");
$temp_dir = tempnam($tempdir_parent, "sug");
sugar_mkdir($temp_dir, 0775);
$upgrade_installed = false;
if (empty($soapclient->error_str) && $result['error']['number'] == 0) {
foreach ($result['upgrade_history_list'] as $upgrade) {
$file_result = $soapclient->call('get_encoded_file', array('session' => $session, 'filename' => $upgrade['filename']));
if (empty($soapclient->error_str) && $result['error']['number'] == 0) {
if ($file_result['md5'] == $upgrade['md5']) {
$newfile = write_encoded_file($file_result, $temp_dir);
unzip($newfile, $temp_dir);
global $unzip_dir;
$unzip_dir = $temp_dir;
if (file_exists("{$temp_dir}/manifest.php")) {
require_once "{$temp_dir}/manifest.php";
global $manifest_arr;
$manifest_arr = $manifest;
if (!isset($manifest['offline_client_applicable']) || $manifest['offline_client_applicable'] == true || $manifest['offline_client_applicable'] == 'true') {
if (file_exists("{$temp_dir}/scripts/pre_install.php")) {
require_once "{$temp_dir}/scripts/pre_install.php";
pre_install();
}
if (isset($manifest['copy_files']['from_dir']) && $manifest['copy_files']['from_dir'] != "") {
$zip_from_dir = $manifest['copy_files']['from_dir'];
}
$source = "{$temp_dir}/{$zip_from_dir}";
$dest = getcwd();
copy_recursive($source, $dest);
if (file_exists("{$temp_dir}/scripts/post_install.php")) {
require_once "{$temp_dir}/scripts/post_install.php";
post_install();
}
//save newly installed upgrade
$new_upgrade = new UpgradeHistory();
$new_upgrade->filename = $upgrade['filename'];
$new_upgrade->md5sum = $upgrade['md5'];
$new_upgrade->type = $upgrade['type'];
$new_upgrade->version = $upgrade['version'];
$new_upgrade->status = "installed";
$new_upgrade->save();
$upgrade_installed = true;
}
}
}
}
}
}
return $upgrade_installed;
}