Drongo_III Posted January 18, 2021 Share Posted January 18, 2021 Hi Guys I'm getting the following error when sending large post data to a PHP 7 application: PHP Warning: Unknown: POST data can’t be buffered; all data discarded in Unknown on line 0 I think I have a fix for this now, so the error isn't the source of my question. It just got me wondering two things: Does PHP always buffer data to a temporary file? Or is it only when post data is of a certain size? Are there any php.ini settings that directly influence this behaviour? I have trawled through the common ini settings but nothing (that i can find) mentions buffering. Thanks, Drongo Quote Link to comment Share on other sites More sharing options...
requinix Posted January 18, 2021 Share Posted January 18, 2021 This behavior is related to the SAPI - that is, the thing PHP interacts with when it needs to do stuff like read incoming request bodies. So which are you using? php-fpm? mod_php? Does that have any relevant settings that may explain why it couldn't buffer the request body? Quote Link to comment Share on other sites More sharing options...
Drongo_III Posted January 18, 2021 Author Share Posted January 18, 2021 Hi Requinix Thanks for the fast response. I'm not too worried about the error as it sounds self explanatory to fix. The full error was: PHP Warning: Unable to creeate temporary file, Check permissions in temporary files directory. in unknown PHP Warning: unknown: Post data can't be buffered; all data discarded in unknown There's no temp directory in php.ini so it seems to be falling back to the system temp directory for which apache doesn't have permissions. But the essence of what I'm trying to figure out is what may influence it buffering post data to a temp directory. As this may in turn let me figure out the best course of action for fixing the issue. Also, I'm using mod_php. Quote Link to comment Share on other sites More sharing options...
requinix Posted January 18, 2021 Share Posted January 18, 2021 28 minutes ago, Drongo_III said: the system temp directory for which apache doesn't have permissions. Well there ya go. The system temp directory should be writable by virtually everyone - it's the temp directory, it's supposed to be usable for creating temporary files. Quote Link to comment Share on other sites More sharing options...
Drongo_III Posted January 18, 2021 Author Share Posted January 18, 2021 3 hours ago, requinix said: Well there ya go. The system temp directory should be writable by virtually everyone - it's the temp directory, it's supposed to be usable for creating temporary files. That's great. But I was hoping to gain some insight into what drives that buffering behaviour. Does it just kick in after post size is over a certain amount? I can't seem to find any settings that state they make post data buffer. Quote Link to comment Share on other sites More sharing options...
requinix Posted January 19, 2021 Share Posted January 19, 2021 As far as I know, the buffering always happens for POST requests. It's an internal detail that allows people to read the request body multiple times - no buffering means it could only be read once (and by PHP itself). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.