Jump to content

When does PHP Buffer Post Data?


Recommended Posts

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:

  1. Does PHP always buffer data to a temporary file? Or is it only when post data is of a certain size?
  2.  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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.