Skip to content

ISession added#198

Closed
hranicka wants to merge 1 commit into
nette:masterfrom
hranicka:feature/session
Closed

ISession added#198
hranicka wants to merge 1 commit into
nette:masterfrom
hranicka:feature/session

Conversation

@hranicka

@hranicka hranicka commented Jun 20, 2016

Copy link
Copy Markdown
Contributor

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

Comment thread src/Tracy/Bar.php
public function render()
{
$useSession = $this->dispatched && session_status() === PHP_SESSION_ACTIVE;
$useSession = $this->dispatched && Debugger::getSession()->isActive();

@hranicka hranicka Jun 20, 2016

Copy link
Copy Markdown
Contributor Author

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

dg commented Jun 20, 2016

Copy link
Copy Markdown
Member

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

@hranicka

Copy link
Copy Markdown
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

hranicka commented Jun 20, 2016

Copy link
Copy Markdown
Contributor Author

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

@dg

dg commented Jun 20, 2016

Copy link
Copy Markdown
Member

Yes :-)

@hranicka

hranicka commented Jun 20, 2016

Copy link
Copy Markdown
Contributor Author

@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

dg commented Jun 20, 2016

Copy link
Copy Markdown
Member

It is needed for AJAX requests and redirects in bar.

@hranicka

Copy link
Copy Markdown
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