[FrameworkBundle] fixed client insulation (closes #1726, closes #4608)

This commit is contained in:
Fabien Potencier 2012-07-01 23:01:26 +02:00
parent c0e4760b38
commit 4f4c679eef

View File

@ -84,6 +84,11 @@ class Client extends BaseClient
/**
* Returns the script to execute when the request must be insulated.
*
* It assumes that the autoloader is named 'autoload.php' and that it is
* stored in the same directory as the kernel (this is the case for the
* Symfony Standard Edition). If this is not your case, create your own
* client and override this method.
*
* @param Request $request A Request instance
*
* @return string The script content
@ -94,11 +99,22 @@ class Client extends BaseClient
$request = str_replace("'", "\\'", serialize($request));
$r = new \ReflectionObject($this->kernel);
$autoloader = dirname($r->getFileName()).'/autoload.php';
if (is_file($autoloader)) {
$autoloader = str_replace("'", "\\'", $autoloader);
} else {
$autoloader = '';
}
$path = str_replace("'", "\\'", $r->getFileName());
return <<<EOF
<?php
if ('$autoloader') {
require_once '$autoloader';
}
require_once '$path';
\$kernel = unserialize('$kernel');