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

Bug in setOption method #30

Closed
bogdaniy opened this issue Apr 11, 2016 · 4 comments
Closed

Bug in setOption method #30

bogdaniy opened this issue Apr 11, 2016 · 4 comments
Assignees
Labels

Comments

@bogdaniy
Copy link

When I set some curl params using setOption method and call reset method, some params(set by me) doesn't reloads, because setOption method has not strict check (in_array https://secure.php.net/manual/ru/function.in-array.php#106319) and it goes to defaultParams . Good idea is to make more strict check with in_array strict param or replace it with isset function.

@linslin
Copy link
Owner

linslin commented Apr 11, 2016

Hey @bogdaniy,

thanks for your response. I understand, Could you add some codes? Expecially your custom option set by setOption($key, $value). Thanks

@linslin linslin self-assigned this Apr 11, 2016
@bogdaniy
Copy link
Author

Code

$curl = new Curl();
var_dump($curl->getOption(CURLOPT_CUSTOMREQUEST));
$curl->setOption(CURLOPT_CUSTOMREQUEST, 'POST');
$curl->reset();
var_dump($curl->getOption(CURLOPT_CUSTOMREQUEST));

Result
bool(false) string(4) "POST"

@vasadibt
Copy link

I think the problem is in 'vendor/linslin/yii2-curl/Curl.php' on line 154

Original code:
if (in_array($key, $this->_defaultOptions) && $key !== CURLOPT_WRITEFUNCTION) {

My temporary solution:
if (array_key_exists($key, $this->_defaultOptions) && $key !== CURLOPT_WRITEFUNCTION) {

@linslin linslin added bug and removed enhancement labels Apr 19, 2016
linslin added a commit that referenced this issue Apr 20, 2016
@linslin
Copy link
Owner

linslin commented Apr 20, 2016

Thanks m8s

@linslin linslin closed this as completed Apr 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants