Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ファイルアップロードの失敗時にエラー内容自体を表示しないように修正 #5566

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/Eccube/Controller/Admin/Content/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
$this->errors[] = ['message' => $e->getMessage()];
log_error($e->getMessage());
$this->errors[] = ['message' => trans('admin.content.file.upload_error', [
'%file_name%' => $filename,
])];
}
}

Expand Down Expand Up @@ -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,
'%error%' => $e->getMessage(),
])];
} catch (UnsupportedMediaTypeHttpException $e) {
$this->errors[] = ['message' => $e->getMessage()];
}
}
if ($successCount > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Resource/locale/messages.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Resource/locale/messages.ja.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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% は既に使用されています。別のフォルダ名を入力してください'
Expand Down