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

CURLRequest - supplied argument is not a valid File-Handle resource #Windows x64 #2202

Closed
jbotka opened this issue Sep 9, 2019 · 17 comments
Closed
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@jbotka
Copy link
Contributor

jbotka commented Sep 9, 2019

Describe the bug
Using CURLReqguest class produce error:
CRITICAL - 2019-09-09 21:04:32 --> curl_setopt_array(): supplied argument is not a valid File-Handle resource

CodeIgniter 4 version
CI4 - RC1

Affected module(s)
CURLRequest

Expected behaviour, and steps to reproduce if appropriate
Any attempt where is not set debug option will produce this error since Class initialize $config['debug'] = false and later check if via isset() and not via standard condition (true/false) directly from the option so every time this will pass, and it will pass empty option to CURL options that will produce error.

Context

  • OS: Windows 8.1
  • Web server Apache
  • PHP version 7.3.8
@MGatner
Copy link
Member

MGatner commented Sep 9, 2019

Sort of a duplicate of #2049, which should probably be reopened. This is partly underway (see #2168) but needs an actual PR.

@jbotka
Copy link
Contributor Author

jbotka commented Sep 10, 2019

I fixed first part, simple by changing condition but anyway after allowing debug it will throw this error:

CRITICAL - 2019-09-10 07:52:14 --> curl_setopt_array(): cannot represent a stream of type Output as a STDIO FILE*

@michalsn
Copy link
Member

You can try this fix #2204

@jbotka
Copy link
Contributor Author

jbotka commented Sep 10, 2019

You can try this fix #2204

Sorry didn't see your pull request :/ I did it a bit another way.

@michalsn
Copy link
Member

Well... from what I see, you removed the CURLOPT_STDERR part so it won't work.
According to the documentation, we should have the ability to write the output to a file or just "echo" it when the debug option is enabled.

@jbotka
Copy link
Contributor Author

jbotka commented Sep 10, 2019

Well... from what I see, you removed the CURLOPT_STDERR part so it won't work.
According to the documentation, we should have the ability to write the output to a file or just "echo" it when the debug option is enabled.

Yeah, I just realize it :) You are right...

@MGatner MGatner added this to the 4.0.0-rc.2 milestone Sep 14, 2019
@MGatner MGatner added the bug Verified issues on the current code behavior or pull requests that will fix them label Sep 14, 2019
@michalsn
Copy link
Member

@xbotkaj this should be fixed by #2168

Please, give it a try if you find a moment.

@jbotka
Copy link
Contributor Author

jbotka commented Sep 19, 2019

@xbotkaj this should be fixed by #2168

Please, give it a try if you find a moment.

Sorry I was few days off... I will look into it more in the next days.

@jim-parry jim-parry modified the milestones: 4.0.0-rc.2, 4.0.0-rc.3 Sep 24, 2019
@jbotka
Copy link
Contributor Author

jbotka commented Sep 25, 2019

Update to this issue. It is confirmed windows related problem. Uploaded to LINUX server and it works fine with php://output.

I tried to update CURL program in XAMPP without change. Maybe is problem in PHP curl extension for windows.

Similar issue in original guzzle -> guzzle/guzzle#1413

@jbotka jbotka changed the title CURLRequest - supplied argument is not a valid File-Handle resource CURLRequest - supplied argument is not a valid File-Handle resource #Windows x64 Sep 25, 2019
@khuderm
Copy link

khuderm commented Oct 1, 2019

I am experiencing this on Ubuntu 18.04.3 running php7 and apache2

@jbotka
Copy link
Contributor Author

jbotka commented Oct 2, 2019

I am experiencing this on Ubuntu 18.04.3 running php7 and apache2

Can you please write specific php build and full version of Apache? Maybe we can track it down. If it is possible please check curl extension version.

@michalsn
Copy link
Member

michalsn commented Oct 6, 2019

Finally, I had time to get my hands dirty with a windows machine.

I was able to reproduce this problem and also I have a possible solution.

Tested on machines/environments:

  • Win7 - spark with php 7.3.9 and xampp (apache 2.4.41 + php 7.3.9)
  • MacOS - spark with php 7.3.9
  • Ubuntu - nginx 1.13.3 + php 7.2.11

@michalsn michalsn mentioned this issue Oct 6, 2019
5 tasks
@MGatner
Copy link
Member

MGatner commented Oct 7, 2019

@michalsn Is the problem that php://output isn't supported on Windows? I can't find any documentation on this, and the PHP site states it as though it is a standard stream, always available. There are a lot of users reporting issues with it though. I personally don't think stderr is the most logical destination for the debug output, but it might be the low-hanging fruit right now.

@michalsn
Copy link
Member

michalsn commented Oct 7, 2019

@MGatner I couldn't find much about php://output for Windows but apparently, it doesn't work as expected. Technical reasons are unclear for me.

From what I understand php://stderr can be actually what we want. When running a built-in server via spark serve it will be outputted to the console screen. In the other case, it will write to the server error log.

It would be nice if someone could check if that referenced PR solves the problem in his case. Also - any other suggestions/ideas will be appreciated.

@MGatner
Copy link
Member

MGatner commented Oct 7, 2019

I understand the solution, and I agree with you - I was just noting that stderr feels like the wrong place to be sending debug output, even if it has the desired effect for our scenarios. But I think it is what we've got for now, and I'll be very glad to close this one out. Thank you for the troubleshooting and research - I'll give those with the issue a chance to test this solution before we merge but IMO this is ready.

@MGatner MGatner assigned MGatner and unassigned MGatner Oct 7, 2019
@michalsn
Copy link
Member

michalsn commented Oct 7, 2019

Yes, I definitely agree with you that using php://stderr seems a "little" wrong but for now I have no other ideas.

@lonnieezell
Copy link
Member

I can live with this solution for now, though I agree it doesn't feel perfect. As long as there's a note in the docs about this caveat I think we can close it out and get this feature working for people again.

Thanks for your work on this @michalsn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants