Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't upload media file on php 5.6 if not config php.ini with always_populate_raw_post_data = -1 #1104

Closed
winggundamth opened this issue Apr 3, 2015 · 6 comments

Comments

@winggundamth
Copy link

I'm using DokuWiki Release 2014-09-29d "Hrun". I upgraded my box to php 5.6

# php -v
PHP 5.6.7-1+deb.sury.org~utopic+1 (cli) (built: Mar 24 2015 11:23:10) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies

Everything work fine except Upload in Media Manager. When I upload something it always shown Failed so I looked at my apache error log and found this

[Fri Apr 03 10:58:16.969417 2015] [proxy_fcgi:error] [pid 5018:tid 140197337466624] [client 172.17.42.1:44459] AH01071: Got error 'PHP message: 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\n', referer: http://wiki.example.net/example?do=media&ns=
[Fri Apr 03 10:58:16.969664 2015] [proxy_fcgi:error] [pid 5018:tid 140197337466624] [client 172.17.42.1:44459] AH01071: Got error 'PHP message: PHP Warning:  Cannot modify header information - headers already sent in /var/www/html/inc/auth.php on line 1335\nPHP message: PHP Warning:  Cannot modify header information - headers already sent in /var/www/html/lib/exe/ajax.php on line 14\n', referer: http://wiki.example.net/example?do=media&ns=

So I went to php.ini and add variable as it suggested then everything working again.

always_populate_raw_post_data = -1

I'm not sure this should fix or not but since this php.ini is default that comes with php package and I see warning message about PHP Deprecated so I think I should open this issue to let you know.

@Chris--S
Copy link
Collaborator

Chris--S commented Apr 3, 2015

The first message isn't fatal. The second message implies you
actually have "display_errors" set on. When php writes the first
warning in the output stream (i.e. displaying the error), it prevents
dokuwiki working properly - I.e. modifying http headers before it
starts its own output.

Try turning display_errors off and leaving the other setting at the default.

This issue should remain open as we will need to respond to the
deprecated issue before the feature is actually removed in a future
php version.

  • Chris

@splitbrain
Copy link
Collaborator

Hmm, I can't find any references to $HTTP_RAW_POST_DATA in our code. media_upload_xhr() already uses php://input.

The error message states it occurred in Unknown on line 0 which usually means it comes from some preloaded file and not one of DokuWiki's own files. @winggundamth does your PHP setup use the auto_prepend_file directive for something?

@kraag22
Copy link

kraag22 commented Jun 3, 2015

better about this issue is here: matomo-org/matomo#6465

@winggundamth
Copy link
Author

@splitbrain No I didn't have auto_prepend_file. This is just default php5-fpm configuration

@Klap-in
Copy link
Collaborator

Klap-in commented Jun 11, 2015

The link of @kraag22 explains that this is caused by a not handy default setting of php for always_populate_raw_post_data. PHP should improve this... As workaround piwik add an check that give admins feedback about the right setting.

@splitbrain
Copy link
Collaborator

Reading the piwik ticket thread explained what exactly is going wrong here. There's also a nice blog post at https://www.bram.us/2014/10/26/php-5-6-automatically-populating-http_raw_post_data-is-deprecated-and-will-be-removed-in-a-future-version/

To summarize:

  • DokuWiki does not use $HTTP_RAW_POST_DATA
  • DokuWiki does not rely on always_populate_raw_post_data
  • PHP 5.6 deprecated the always_populate_raw_post_data
  • The default setting of always_populate_raw_post_data is 0
  • 0 does not mean off, only -1 turns off the feature
  • thus everyone not having explicitly configured always_populate_raw_post_data = -1 will get errors
  • the setting can not be set from program context. Only a php.ini change works
  • we can do nothing about this. People need to configure their PHP properly (or request their hosters to do that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants