-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Update CURLRequest.php #2049
Update CURLRequest.php #2049
Conversation
aa362d0 prvious fix caused eception if debug has not been specified Type: ErrorException Message: curl_setopt_array(): supplied argument is not a valid File-Handle resource Filename: /home/-exchange/site/system/HTTP/CURLRequest.php
@lonnieezell : I think test "testDebugOption" is written wrongly. " CURLOPT_STDERR | An alternative location to output errors to instead of STDERR. IMHO CURLOPT_STDERR should be set to file handle or should not exists. |
@lonnieezell could you answer pls? Am I wrong or not my approach is correct? |
$curl_options[CURLOPT_VERBOSE] = 1; | ||
$curl_options[CURLOPT_STDERR] = fopen('php://output', 'w+'); | ||
} | ||
else if(is_resource($config['debug'])) |
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.
I'm confused. When is $config['debug']
going to be a resource? According to the docs it should only ever be a boolean. If true, it turns on verbose and sets the error output, otherwise it leaves verbose to whatever it was otherwise set at.
While it may crash if debug hasn't been specified, what you're changing it to doesn't work. See my comment for explanation. |
According to docs CURLOPT_STDERR should be a resource or should not be specified.
This line in old code:
```
$curl_options[CURLOPT_STDERR] = $config['debug'] === true ? fopen('php://output', 'w+') : $config['debug'];
```
caused an exception if someone tried to (if I remember correctly) set false there.
…---
CURLOPT_STDERR | An alternative location to output errors to instead of STDERR.
-- | --
Contrary to the documentation, CURLOPT_STDERR should be set to a handle to the file you want to write to, not the file's location.
|
I'm encountering this on a fresh install. Even without doing any configuration:
I get an exception:
I'll dig into it a bit. |
Okay a couple issues going on here. First issue, the class starts with some default values for
This means that in
Because of this if no overriding value was passed for Second issue, if
Consulting the CI4 User Manual on CURLRequest:
So @lonnieezell we need to decide if we still want to pass in file paths, and if so we need to make a resource from them, so then need to decide if we're going to check the path or just let that be an exception from somewhere else ( I can make a new PR but this needs a little scrutiny first. |
NOTE: These should fail until codeigniter4#2049 is resolved.
@MGatner yes, you're right. My apologies to @nowackipawel We should allow a file name to be specified - so convert it to a resource behind the scenes I guess. I don't think it needs to check the path. If it doesn't exist it should create it. If it does exist, and is writable, then it would get overwritten. If it can't be written to (or outside safe_mode boundaries) then it should naturally throw an exception. I would think that exception would be clear enough about what happened and why. |
aa362d0
prvious fix caused eception if debug has not been specified
Type: ErrorException
Message: curl_setopt_array(): supplied argument is not a valid File-Handle resource
Filename: /home/-exchange/site/system/HTTP/CURLRequest.php