Merge branch release/21.7.7 of zentao/zentaopms (#12411)
This commit is contained in:
@@ -151,7 +151,8 @@ class upgrade extends control
|
||||
|
||||
/* 手动删除无法自动删除的文件。*/
|
||||
/* Remove files that can not be deleted automatically. */
|
||||
$result = $this->upgrade->deleteFiles();
|
||||
$script = $this->app->getTmpRoot() . 'deleteFiles.sh';
|
||||
$result = $this->upgrade->deleteFiles($script);
|
||||
if($result)
|
||||
{
|
||||
$this->view->result = 'fail';
|
||||
@@ -159,6 +160,10 @@ class upgrade extends control
|
||||
|
||||
return $this->display();
|
||||
}
|
||||
elseif(is_file($script))
|
||||
{
|
||||
unlink($script);
|
||||
}
|
||||
|
||||
$rawFromVersion = isset($_POST['fromVersion']) ? $this->post->fromVersion : $fromVersion;
|
||||
if(strpos($fromVersion, 'lite') !== false) $rawFromVersion = $this->config->upgrade->liteVersion[$fromVersion];
|
||||
|
||||
@@ -7,6 +7,18 @@ window.submitConfirm = function(event)
|
||||
updateProgress();
|
||||
}
|
||||
|
||||
window.copyCommand = function()
|
||||
{
|
||||
const command = $('#command').text();
|
||||
navigator.clipboard.writeText(command).then(function()
|
||||
{
|
||||
zui.Messager.show({type: 'success', message: copySuccess, timeout: 1000});
|
||||
}, function()
|
||||
{
|
||||
zui.Messager.show({type: 'danger', message: copyFail, timeout: 1000});
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
if(typeof result != 'undefined' && result == 'duckdbFail')
|
||||
|
||||
@@ -59,6 +59,9 @@ $lang->upgrade->setStatusFile = '<h4>Please complete the following actions<
|
||||
<p><strong style="color:red">I have read and done as instructed above. <a href="upgrade.php">Continue upgrading.</a></strong></p>';
|
||||
|
||||
$lang->upgrade->selectVersion = 'Version';
|
||||
$lang->upgrade->copyCommand = 'Copy';
|
||||
$lang->upgrade->copySuccess = 'Copied to clipboard';
|
||||
$lang->upgrade->copyFail = 'Copy failed, please copy it manually.';
|
||||
$lang->upgrade->continue = 'Continue';
|
||||
$lang->upgrade->noteVersion = "Select the compatible version, or it might cause data loss.";
|
||||
$lang->upgrade->fromVersion = 'From';
|
||||
@@ -70,8 +73,8 @@ $lang->upgrade->forbiddenExt = 'The extension is incompatible with the version.
|
||||
$lang->upgrade->updateFile = 'File information has to be updated.';
|
||||
$lang->upgrade->showSQLLog = 'Your database is inconsistent with the standard and try fix it.';
|
||||
$lang->upgrade->noticeErrSQL = 'Your database is inconsistent with the standard and it failed to fix it. Please run the following SQL and refresh.';
|
||||
$lang->upgrade->afterDeleted = 'Please execute commands to delete the files. Please refresh after you delete them.';
|
||||
$lang->upgrade->afterExec = 'Please modify the database manually according to the above error information, and refresh after the modification!';
|
||||
$lang->upgrade->afterDeleted = 'Please execute the above command on the server to delete the file, and then refresh the page.';
|
||||
$lang->upgrade->afterExec = 'Please manually modify the database based on the above error message, and then refresh the page.';
|
||||
$lang->upgrade->afterDuckdb = 'Please wait for Duckdb engine to install.';
|
||||
$lang->upgrade->mergeProgram = 'Data Merge';
|
||||
$lang->upgrade->mergeTips = 'Data Migration Tips';
|
||||
|
||||
@@ -59,6 +59,9 @@ $lang->upgrade->setStatusFile = '<h4>升级之前请先完成下面的操
|
||||
<p><strong style="color:red">我已经仔细阅读上面提示且完成上述工作,<a href="#" onclick="location.reload()">继续更新</a></strong></p>';
|
||||
|
||||
$lang->upgrade->selectVersion = '选择版本';
|
||||
$lang->upgrade->copyCommand = '复制命令';
|
||||
$lang->upgrade->copySuccess = '复制成功';
|
||||
$lang->upgrade->copyFail = '复制失败,请手动复制';
|
||||
$lang->upgrade->continue = '继续';
|
||||
$lang->upgrade->noteVersion = "务必选择正确的版本,否则会造成数据丢失。";
|
||||
$lang->upgrade->fromVersion = '原来的版本';
|
||||
@@ -70,8 +73,8 @@ $lang->upgrade->forbiddenExt = '以下插件与新版本不兼容,已经自
|
||||
$lang->upgrade->updateFile = '需要更新附件信息。';
|
||||
$lang->upgrade->showSQLLog = '检查到你的数据库跟标准不一致,正在尝试修复。以下是修复SQL语句。';
|
||||
$lang->upgrade->noticeErrSQL = '检查到你的数据库跟标准不一致,尝试修复失败。请手动执行以下SQL语句,再刷新页面检查。';
|
||||
$lang->upgrade->afterDeleted = '请执行上面命令删除文件, 删除后刷新!';
|
||||
$lang->upgrade->afterExec = '请根据以上报错信息手动修改数据库,修改后刷新!';
|
||||
$lang->upgrade->afterDeleted = '请在服务器上执行上面命令删除文件,删除后刷新页面。';
|
||||
$lang->upgrade->afterExec = '请根据以上报错信息手动修改数据库,修改后刷新页面。';
|
||||
$lang->upgrade->afterDuckdb = '请等待安装Duckdb引擎。';
|
||||
$lang->upgrade->mergeProgram = '数据迁移';
|
||||
$lang->upgrade->mergeTips = '数据迁移提示';
|
||||
|
||||
@@ -657,10 +657,11 @@ class upgradeModel extends model
|
||||
* 删除无用的文件。
|
||||
* Delete Useless Files.
|
||||
*
|
||||
* @param string $script
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function deleteFiles(): array
|
||||
public function deleteFiles(string $script): array
|
||||
{
|
||||
$result = array();
|
||||
$zfile = $this->app->loadClass('zfile');
|
||||
@@ -681,7 +682,7 @@ class upgradeModel extends model
|
||||
if(!is_writable($fullPath) || ($isDir && !$zfile->removeDir($fullPath)) ||
|
||||
(!$isDir && !$zfile->removeFile($fullPath)))
|
||||
{
|
||||
$result[] = 'rm -f ' . ($isDir ? '-r ' : '') . $fullPath;
|
||||
$result[] = 'rm -fr ' . $fullPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -696,11 +697,19 @@ class upgradeModel extends model
|
||||
if(!is_writable($patchPath) || ($isDir && !$zfile->removeDir($patchPath)) ||
|
||||
(!$isDir && !$zfile->removeDir($patchPath)))
|
||||
{
|
||||
$result[] = 'rm -f ' . ($isDir ? '-r ' : '') . $patchPath;
|
||||
$result[] = 'rm -fr ' . $patchPath;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
if(empty($result)) return $result;
|
||||
|
||||
asort($result);
|
||||
|
||||
$content = "#!/bin/bash\n";
|
||||
foreach($result as $cmd) $content .= "$cmd\n";
|
||||
file_put_contents($script, $content);
|
||||
|
||||
return ["/bin/bash $script"];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,9 @@ namespace zin;
|
||||
set::zui(true);
|
||||
|
||||
jsVar('result', $result);
|
||||
jsVar('copySuccess', $lang->upgrade->copySuccess);
|
||||
jsVar('copyFail', $lang->upgrade->copyFail);
|
||||
|
||||
div
|
||||
(
|
||||
setID('main'),
|
||||
@@ -40,6 +43,7 @@ div
|
||||
h::textarea
|
||||
(
|
||||
setClass('form-control w-full'),
|
||||
set::id('command'),
|
||||
set::name('errors'),
|
||||
set::rows(10),
|
||||
set::readonly('readonly'),
|
||||
@@ -50,19 +54,35 @@ div
|
||||
(
|
||||
on::click('button[type=submit]', "submitConfirm"),
|
||||
on::click('button[type=button]', "loadCurrentPage"),
|
||||
on::click('#copyBtn', "copyCommand"),
|
||||
set::target('_self'),
|
||||
set::actions(false),
|
||||
formHidden('fromVersion', $fromVersion),
|
||||
div
|
||||
(
|
||||
setClass('mt-4'),
|
||||
$result == 'sqlFail' ? $lang->upgrade->afterExec : null,
|
||||
$result == 'fail' ? $lang->upgrade->afterDeleted : null,
|
||||
btn
|
||||
div
|
||||
(
|
||||
setID('refreshBtn'),
|
||||
set::btnType($this->app->rawMethod == 'execute' ? 'submit' : 'button'),
|
||||
$lang->refresh
|
||||
setClass('text-important'),
|
||||
$result == 'sqlFail' ? $lang->upgrade->afterExec : null,
|
||||
$result == 'fail' ? $lang->upgrade->afterDeleted : null,
|
||||
),
|
||||
div
|
||||
(
|
||||
setClass('text-center'),
|
||||
$result == 'fail' ? a
|
||||
(
|
||||
setID('copyBtn'),
|
||||
setClass('btn wide important mr-2'),
|
||||
$lang->upgrade->copyCommand
|
||||
) : null,
|
||||
btn
|
||||
(
|
||||
setID('refreshBtn'),
|
||||
setClass('btn-wide primary'),
|
||||
set::btnType($this->app->rawMethod == 'execute' ? 'submit' : 'button'),
|
||||
$lang->refresh
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user