-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/core#1565 Throwing an API_Exception if uploaded file fails to move with APIv3 #16444
Conversation
Can one of the admins verify this patch? |
(Standard links)
|
I have only made changes to api/v3/Attachment.php. I'm not sure where the test file conflict has come from but I assume it can be resolved easily. |
@albionbrown it looks like the code is applied to the wrong branch or something - maybe checkout a clean copy of master & cherry-pick your patch on & force-push? |
I'll try again today. Shall we close this PR? |
It looks like your master branch has gotten messed up because you committed df77575 and then did Also it appears you created this PR from To reboot the whole shebang, you can do:
It will give you a link to opening a new PR. Note, if it tries to create another merge commit during step 3, cancel it and do step 2 again. Reset as far back as you need to so it will pull cleanly without prompting you to create a merge commit. Change step 2 to |
Thanks for having a look @colemanw. Out of curiosity, is it preferable to create a new fork when going to create a new PR or can I just use the same one I forked last time but just need to update it? |
Ok I think I'm going to have to delete my repo and fork again because I realised what I've done now. |
Created new PR #16465 |
@albionbrown I've created thousands of PRs and only ever had one fork :) |
Overview
When creating an attachment using APIv3, the
civicrm_api3_attachment_create
function copies the file to the custom file upload directory. However, there is no error checking currently.Before
The file would attempt to be copied and the original removed.
copy($moveFile, $path); unlink($moveFile);
If the directory is non-writable, the file would be lost.
After
if (!copy($moveFile, $path)) { throw new API_Exception("Cannot copy uploaded file ".$moveFile." to ".$path); } unlink($moveFile);
Now, an API_Exception is thrown before the file is removed.