From 8c313f90c8ba86f293a902cde18690c140547eba Mon Sep 17 00:00:00 2001 From: takeuji <8424850+takeuji@users.noreply.github.com> Date: Thu, 18 Aug 2022 14:09:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89=E3=81=AE?= =?UTF-8?q?=E5=A4=B1=E6=95=97=E6=99=82=E3=81=AB=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E8=87=AA=E4=BD=93=E3=82=92=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Controller/Admin/Content/FileController.php | 6 +++--- src/Eccube/Resource/locale/messages.en.yaml | 2 +- src/Eccube/Resource/locale/messages.ja.yaml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Eccube/Controller/Admin/Content/FileController.php b/src/Eccube/Controller/Admin/Content/FileController.php index 14be60141d4..8f369d3082f 100644 --- a/src/Eccube/Controller/Admin/Content/FileController.php +++ b/src/Eccube/Controller/Admin/Content/FileController.php @@ -190,7 +190,7 @@ public function create(Request $request) $this->addSuccess('admin.common.create_complete', 'admin'); } catch (IOException $e) { - $this->errors[] = ['message' => $e->getMessage()]; + log_error($e->getMessage()); } } @@ -306,10 +306,10 @@ public function upload(Request $request) } catch (FileException $e) { $this->errors[] = ['message' => trans('admin.content.file.upload_error', [ '%file_name%' => $filename, - '%error%' => $e->getMessage(), ])]; + log_error($e->getMessage()); } catch (UnsupportedMediaTypeHttpException $e) { - $this->errors[] = ['message' => $e->getMessage()]; + log_error($e->getMessage()); } } if ($successCount > 0) { diff --git a/src/Eccube/Resource/locale/messages.en.yaml b/src/Eccube/Resource/locale/messages.en.yaml index 98b74726816..0368c568629 100644 --- a/src/Eccube/Resource/locale/messages.en.yaml +++ b/src/Eccube/Resource/locale/messages.en.yaml @@ -982,7 +982,7 @@ admin.content.file.file_list__card_title: Files in This Directory admin.content.file.updated: Update admin.content.file.directory_tree: Directories admin.content.file.upload_complete: '%success% file upload completed. (%success%/%count%)' -admin.content.file.upload_error: 'Failed to upload %file_name%. (%error%)' +admin.content.file.upload_error: 'Failed to upload %file_name%. ' admin.content.file.folder_name_symbol_error: The folder name contains invalid characters. admin.content.file.folder_name_period_error: Folder names beginning with a period(.) are not allowed. admin.content.file.dir_exists: '%file_name% is already exists.' diff --git a/src/Eccube/Resource/locale/messages.ja.yaml b/src/Eccube/Resource/locale/messages.ja.yaml index 88d96f2e33c..f5185014938 100644 --- a/src/Eccube/Resource/locale/messages.ja.yaml +++ b/src/Eccube/Resource/locale/messages.ja.yaml @@ -982,7 +982,7 @@ admin.content.file.file_list__card_title: このフォルダ内のファイル admin.content.file.updated: 更新 admin.content.file.directory_tree: フォルダ構成 admin.content.file.upload_complete: '%success%件のファイルをアップロードしました。(%success%/%count%)' -admin.content.file.upload_error: '%file_name% のアップロードに失敗しました。(%error%)' +admin.content.file.upload_error: '%file_name% のアップロードに失敗しました。' admin.content.file.folder_name_symbol_error: 使用できない文字が含まれています。 admin.content.file.folder_name_period_error: ピリオド(.)で始まる名前は使用できません。 admin.content.file.dir_exists: '%file_name% は既に使用されています。別のフォルダ名を入力してください' From 5a6b62be34b091056336248d803db025cf9e5ee3 Mon Sep 17 00:00:00 2001 From: takeuji <8424850+takeuji@users.noreply.github.com> Date: Sun, 21 Aug 2022 22:14:57 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=AE=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=81=AE=E3=81=BF=E3=82=92=E7=94=BB=E9=9D=A2=E3=81=AB?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Content/FileController.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Eccube/Controller/Admin/Content/FileController.php b/src/Eccube/Controller/Admin/Content/FileController.php index 8f369d3082f..6a8f77a10d6 100644 --- a/src/Eccube/Controller/Admin/Content/FileController.php +++ b/src/Eccube/Controller/Admin/Content/FileController.php @@ -186,11 +186,18 @@ public function create(Request $request) if (file_exists($newFilePath)) { throw new IOException(trans('admin.content.file.dir_exists', ['%file_name%' => $filename])); } + } catch (IOException $e) { + $this->errors[] = ['message' => $e->getMessage()]; + return; + } + try { $fs->mkdir($newFilePath); - $this->addSuccess('admin.common.create_complete', 'admin'); } catch (IOException $e) { log_error($e->getMessage()); + $this->errors[] = ['message' => trans('admin.content.file.upload_error', [ + '%file_name%' => $filename, + ])]; } } @@ -301,15 +308,18 @@ public function upload(Request $request) if (strpos($filename, '.') === 0) { throw new UnsupportedMediaTypeHttpException(trans('admin.content.file.dotfile_error')); } + } catch (UnsupportedMediaTypeHttpException $e) { + $this->errors[] = ['message' => $e->getMessage()]; + continue; + } + try { $file->move($nowDir, $filename); $successCount++; } catch (FileException $e) { + log_error($e->getMessage()); $this->errors[] = ['message' => trans('admin.content.file.upload_error', [ '%file_name%' => $filename, ])]; - log_error($e->getMessage()); - } catch (UnsupportedMediaTypeHttpException $e) { - log_error($e->getMessage()); } } if ($successCount > 0) {