Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
2.2k views
in Plugins by
edited by

I love error-log-free environments, so this q2a-error makes me kind of crazy - appearing now every day.

PHP Warning:  Cannot modify header information - headers already sent by (output started at /qa-include/qa-theme-base.php:106) in /qa-include/qa-app-cookies.php on line 61

I asked about that in June and got gidgreen's answer, he pointed out to the plugins.

read on: http://question2answer.org/qa/20376/possible-solution-headers-already-sent-theme-base-cookies
 

As the wysiwyg editor plugin uses the qa_cookie_get_create() on line 108 (in the error message above it says line 106 though), so I think it is responsible. How can I change the code to prevent this error?

PS: I wonder what is causing the problem, something must be undefined? Maybe function qa_remote_ip_address() (in qa-base.php) is expecting an IP ... however, some users use services that hide IPs!

--

Update 2012-10-31: I got the error logs of the last 2 days and sent them gidgreen. It seems to me that it is not a plugin causing the error as arbitrary (?) files are accessed and the error just appears like that.

Q2A version: 1.5.3
by
edited by
As there are already some votes on this question, I assume that I am not the only one having this issue.

If you have this problem too, maybe you could post the q2a-version you are using + list your plugins. Thanks!

2 Answers

+2 votes
by

This line is in the output_raw(...) function in the theme class, so you need to find out who might be calling that. Possibly some plugin. Cross reference the error time against your web server logs to see which request is causing it. You can stick a debug_print_backtrace() in output_raw(...) to see where it's being called from.

by
Somewhere we have an error which gets written into the output, then it is tried to set a cookie... dunno
by
By cross referencing times against your web server's access_log, can you identify which HTTP request is leading to this PHP error?
by
I sent you the error logs by email a couple of days ago, is this not what you mean?
by
edited by
In my setup function output_raw(...) gets only called by:
1. custom-theme/qa-theme.php
2. qa-include/qa-theme-base.php

So either it is the custom theme or the core :)
It is NOT a plugin then...

--

Note: Checking all occurrences of output_raw() I see that only function sidepanel() with: $this->output_raw(@$this->content['sidepanel']); holds an @ sign before $this. All other occurrences do not have this @ sign.
0 votes
by

Please do a search through all your code for the function qa_cookie_get_create() and see if perhaps any plugins or other pieces of custom code are calling it at the wrong time, after some HTML has already been output by the theme.

by
Hi Gideon, there are 2 plugins calling qa_cookie_get_create():

1. Badges plugin:
- in qa-plugin.php, function qa_badge_award_check, line 261.
- in qa-badge-check.php, function award_badge, line 628.

2. WYSIWYG CKEditor plugin
- qa-wysiwyg-upload.php, function process_request, line 124

I guess it is not caused by HTML but by an error message that must be "triggered" somewhere before.

For the badges the chance to have an error might be the sql queries from line 245 (qa-plugin.php), or calling the function award_badge (happens on different spots).

For WYSIWYG the only chance to have an error is qa_get_logged_in_userid(), see line 123 of qa_get_logged_in_userid.

PS: I still have to update the badges plugin to the latest version. I would like to know from others if they get this php error as well, even with the latest version of badges...
by
edited by
I could disable the badges plugin for 1 day (even if my users will be irritated). But, as you see from the error log files I sent you, the error happens on different sites - where badges plugin is not involved. Even on /questions. This is why I think it is a problem of the core function...
by
Another idea I got when reading function qa_cookie_get_create():
1. What if the user's browser does not accept cookies? Could this be problematic?
2. What if the user hides his IP. Would this lead to an error in line 59 of qa-app-cookies.php: $cookieid=qa_db_cookie_create(qa_remote_ip_address());
...