1 (edited by justapeddler 09/01/2016 04:34:04 pm)

Topic: Broken ajax functionality in newer php installation

I'm running fa under xampp. Some ajax functionality is broken (always result in timeouts) when used in newer php environments. Most problems are from form data editing or submitting new data.

Here is a little data on such error

error
[Thu Sep 01 19:13:58.342566 2016] [:error] [pid 14080:tid 1632] [client 127.0.0.1:56914] PHP Deprecated:  Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0, referer: http://127.0.0.1/fa/inventory/manage/locations.php?
[Thu Sep 01 19:13:58.342566 2016] [:error] [pid 14080:tid 1632] [client 127.0.0.1:56914] PHP Warning:  Cannot modify header information - headers already sent in Unknown on line 0, referer: http://127.0.0.1/fa/inventory/manage/locations.php?
[Thu Sep 01 19:13:58.364568 2016] [:error] [pid 14080:tid 1632] [client 127.0.0.1:56914] PHP Notice:  Trying to get property of non-object in C:\\xampp\\htdocs\\fa\\includes\\errors.inc on line 74, referer: http://127.0.0.1/fa/inventory/manage/locations.php?

access
127.0.0.1 - - [01/Sep/2016:19:13:58 +0700] "POST /fa/inventory/manage/locations.php?JsHttpRequest=0-xml HTTP/1.1" 200 570 "http://127.0.0.1/fa/inventory/manage/locations.php?" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0"

Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.15

Current database version Required  2.4.1 

Fa doesn't return any error if I turn off javascript.


Tested with older deployment of xampp using php 5.3.1 and ajax works fine without timeouts.

Any idea to what I can do to fix the ajax timeout error?

EDIT: tested with php 5.4.31 and also no errors

2 (edited by apmuthu 09/02/2016 10:59:00 am)

Re: Broken ajax functionality in newer php installation

In PHP v5.6 onwards this behavior is so. Restart the webserver after including the following line in the php.ini file:

always_populate_raw_post_data = -1

The caveat for the above would be an inability to upload files as discussed here. The newer recommended construct for Ajax is to use php://input stream that does not have the above issue.

If you are using the latest code from GitHub / SF Git, (for FA v2.3.25+) you will find HTTP_RAW_POST_DATA is so in line 264:

        $rawPost = strcasecmp($_SERVER['REQUEST_METHOD'], 'POST') == 0? (isset($GLOBALS['HTTP_RAW_POST_DATA'])? $GLOBALS['HTTP_RAW_POST_DATA'] : @file_get_contents("php://input")) : null;

Re: Broken ajax functionality in newer php installation

Yes ,
@ apmuthu  your right

; Always populate the $HTTP_RAW_POST_DATA variable. PHP's default behavior is
; to disable this feature and it will be removed in a future version.
; If post reading is disabled through enable_post_data_reading,
; $HTTP_RAW_POST_DATA is *NOT* populated.
; http://php.net/always-populate-raw-post-data
always_populate_raw_post_data = -1

its should be made -1,

as when i install new version of WAMP ( which came latest php/mysql version ) ....
my edit / add function was taking to much time ...

i did above changes in php.ini..... and it solved my solution .....

but still struggle to find solution for bigger result smile

Re: Broken ajax functionality in newer php installation

apmuthu wrote:

In PHP v5.6 onwards this behavior is so. Restart the webserver after including the following line in the php.ini file:

always_populate_raw_post_data = -1

The caveat for the above would be an inability to upload files as discussed here. The newer recommended construct for Ajax is to use php://input stream that does not have the above issue.

So, does the main problem lie in fa using deprecated ajax constructs?

Is the best solution to use PHP <5.6 if I am using fa for commercial deployment?

5 (edited by apmuthu 09/02/2016 05:37:49 pm)

Re: Broken ajax functionality in newer php installation

Using FA v2.3.25+ with PHP version < 5.6 is recommended for production.

Check the value of the variable always_populate_raw_post_data in your php.ini in PHP 5.6 when your errors come.

Increase the timeout value for script execution and input time in php.ini for bigger results.