Archive script failing - headers already sent

Hello,

When i run the archive script, I’m getting this error
Unable to start session. Check that session.save_path or tmp/sessions is writeable.

However, if I trace out the exception, I see more information

(from code below)
Session must be started before any output has been sent to the browser; output started in /0

(
[_previous:private] =>
[message:protected] => Session must be started before any output has been sent to the browser; output started in /0
[string:private] =>
[code:protected] => 0
[file:protected] => /public/piwik_custom/piwik/libs/Zend/Session.php
[line:protected] => 457
[trace:private] => Array
(
[0] => Array
(
[file] => /public/piwik_custom/piwik/core/Session.php
[line] => 88
[function] => start
[class] => Zend_Session
[type] => ::
[args] => Array
(
)

            )

        [1] => Array
            (
                [file] => /public/piwik_custom/piwik/index.php
                [line] => 47
                [function] => start
                [class] => Piwik_Session
                [type] => ::
                [args] => Array
                    (
                    )

            )

    )

)

Also session.auto_start is Off

Does anyone know how to resolve this?

Thank you!

Make sure those directories are writeable under whatever user ID your cron job runs as, and double check that that session.auto_start=Off as it might be configured in a separate php.ini file (i.e., for php-cli).

The “Session must be started before any output has been sent to the browser; output started in /0” message is probably because you’re printing messages.

Actually I have the same issue when running piwik unit tests on windows.

In particular, the integration file trunk\tests\integration\processed\test_apiGetReportMetadata__API.getProcessedReport_day.xml

is:


<?xml version="1.0" encoding="utf-8" ?>
<result>
	<error message="Session must be started before any output has been sent to the browser; output started in /0" />
</result>

At this stage I’m not sure what is causing this, but will try to understand…

I checked in a fix for the headers already sent. The culprit is using php-cgi instead of php-cli. The changeset is http://dev.piwik.org/trac/changeset/3468 (note there’s a new file).

As for the unit tests, I’m investigating something similar in Webtest: failing unit tests on my CI server · Issue #1908 · matomo-org/matomo · GitHub.

This is working now, but I don’t understand why since I execute unit tests from http in firefox. Is there a reason the changeset r3468 would have fixed this use case as well?

That particular changeset shouldn’t have.made a difference in your case.