Skip to content

Commit

Permalink
Merge pull request #5566 from takeuji/file-uploader-message-fix
Browse files Browse the repository at this point in the history
ファイルアップロードの失敗時にエラー内容自体を表示しないように修正
  • Loading branch information
chihiro-adachi authored Aug 24, 2022
2 parents 1e118a1 + 5a6b62b commit 1a1d4f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
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 @@ -305,15 +312,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 @@ -983,7 +983,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 @@ -983,7 +983,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

0 comments on commit 1a1d4f7

Please sign in to comment.