Timeline for PHP8.2 ignores local value of `output_buffering` and uses master
Current License: CC BY-SA 4.0
Post Revisions
33 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| yesterday | audit | Suggested edits | |||
| yesterday | |||||
| Mar 23 at 23:47 | comment | added | tvanc | @drew010 yes! That fixed it. Thank you very much. | |
| Mar 20 at 11:28 | comment | added | shingo |
I found a way to debug where the buffering happens: First run strace -p <php-fpm-worker-pid>, and then visit the PHP file, observe whether strace outputs write/sleep 3 times in sequence. Next do the same steps, but this time you need to watch the httpd worker process to see if it outputs recv/write 3 times in sequence. (You may need to edit the config file first to ensure that fpm and httpd only spawn one worker process.) This method can also determine whether the fpm has read the .user.ini file.
|
|
| Mar 20 at 0:47 | comment | added | drew010 | Oh btw, that handler is using mod_proxy and mod_proxy_fcgi, so the relevant documentation is at httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html and the mod_proxy page. | |
| Mar 20 at 0:43 | comment | added | drew010 |
Any improvement if you add this after the FilesMatch? <Proxy fcgi://localhost> ProxySet enablereuse=on flushpackets=on </Proxy> flushpackets defaults to off and "determines whether the proxy module will auto-flush the output brigade after each "chunk" of data. 'off' means that it will flush only when needed; 'on' means after each chunk is sent; and 'auto' means poll/wait for a period of time and flush if no input has been received for 'flushwait' milliseconds. Currently, this is in effect only for mod_proxy_ajp and mod_proxy_fcgi."
|
|
| Mar 20 at 0:29 | history | edited | tvanc | CC BY-SA 4.0 |
added 196 characters in body
|
| Mar 20 at 0:25 | comment | added | tvanc |
@drew010 I added how Apache is configured to handle requests for PHP files to the question. I added RemoveOutputFilter DEFLATE html txt xml css js php and SetEnv no-gzip 1 to .htaccess just in case and got no change in behavior.
|
|
| Mar 20 at 0:21 | comment | added | tvanc | @shingo I added how Apache is set up to handle requests for PHP files to the question. | |
| Mar 20 at 0:10 | comment | added | tvanc |
@shingo i'm using FPM. fpm_get_status() is defined, which is only the case for FPM. I'm not using mod_proxy or mod_deflate. I'm accessing the PHP file directly via the browser. ob_get_status() returns an empty array as expected because I'm not using any ob_* functions
|
|
| Mar 19 at 20:18 | comment | added | drew010 | If it says local value is 0, that's what it's using. Master value is from the primary config, and local value is the actual value being used whether it came from .user.ini or ini_set or somewhere else. If you're using php-fpm with Apache, then you're using some proxy module or another in Apache, which might be responsible for the buffering. | |
| Mar 19 at 7:32 | comment | added | shingo |
Which module are you using? It is possible that you have set different buffering options for different directories/locations in Apache. Additionally, did you directly access the PHP file in the directory or did you access it through another PHP file? And try print_r(ob_get_status());, it should be empty if php's buffering is off.
|
|
| Mar 18 at 17:05 | comment | added | tvanc |
@shingo I'm not using mod_proxy or any of its variants. I am able to get the behavior I want when I set the output_buffering=0 master value, so that also rules out that any proxy or browser buffering is the culprit. In this case I don't want to set the master value though - I want output_buffering=0 in only one directory.
|
|
| Mar 18 at 17:03 | comment | added | tvanc |
@olivier thanks for responding. ob_get_level() returns 0. There's no ob_start() involved just. The behavior I'm observing rules out that Apache or my browser are doing the buffering and demonstrates that PHP is what's doing the buffering. I added code samples and additional details to my question in response to comments.
|
|
| Mar 18 at 16:57 | history | edited | tvanc | CC BY-SA 4.0 |
added 139 characters in body
|
| Mar 18 at 16:54 | comment | added | tvanc |
@YourCommonSense I'm not sure what that means. If you're saying the browser is doing its own buffering, then I wouldn't be able to achieve a streaming response at all in the browser but that's not the case. When I set the master value of output_buffering=0 I get the behavior I want - just not in .user.ini
|
|
| Mar 18 at 16:50 | comment | added | Your Common Sense | your str repeat is a browser issue not php | |
| Mar 18 at 16:47 | history | edited | tvanc | CC BY-SA 4.0 |
Added code sample
|
| Mar 18 at 16:40 | comment | added | tvanc | I don't understand why the downvote. | |
| Mar 18 at 16:40 | comment | added | tvanc |
@shingo the actual behavior is that content arrives in 4096-byte chunks instead of character by character. To test: for($i = 0; $i < 3; ++$i) { echo $i; sleep(1); echo str_repeat(' ', 4096); } Without the str_repeat() call the response arrives all at once after three seconds. With the call the response arrives in chunks one second apart. I'll add that to the question.
|
|
| Mar 18 at 16:20 | comment | added | tvanc |
@YourCommonSense that does not answer my question. Other settings do have an effect in .user.ini. For instance I set default_mimetype=application/json and my pages started being served as JSON. Also I mentioned in my question that the output_buffering value in my .user.ini is displayed in phpinfo() output.
|
|
| Mar 18 at 9:07 | comment | added | shingo |
What is the actual, seemingly erroneous behavior? Please note you can't fully disable bufferring when using mod_proxy(_fcgi)
|
|
| Mar 18 at 7:51 | comment | added | Olivier |
What makes you think that PHP uses output buffering? What does ob_get_level() return?
|
|
| Mar 18 at 7:06 | review | Close votes | |||
| Mar 22 at 0:06 | |||||
| Mar 18 at 6:10 | comment | added | Your Common Sense | So it's your answer. php-fpm doesn't support user ini | |
| Mar 17 at 21:06 | comment | added | tvanc |
@YourCommonSense php_sapi_name() returns fpm-fcgi
|
|
| Mar 17 at 20:59 | comment | added | Your Common Sense | And which actual sapi it is? FPM or FastCGI? | |
| Mar 17 at 20:48 | comment | added | tvanc |
@drew010 I can confirm the request isn't being gzipped and with RemoveOutputFilter DEFLATE I'm still getting the exact same, seemingly erroneous behavior. I'm not aware of another mechanism by which Apache could be buffering output.
|
|
| Mar 17 at 20:29 | comment | added | drew010 | Is it Apache buffering? stackoverflow.com/questions/33628918/… | |
| Mar 17 at 20:22 | comment | added | tvanc |
@YourCommonSense I'm not able to find any instances of php_admin_value in the apache configuration, and SetEnv is for mod_php, not FPM/FastCGI.
|
|
| Mar 17 at 20:02 | comment | added | tvanc |
@YourCommonSense phpinfo() shows Sever API = FPM/FastCGI, so .user.ini is the correct mechanism. In the question you linked it appears the asker was using PHP via mod_php, which does not support .user.ini. Attempting to use php_value directives in .htaccess leads to an internal server error.
|
|
| Mar 17 at 20:00 | comment | added | Your Common Sense | Another reason is master value is set with php_admin_value and hence not user-changeable | |
| Mar 17 at 19:54 | comment | added | Your Common Sense | So may be your question is just php ignores .user.ini? | |
| Mar 17 at 19:46 | history | asked | tvanc | CC BY-SA 4.0 |