Skip to content

Conversation

@hranicka
Copy link
Contributor

@hranicka hranicka commented Jun 20, 2016

I run a CLI application in a debug mode (development, CI).

But Tracy v2.4 is starting a session automatically and itselfs: [1], [2].

I can't solve this by fake session object. When DI Container is initialized, session_start() is called and I do nothing with it.

So I've extracted session_* code into ISession interface which should allow set custom ISession implementation. It is useful in a CLI when debug mode is enabled.


https://forum.nette.org/cs/26250-pojdte-otestovat-nette-2-4-rc?p=3#p175951
http://zlml.cz/fix-compatibility-with-nette-2-4#comment-2740141135

public function render()
{
$useSession = $this->dispatched && session_status() === PHP_SESSION_ACTIVE;
$useSession = $this->dispatched && Debugger::getSession()->isActive();
Copy link
Contributor Author

@hranicka hranicka Jun 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this file should be untouched (session_status() === PHP_SESSION_ACTIVE)?

@dg
Copy link
Member

dg commented Jun 20, 2016

Simply don't call Tracy\Debugger::dispatch in TracyExtension in CLI, this is unnecessary complicated solution.

@hranicka
Copy link
Contributor Author

@dg But TracyExtension adds Tracy\Debugger::dispatch() call automatically in Container::initialize, see https://github.com/nette/tracy/blame/master/src/Bridges/Nette/TracyExtension.php#L101

This is my problem. I have fake session, but with v2.4 it doesn't work correctly because Tracy checks for session_status and calls session_starts internally.

@hranicka
Copy link
Contributor Author

hranicka commented Jun 20, 2016

@dg Or did you mean throw away these changes (ISession inside Debugger) and rather edit TracyExtension and allow/disallow this line call?

@dg
Copy link
Member

dg commented Jun 20, 2016

Yes :-)

@hranicka
Copy link
Contributor Author

hranicka commented Jun 20, 2016

@dg
Hmm, and is explicit call of Tracy\Debugger::dispatch(); really needed in Container::initialize?

What about if I replace

$initialize->addBody('if ($tmp = $this->getByType("Nette\Http\Session", FALSE)) { $tmp->start(); Tracy\Debugger::dispatch(); };');

with

$initialize->addBody('if ($tmp = $this->getByType("Nette\Http\Session", FALSE)) { $tmp->start(); };');

?

@dg
Copy link
Member

dg commented Jun 20, 2016

It is needed for AJAX requests and redirects in bar.

@hranicka
Copy link
Contributor Author

@dg Thank you for your time and explanation. I've made another PR, see #200 .

Closing this.

@hranicka hranicka closed this Jun 20, 2016
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

Successfully merging this pull request may close these issues.

2 participants