Looks good but you should also probably add this:
$this->content = $content;
$this->languages = null;
$this->charsets = null;
$this->acceptableContentTypes = null;
$this->pathInfo = null;
$this->requestUri = null;
$this->baseUrl = null;
$this->basePath = null;
$this->method = null;
$this->format = null;
Can you send me a pull request?
Fabien
--
Fabien Potencier
Sensio CEO - Symfony lead developer
sensiolabs.com | symfony-project.org | fabien.potencier.org
Tél: +33 1 40 99 80 80
On 2/7/11 5:35 PM, Sven Paulus wrote:
When profiling a Symfony2 application displaying a CMS generated page of
medium complexity (leading to about 800 controller requests) we saw
quite a negative performance impact coming from
Symfony\Component\HttpFoundation\Request::initialize(), especially since
$this->server->getHeaders() is called every time.
I made the following modification to the duplicate() method, for me
everything seems fine (and faster), but I don't know if there are any
side effects which I might have missed:
public function duplicate(array $query = null, array $request = null,
array $attributes = null, array $cookies = null, array $files = null,
array $server = null)
{
$dup = clone $this;
- $dup->initialize(
- null !== $query ? $query : $this->query->all(),
- null !== $request ? $request : $this->request->all(),
- null !== $attributes ? $attributes : $this->attributes->all(),
- null !== $cookies ? $cookies : $this->cookies->all(),
- null !== $files ? $files : $this->files->all(),
- null !== $server ? $server : $this->server->all()
- );
+ if ($query !== null) {
+ $dup->query = new ParameterBag($query);
+ }
+ if ($request !== null) {
+ $dup->request = new ParameterBag($request);
+ }
+ if ($attributes !== null) {
+ $dup->attributes = new ParameterBag($attributes);
+ }
+ if ($cookies !== null) {
+ $dup->cookies = new ParameterBag($cookies);
+ }
+ if ($files !== null) {
+ $dup->files = new FileBag($files);
+ }
+ if ($server !== null) {
+ $dup->server = new ServerBag($server);
+ }
return $dup;
}
Using initialize() after clone() overwrote all of the cloned members, so
there was no real benefit from cloning?!
Regards,
Sven
--
If you want to report a vulnerability issue on symfony, please send it
to security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en