From eeea19ee199f9afaf4d71de235ca054dff418485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pluchino?= Date: Mon, 3 Mar 2014 00:27:33 +0100 Subject: [PATCH 1/2] Fix the regression caused by the removal of double-stringification --- .../Component/HttpKernel/DataCollector/RequestDataCollector.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index cc366186fc0f8..050d8318c19e8 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -52,6 +52,8 @@ public function collect(Request $request, Response $response, \Exception $except foreach ($request->attributes->all() as $key => $value) { if ('_route' === $key && is_object($value)) { $value = $value->getPath(); + } elseif (is_object($value)) { + $value = $this->varToString($value); } $attributes[$key] = $value; From 023c3f84c52e3fdff50c7c796f1fd4a5d4aaf826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pluchino?= Date: Mon, 3 Mar 2014 11:47:07 +0100 Subject: [PATCH 2/2] Adds tests of regression for the removal of double-stringification --- .../RequestDataCollectorTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index bb80781ebeb56..240d9e931e71c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -144,6 +144,22 @@ function () { return 'foo'; }, } } + /** + * Test data collector serialisation. + * + * @dataProvider provider + */ + public function testDataCollectorSerialization(Request $request, Response $response) + { + if (class_exists('Symfony\Component\HttpFoundation\Session\Session') && class_exists('PDO')) { + $c = new RequestDataCollector(); + $c->collect($request, $response); + $this->assertContains('"Object(Symfony\Component\HttpFoundation\Session\Session)"', $c->serialize()); + } else { + $this->markTestSkipped('"Symfony\Component\HttpFoundation\Session\Session" or "PDO" class does not exists'); + } + } + public function provider() { if (!class_exists('Symfony\Component\HttpFoundation\Request')) { @@ -155,6 +171,15 @@ public function provider() $request->attributes->set('_route', 'foobar'); $request->attributes->set('_route_params', array('name' => 'foo')); + if (class_exists('Symfony\Component\HttpFoundation\Session\Session') && class_exists('PDO')) { + $pdo = new \PDO("sqlite::memory:"); + $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler($pdo, array('db_table' => 'sessions')); + $bridge = new \Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage($handler); + $session = new \Symfony\Component\HttpFoundation\Session\Session($bridge); + $request->attributes->set('session', $session); + } + $response = new Response(); $response->setStatusCode(200); $response->headers->set('Content-Type', 'application/json'); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy