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

headers already sent by qa-xml-sitemap.php:293 #46

Closed
q2apro opened this issue Apr 28, 2014 · 7 comments
Closed

headers already sent by qa-xml-sitemap.php:293 #46

q2apro opened this issue Apr 28, 2014 · 7 comments

Comments

@q2apro
Copy link

q2apro commented Apr 28, 2014

Hi everyone, I am getting the following error once in a while (which fills my error_log):

PHP Warning:  Cannot modify header information - headers already sent by (output started at /qa-plugin/xml-sitemap/qa-xml-sitemap.php:293) in qa-include/qa-app-users.php on line 1042

Line 293 from qa-xml-sitemap.php is:

"\t</url>\n";

What could be the problem and how can I fix this?

Thanks
Kai

PS: I know this is a plugin issue but I am posting this error here because this plugin comes only with the core distribution.

@svivian
Copy link
Collaborator

svivian commented May 1, 2014

I cannot reproduce this error here. Is there perhaps another plugin that's causing it? Can you try temporarily removing any non-official plugins and see if the error still occurs? If so, try putting them back one at a time until you find the plugin causing the error.

@svivian
Copy link
Collaborator

svivian commented May 8, 2014

@q2apro Any luck reproducing the issue? Does it occur when you load the sitemap yourself (e.g. your-q2a-site.com/sitemap.xml)

@q2apro
Copy link
Author

q2apro commented May 8, 2014

I realized that loading the your-q2a-site.com/sitemap.xml created the error. Getting this error means for me a bot crawled the sitemap URL.

I disabled each plugin one by one, loaded the sitemap.xml, and tried to find out if the error does not appear. The error appeared no matter what plugin I disabled. Still have no clue. I will update with v1.7 to see if the problem goes away. Just wait for the release :)

@svivian
Copy link
Collaborator

svivian commented May 9, 2014

OK I found the issue! It occurs only when logged out. Strangely, it also only occurs when I include the user accounts in the sitemap, though I think that may be related to output buffering.

In qa_get_request_content the content is fetched, then qa_set_form_security_key is called which sets a cookie for non logged-in users. However in the case of the sitemap plugin, instead of returning $qa_content it outputs content immediately which prevents the cookie setting.

Anyway, it looks like this particular problem can be fixed by only calling the function if qa_content exists (qa-page.php line 227):

if (isset($qa_content))
    qa_set_form_security_key();

@q2apro
Copy link
Author

q2apro commented May 9, 2014

Great work! In my installation I unchecked the "Include user pages" for the xml sitemap plugin now. Let's see if this fixes the error. Or if I need to change the code as you suggested.

@svivian
Copy link
Collaborator

svivian commented May 9, 2014

I don't think it's specifically the user pages, I think it's the size of the sitemap output. I only have a few questions on my test site but many users. If you have many questions you will probably get the same error without the users.

@q2apro
Copy link
Author

q2apro commented May 9, 2014

All right, I added the line in qa-page.php. Seems to be fixed now. When calling the stemap.xml (logged-in or logged-out) the error does not appear anymore.

@q2apro q2apro closed this as completed May 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants