-
Notifications
You must be signed in to change notification settings - Fork 90
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
curl to post generate gives error: The parameter post_content
reads from STDIN
#293
Comments
Same issue here. Thanks for the proposed solution. |
I cannot replicate the above, the command just works fine for me for both v2.4.0 and for latest dev. Can you post the output of the following commands for me to get more information about your environment?
I suspect there's a script in-between that messes up the IO. |
Howdy,
This is running inside of Docker |
|
I'm available for a quick anydesk call if that helps |
STDIN seems to be populated in PHP:
This works:
So it means it's something with my CURL? Even though this works, too.
And, this works:
Something in this code is bailing the execution before it can try to read from STDIN, only when feeded by CURL:
Aha! The problem is the timeout:
I've added a timeout of 10s, the stream returns as expected with Curl now. 10s is just the timeout, but it seems it returns as soon as ready, if it will be ready at all:
|
@schlessera Can you please take a look at the debugging process and proposed solution above? ☝️ Essentially, increasing the timeout here:
One downside of the timeout approach is that if there's no STDIN, it will take 10s for the command to fail:
I'm not sure if there are better ways to tackle this. Any timeout below 1s is returning an empty stream for me, it seems the timeout is directly related to the time it takes for curl to feed the data, so it's a combination of issues between curl and the no timeout. So that's why pre-computing the result of curl works, in the example of the original thread:
What I find most curious is that the STDIN is there when PHP starts execution, so the timeout should be unnecessary:
Maybe just read |
I'm getting the same error. System:
Command:
Error:
But this one wors:
Could be the API issue |
@zzap Please try this:
With the approach above, we are essentially pre-caching the remote response in a local file and then feeding it to WP CLI, essentially minimizing delays that could be causing this issue. I don't know exactly what's happening, but for a definitive solution I'd play around with increasing the
0 to 1 or more
|
I encountered this issue, as well. The workaround @Luc45 suggested worked. Would a permanent solution be to add an optional
So the The |
Bug Report
Describe the current, buggy behavior
curl -Ns http://loripsum.net/api/5 | wp post generate --post_content --count=10
Gives me:
Error: The parameter
post_contentreads from STDIN.
Curl works fine:
Describe how other contributors can replicate this bug
// You can also use code snippets if needed.
Describe what you would expect as the correct outcome
Generate posts
Let us know what environment you are running this on
Provide a possible solution
If you happen to have a suggestion on how to fix this bug, please tell us in here.
Just leave this section out if you don't know how to fix it.
Provide additional context/Screenshots
this works:
echo "hello world" | wp post generate --post_content --count=10
This works:
The text was updated successfully, but these errors were encountered: