-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix UploadedFile::move() $this->hasMoved value #5290
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 UploadedFile::move() $this->hasMoved value #5290
Conversation
It seems even if
|
@diegoscoponi Thank you for PR! We ask that contributions have code commits signed. See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md#signing |
Coding style checking failed. Could you fix the style? |
PHPUnit testing failed. https://github.com/codeigniter4/CodeIgniter4/runs/4128729664?check_suite_focus=true
Could you fix the broken test? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the failed checks in GitHub Actions, please.
If you have any questions, feel free to ask.
I might be mistaken, but if |
@sfadschm it looks like that is true some of the time, but |
Thanks, I did not grasp that. Does 'fail silently' mean that the method simy returns false? If so, we would maybe like to throw the same exception for that case as in the |
Yes. |
@diegoscoponi You don't use Please fix two checking failed. See And see #5290 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix the above.
@@ -141,7 +141,7 @@ public function move(string $targetPath, ?string $name = null, bool $overwrite = | |||
$destination = $overwrite ? $targetPath . $name : $this->getDestination($targetPath . $name); | |||
|
|||
try { | |||
move_uploaded_file($this->path, $destination); | |||
$this->hasMoved = move_uploaded_file($this->path, $destination); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When move_uploaded_file()
returns false
, the current code returns false
after all.
But we need to throw HTTPException::forMoveFailed()
as the same as move_uploaded_file()
raise warning
to have consistent output in case of failure.
Please change the code like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diegoscoponi I added a comment.
And you have a merge commit in this PR.
Please rebase your branch like the following:
$ git fetch upstream
$ git checkout UploadedFileHasMoved
$ git rebase upstream/develop
$ git push --force-with-lease origin UploadedFileHasMoved
Thank you!
The
move
method always assigns atrue
value to the$this->hasMoved
attribute regardless of whethermove_uploaded_file
has failed, this means that calling$file->hasMoved()
always returnstrue
.I'm right?
Thanks!!!