From c78f7fda683caa195961bb0cfde7bfec1fce4914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Sat, 2 Apr 2022 21:27:31 +0800 Subject: [PATCH] Fix pgsql reset id error (#1369) --- var/Widget/Backup.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/var/Widget/Backup.php b/var/Widget/Backup.php index b7179537..33dc1c21 100644 --- a/var/Widget/Backup.php +++ b/var/Widget/Backup.php @@ -189,7 +189,12 @@ class Backup extends BaseOptions implements ActionInterface if (!empty($_FILES)) { $file = array_pop($_FILES); - if (0 == $file['error'] && is_uploaded_file($file['tmp_name'])) { + if(UPLOAD_ERR_NO_FILE == $file['error']) { + Notice::alloc()->set(_t('没有选择任何备份文件'), 'error'); + $this->response->goBack(); + } + + if (UPLOAD_ERR_OK == $file['error'] && is_uploaded_file($file['tmp_name'])) { $path = $file['tmp_name']; } else { Notice::alloc()->set(_t('备份文件上传失败'), 'error'); @@ -270,7 +275,7 @@ class Backup extends BaseOptions implements ActionInterface } // 针对PGSQL重置计数 - if (false !== strpos($this->db->getVersion(), 'pgsql')) { + if (false !== strpos(strtolower($this->db->getAdapterName()), 'pgsql')) { foreach ($this->lastIds as $table => $id) { $seq = $this->db->getPrefix() . $table . '_seq'; $this->db->query('ALTER SEQUENCE ' . $seq . ' RESTART WITH ' . ($id + 1));