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

Fix: Avoid UnknownPropertyException in validation error response #191

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
12 changes: 6 additions & 6 deletions actions/UploadAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ protected function handleFileUpload(UploadedFile $uploadedFile, $hideInStream =

$file = $folder->addUploadedFile($uploadedFile);

if($file->hasErrors()) {
if ($file->hasErrors()) {
return $this->getValidationErrorResponse($file);
}

if($file->baseFile->hasErrors()) {
if ($file->baseFile->hasErrors()) {
return $this->getErrorResponse($file->baseFile);
}

Expand All @@ -57,17 +57,17 @@ protected function handleFileUpload(UploadedFile $uploadedFile, $hideInStream =

protected function getValidationErrorResponse(FileSystemItem $file)
{
$errorMessage = Yii::t('FileModule.actions_UploadAction', 'File {fileName} could not be uploaded!', ['fileName' => $file->baseFile->name]);
$errorMessage = Yii::t('FileModule.actions_UploadAction', 'File {fileName} could not be uploaded!', ['fileName' => $file->baseFile->name ?? '']);

if(!empty($file->hasErrors())) {
if (!empty($file->hasErrors())) {
$errorMessage = $file->getErrorSummary(false);
}

return [
'error' => true,
'errors' => $errorMessage,
'name' => $file->baseFile->name,
'size' => $file->baseFile->size
'name' => $file->baseFile->name ?? '',
'size' => $file->baseFile->size ?? '',
];
}
}
8 changes: 4 additions & 4 deletions actions/UploadZipAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function handleFileUpload(UploadedFile $uploadedFile, $hideInStream =
$zip = new ZipExtractor();
$file = $zip->extract($this->controller->getCurrentFolder(), $uploadedFile);

if($file->hasErrors()) {
if ($file->hasErrors()) {
return $this->getValidationErrorResponse($file);
}

Expand All @@ -37,7 +37,7 @@ protected function handleFileUpload(UploadedFile $uploadedFile, $hideInStream =

protected function getValidationErrorResponse(FileSystemItem $file)
{
$errorMessage = Yii::t('FileModule.actions_UploadAction', 'File {fileName} could not be uploaded!', ['fileName' => $file->baseFile->name]);
$errorMessage = Yii::t('FileModule.actions_UploadAction', 'File {fileName} could not be uploaded!', ['fileName' => $file->baseFile->name ?? '']);

if (!empty($file->hasErrors())) {
$errorMessage = array_values($file->getErrors())[0];
Expand All @@ -46,8 +46,8 @@ protected function getValidationErrorResponse(FileSystemItem $file)
return [
'error' => true,
'errors' => $errorMessage,
'name' => $file->baseFile->name,
'size' => $file->baseFile->size
'name' => $file->baseFile->name ?? '',
'size' => $file->baseFile->size ?? '',
];
}
}
28 changes: 4 additions & 24 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Changelog
- Fix #184: Display only published content files in the folder "Files from the stream"
- Fix #186: Rename conflicted not published folder/file on creating/uploading
- Fix #189: Initialize module content class
- Fix #191: Avoid UnknownPropertyException in validation error response

0.16.1 - May 1, 2023
--------------------
Expand All @@ -29,26 +30,23 @@ Changelog

0.14.3 - Unreleased
--------------------
- Enh #152: Improve File listing layout
- Enh #152: Improve File listing layout

0.14.2 - December 15, 2021
--------------------------
- Fix #149: Fix error on context menu for files from stream


0.14.1 - December 7, 2021
-------------------------
- Fix #146: Update content last editor and date after save base File
- Enh #127: Improve context menu with items from wall stream entry


0.14.0 - November 26, 2021
--------------------------
- Enh #83: Enable paste/upload files from clipboard
- Enh #100: Add context menu on hover
- Enh #121: File versioning


0.13.2 - Unreleased
-----------------------
- Enh #84: Move files to different Space
Expand All @@ -59,15 +57,13 @@ Changelog
- Enh #133: Factorize duplicated code
- Enh #140: Use widget ContentVisibiltySelect


0.13.1 - July 29, 2021
-----------------------
- Enh #114: Fix for PHP8 - Deprecate required parameters after optional parameters
- Fix #117: CLI error when no REST module is installed
- Fix: Race condition on newly created files (import vs. oo)
- Enh: Updated translations


0.13.0 - April 9, 2021
----------------------
- Enh #4751: Hide separator between content links
Expand All @@ -81,98 +77,82 @@ Changelog

0.12.0 - November 4, 2020
--------------------------
- Enh #93: Wall Stream Layout Migration for HumHub 1.7+
- Enh #93: Wall Stream Layout Migration for HumHub 1.7+

0.11.20 - November 4, 2020
---------------------------
- Fix #87: ZIP Upload broken due legency ImageConverter usage
- Fix #74: Remove Temp Directory recursively in cleanup()
- Fix #74: Remove Temp Directory recursively in cleanup()
- Enh #94: Implement Download Counter

0.11.18 - December 4, 2019
---------------------------
- Fix: Social acitivites for virtual (Files from stream and root) folders


0.11.18 - December 4, 2019
---------------------------
- Fix: Social acitivites for virtual (Files from stream and root) folders


0.11.17 - June 27, 2019
---------------------------
- Enh: Updated translations
- Enh: Updated docs


0.11.16 - October 10, 2018
---------------------------
- Fix: Imported file visibility private


0.11.15 - October 2, 2018
---------------------------
- Fix: Imported file visibility private instead of public


0.11.14 - September 18, 2018
---------------------------
- Fix: getSearchAttributes() on items without editor or creator fails


0.11.13 - July 26, 2018
---------------------------
- Fix: Edit/Delete of own files without ManageFiles permission not working


0.11.12 - July 2, 2018
---------------------------
- Fix: PHP 7.2 compatibility issues


0.11.11 - April 27, 2018
---------------------------
- Fix: Profile files can't be managed


0.11.10 - April 25, 2018
---------------------------
- Fix: Yii 2.0.14 compatibility (https://github.com/yiisoft/yii2/issues/15875)


0.11.9 - December 20, 2017
---------------------------
- Enh: Updated translations


0.11.7 - December 12, 2017
---------------------------
- Enh: Added FolderView sort
- Enh: Default sorting configuration
- Enh: Remember user sort settings


0.11.6 - October 27, 2017
---------------------------
- Enh: Added upload behaviour settings (Index/Replace) in module config


0.11.5 - October 22, 2017
---------------------------
- Fix: Temporary files deletion on ZIP creation


0.11.4 - October 13, 2017
---------------------------
- Fix: Missing WallEntry layout for search results
- Enh: Updated translations


0.11.3 - September 22, 2017
---------------------------
- Fix: Fixed mixed permissions check


0.11.0 - September 4, 2017
---------------------------
- Enh: Editable folder/file visibility
Expand Down