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 beforeMarshall if file uploads are array #588

Merged
merged 2 commits into from
Oct 18, 2022

Conversation

albertcansado
Copy link
Contributor

Fix error "Call to a member function getError() on array" when uploaded file is an array.

@codecov
Copy link

codecov bot commented Sep 6, 2022

Codecov Report

Merging #588 (f412266) into master (878cba2) will decrease coverage by 0.17%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master     #588      +/-   ##
============================================
- Coverage     95.68%   95.50%   -0.18%     
- Complexity      108      109       +1     
============================================
  Files            11       11              
  Lines           278      267      -11     
============================================
- Hits            266      255      -11     
  Misses           12       12              
Impacted Files Coverage Δ
src/Model/Behavior/UploadBehavior.php 94.56% <100.00%> (-0.18%) ⬇️
src/File/Writer/DefaultWriter.php 100.00% <0.00%> (ø)
src/File/Path/DefaultProcessor.php 100.00% <0.00%> (ø)
src/File/Path/Basepath/DefaultTrait.php 100.00% <0.00%> (ø)
src/File/Transformer/DefaultTransformer.php 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@davidyell
Copy link
Member

A few small bits to tidy up.

@albertcansado
Copy link
Contributor Author

Done!

@davidyell
Copy link
Member

You have some build failures still to address, looking at the pipeline

Comment on lines +804 to +814
return array_map(
fn(UploadedFileInterface $file) => [
'tmp_name' => '',
'error' => $file->getError(),
'name' => $file->getClientFilename(),
'type' => $file->getClientMediaType(),
'size' => $file->getSize(),
],
$data
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parse error: syntax error, unexpected '$file' (T_VARIABLE), expecting ',' or ')' in /home/runner/work/cakephp-upload/cakephp-upload/tests/TestCase/Model/Behavior/UploadBehaviorTest.php on line 805

To fix the above error:

Suggested change
return array_map(
fn(UploadedFileInterface $file) => [
'tmp_name' => '',
'error' => $file->getError(),
'name' => $file->getClientFilename(),
'type' => $file->getClientMediaType(),
'size' => $file->getSize(),
],
$data
);
}
return array_map(
function (UploadedFileInterface $file) {
return [
'tmp_name' => '',
'error' => $file->getError(),
'name' => $file->getClientFilename(),
'type' => $file->getClientMediaType(),
'size' => $file->getSize(),
];
},
$data
);
}

@ravage84
Copy link
Contributor

ravage84 commented Oct 3, 2022

@albertcansado the code needs to have PHP 7.2 compat as it needs to keep CakePHP 4.x before 4.4 compatibility.

"cakephp/cakephp": "^4.0.2",

@TerryKern's changes take care of that.

@ADmad ADmad merged commit f412266 into FriendsOfCake:master Oct 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants