Posts: 21
Threads: 4
Joined: Feb 2012
Hello again
on my local wamp I don't have the error, but when put on the production server my in-development plugin generates the error
Code:
Warning: Cannot modify header information
headers already sent by (output started at /path/to/getsimple/admin/inc/template_functions.php:27)
looking briefly at the template_functions.php file with its ob_start and ob_end this seems normal (so maybe I should save the datas more elegantly using an ajax request instead of using a header:Location trick as I mimicked what is done in the pages.php file) but what may be going on differently on the local server vs the distant server that don't make it throw the error ?
Now that I think about it : I don't use the same theme locally and on the webserver so I think I know what's wrong : my them doesn't have a functions.inc.php file while the default theme (on the server) has.
Posts: 21
Threads: 4
Joined: Feb 2012
(2014-03-08, 05:07:23)Bertrand Wrote: Now that I think about it : I don't use the same theme locally and on the webserver so I think I know what's wrong : my them doesn't have a functions.inc.php file while the default theme (on the server) has.
nope I just checked and it's a wrong explanation, so it's still a mystery to me.
Posts: 6,266
Threads: 181
Joined: Sep 2011
template file might have newlines after closing php tag?
Or one of its includes?
Posts: 6,266
Threads: 181
Joined: Sep 2011
actually template_functions.php does
remove that and see if it helps.
Posts: 6,266
Threads: 181
Joined: Sep 2011
and the difference would be one has output_buffering on in php
Posts: 21
Threads: 4
Joined: Feb 2012
spot-on, that's a php config issue.
Posts: 6,266
Threads: 181
Joined: Sep 2011
Not really the solution but it would fix it. Still curious what was the problem
Posts: 21
Threads: 4
Joined: Feb 2012
2014-03-08, 10:01:53
(This post was last modified: 2014-03-08, 10:03:35 by Bertrand.)
I checked and the issue was indeed exactly what you spotted : my WAMP installation has php output_buffering on, I turned it off and the header warning happened as on the distant server.
In case someone has the same issue with WAMP (the packaged software) simply add
Code:
php_flag "output_buffering" off
in your root .htaccess file to turn it off.
Posts: 6,266
Threads: 181
Joined: Sep 2011
Usually you have to set this in php.ini, rare that a host allows this in htaccess
Posts: 21
Threads: 4
Joined: Feb 2012
sorry for my inaccuracy : it works with WAMP
Posts: 21
Threads: 4
Joined: Feb 2012
Regarding my initial headers issue, as I hated a javascript redirect workaround, I finally decided to do the saving in a admin-pre-header hook, using a hidden form field identifying my plugin not to interfere with other stuff - save me the hassle of using a separate ajax request (which can also be handled in a admin-pre-header hook now that I think about it) and keeps everything in a unique file - that I like a lot.