-
Notifications
You must be signed in to change notification settings - Fork 40
Fix condition error when reading stdout #35
Conversation
|
Thanks for your contribution @cedroux! WHich operating systems did you test the new solution on? I originally wrote php-r on macos, just curious if PR can break some things in addition to fixing others. |
|
I tested it on a Vagrant box running on Ubuntu Linux (Laravel Homestead) $ uname -a
Linux homestead 4.4.0-92-generic #115-Ubuntu SMP Thu Aug 10 09:04:33 UTC 2017 x86_64 x86_64 x86_64 GNU/LinuxEdit: With PHP 7.1 |
|
After some more tests, I can tell this PR may For instance, before my PR the following R script: print('Hello World! 1')
print('Hello World! 2')
print('Hello World! 3')Would output: Instead of To hide the first line I had to do some black magic with $rProcess->write(PHP_EOL . PHP_EOL . $script . PHP_EOL);Now with my PR, this trick doesn't work anymore and the first line is always returned by the Edit: And in some case, the two first lines are not displayed. There is some kind of i/o mangling that I'm not sure to understand here. |
|
Ok, with the last two commits I think I nailed it. 59b3d20: The |
|
Good to see new comments @cedroux! So am I right that outputting this is no longer the case? |
|
Almost, the exact current output is now: Maybe we should check if |
|
That worries me a bit, because other users may face issues that'll be really hard to investigate. Do you think you could find a solution that would be 100% backwards-compatible? |
|
Oh OK, I just understood the problem here, and it was my fault, sorry! All of the commands that don't have an output will just append a new Example: var1 = TRUE
var2 = TRUE
var3 = TRUE
print('Hello World!')
var4 = TRUE
var5 = TRUE
var6 = TRUE
It was like this before my PR but I forgot about it. Is it the expected behaviour? |
|
If I remember correctly, yes it is. Will you be happy if this PR is merged now? |
|
Yes it is OK for me. |
|
Thanks again @cedroux! Your changes are in v1.0.1 now. |
|
I'm using version 1.0.1 (2017-12-08) of the php-r library on linux servers (16.04 and 18.04). On both servers it happens that sometimes the page is waiting for the server (waiting localhost...). If the load is interrupted and reloaded, the page loads correctly. After several successful recharges, the page does not reload again, it remains indefinitely waiting for the server (waiting localhost...). This happens in a cyclical way. What do you suggest to avoid this situation? |
|
Hi @mamoralesri! I'm sorry, but I won't be able to help here. Haven't used PHP or R for over two years, mainly Node.js now. |
In some occurences, when reading the stdout buffer, the output can contain multiple lines at once.
I changed the conditions to take that case into account.
This PR will probably solve #14 and #18,