ElkArte Community

Project Support => Support => Topic started by: ahrasis on January 04, 2018, 12:52:32 am

Title: Headers already sent
Post by: ahrasis on January 04, 2018, 12:52:32 am
I think when scheduled task is running like this (?scheduled=task;ts=1515043800) there is an error reported like this (Headers already sent in /var/www/clients/clientXXX/webXXX/web/index.php at line 33).

I believe this is due to MultiTenancy addon but I need a direction to check for this to fix it.

Thank you in advance.
Title: Re: Headers already sent
Post by: emanuele on January 04, 2018, 02:30:08 am
Depends on the direction you need.
In general it just means that the header function was called before the one in index.php at line 33.
The reason... well, most of the cases an error that for some reason sends an header too early in the games.
Title: Re: Headers already sent
Post by: ahrasis on January 04, 2018, 07:54:38 pm
I resolved it by running the fast cgi after dispatcher code, instead of before it.
Code: [Select]
if (isset($_GET['scheduled']))
{
$controller = new ScheduledTasks_Controller();
$controller->action_autotask();

// Don't make people wait on us if we can help it.
if (function_exists('fastcgi_finish_request')) {
fastcgi_finish_request();
}
}

I am, however, not sure of its effects though I managed to stop the header error.

Will it hurts if default ElkArte is also running in the above changed sequence instead of default as below?
Code: [Select]
if (isset($_GET['scheduled']))
{
// Don't make people wait on us if we can help it.
if (function_exists('fastcgi_finish_request'))0
fastcgi_finish_request();

$controller = new ScheduledTasks_Controller();
$controller->action_autotask();
}
Title: Re: Headers already sent
Post by: emanuele on January 05, 2018, 02:29:18 am
hmm...
There is no other errors?
Did you try running manually  the scheduled task?
As I said, usually the headers already sent is due to a previous error firing, so I think that finishing the request before is just a silencing the error, sort of adding a @.
Title: Re: Headers already sent
Post by: ahrasis on January 05, 2018, 05:29:16 am
Yes. I did try manually running the scheduled task but there is no error. I also waited until now, and still no error.

The addon does not modify ScheduledTasks.controller.php, so I am not sure which part of the modification (or even hook) triggers the header send when fastcgi_finish_request() is run first before the scheduled tasks.

I can only follow the error if it is there but they are just the same if I am using the default index.php. So I am clueless to figure out other solution.
Title: Re: Headers already sent
Post by: emanuele on January 05, 2018, 07:41:25 am
Does the addon have any scheduled task at all?
When you go to admin > manintenance > scheduled tasks > task log do you see any with a red cross? (Actually a red question mark :P)
Title: Re: Headers already sent
Post by: ahrasis on January 05, 2018, 06:12:55 pm
I don't think so or at least not that I remembered anything about it while browsing the code, but I will check it out today. Thanks for the tips.
Title: Re: Headers already sent
Post by: emanuele on January 05, 2018, 07:26:12 pm
BTW: 1.0 or 1.1?
Because on 1.0 I remember seeing such errors around but I think it was fixed in 1.1?
Title: Re: Headers already sent
Post by: ahrasis on January 05, 2018, 07:30:45 pm
I am using 1.1 now with the addon as well. What were the errors in 1.0 and how was that fixed? May be that will help me in narrowing this down.
Title: Re: Headers already sent
Post by: emanuele on January 08, 2018, 01:47:03 pm
Heck if I remember...
Title: Re: Headers already sent
Post by: ahrasis on January 08, 2018, 08:41:27 pm
No problem. At least for now. ;)
Title: Re: Headers already sent
Post by: live627 on January 08, 2018, 09:55:38 pm
Check the error log file. Anything relevant?