bug#9169 Fixed client insulation when using the terminable event (fabpot)

This PR was merged into the 2.2 branch.

Discussion
----------

Fixed client insulation when using the terminable event

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Commits
-------

8c8cf62 fixed Client when using the terminable event
This commit is contained in:
Fabien Potencier 2013-09-29 21:40:44 +02:00
commit 66d0b18deb
2 changed files with 22 additions and 4 deletions

View File

@ -156,7 +156,7 @@ class Client extends BaseClient
$profilerCode = '$kernel->getContainer()->get(\'profiler\')->enable();';
}
return <<<EOF
$code = <<<EOF
<?php
if ('$autoloader') {
@ -167,7 +167,10 @@ require_once '$path';
\$kernel = unserialize('$kernel');
\$kernel->boot();
$profilerCode
echo serialize(\$kernel->handle(unserialize('$request')));
\$request = unserialize('$request');
EOF;
return $code.$this->getHandleScript();
}
}

View File

@ -84,7 +84,7 @@ class Client extends BaseClient
$requirePath = str_replace("'", "\\'", $r->getFileName());
$symfonyPath = str_replace("'", "\\'", realpath(__DIR__.'/../../..'));
return <<<EOF
$code = <<<EOF
<?php
require_once '$requirePath';
@ -94,7 +94,22 @@ require_once '$requirePath';
\$loader->register();
\$kernel = unserialize('$kernel');
echo serialize(\$kernel->handle(unserialize('$request')));
\$request = unserialize('$request');
EOF;
return $code.$this->getHandleScript();
}
protected function getHandleScript()
{
return <<<'EOF'
$response = $kernel->handle($request);
if ($kernel instanceof Symfony\Component\HttpKernel\TerminableInterface) {
$kernel->terminate($request, $response);
}
echo serialize($response);
EOF;
}