-
Notifications
You must be signed in to change notification settings - Fork 123
Fixing deprecated error when uploading file attachments in PHP 5.5+ #86
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
Conversation
src/Jira/Api/Client/CurlClient.php
Outdated
| if ($method == 'POST') { | ||
| curl_setopt($curl, CURLOPT_POST, 1); | ||
| if ($isFile) { | ||
| $data['file'] = $this->getCurlValue($data['file']); |
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.
Wrong indentation.
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.
Woops, I'll fix it
src/Jira/Api/Client/CurlClient.php
Outdated
| protected function getCurlValue($fileString) | ||
| { | ||
| $theCurlValue = $fileString; | ||
| $regex = "|^@(.*);filename=(.*)$|"; |
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.
Is this regex for checking if given value isn't already in correct format that is created by curl_file_create function?
|
Ok, removed all the unneeded stuff. Is this more like it? |
src/Jira/Api/Client/CurlClient.php
Outdated
| if (!function_exists('curl_file_create')) { | ||
| return $fileString; | ||
| } else { | ||
| return curl_file_create(substr($fileString, 1)); |
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.
Just return it, no else needed.
Almost. |
|
In which PHP version |
|
Here is the RFC: https://wiki.php.net/rfc/curl-file-upload they say
and
But I don't think an actual decision is made to remove this capability yet. |
|
So without your change on PHP 5.6 file upload won't work at all, right? |
|
On PHP 5.6 you can still enable the old behaviour with a |
You can enable it, but it's turned off by default and it means that uploads through this JIRA API client won't work anymore unless I merge your fix. |
|
Well actually it's currently already enabled by default - see https://github.com/chobie/jira-api-restclient/blob/master/src/Jira/Api/Client/CurlClient.php#L83 : As I said, my PR was just to get rid of the ugly deprecated notice. And also to be future proof once this option goes away in the future. |
|
Then maybe setting |
|
I would think so, but honestly I haven't investigated if that could cause adverse effects. |
|
OK. Then could you please squash and I'll merge it in. |
|
Unless I did something wrong, I believe I've squashed everything already? |
|
Merging. Thanks @DerMika . |
|
You're welcome, thanks for indulging me :) |
Same pull request as done on jpastoor/jira-api-restclient:
On PHP 5.5 +, you get an
E_DEPRECATEDwhen trying to upload files. This PR fixes that by using a\CURLFileobject to upload (see https://wiki.php.net/rfc/curl-file-upload)