diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 58c4f0539e4e..abf21d365cbd 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -380,7 +380,7 @@ public function request(string $method, string $uri, array $parameters = [], arr $uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri); } - if (!$this->history->isEmpty()) { + if (!isset($server['HTTP_REFERER']) && !$this->history->isEmpty()) { $server['HTTP_REFERER'] = $this->history->current()->getUri(); } diff --git a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php index 79d47bebe17e..25e76cb80168 100644 --- a/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php +++ b/src/Symfony/Component/BrowserKit/Tests/AbstractBrowserTest.php @@ -230,6 +230,15 @@ public function testRequestReferer() $this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer'); } + public function testRequestRefererCanBeOverridden() + { + $client = new TestClient(); + $client->request('GET', 'http://www.example.com/foo/foobar'); + $client->request('GET', 'bar', [], [], ['HTTP_REFERER' => 'xyz']); + $server = $client->getRequest()->getServer(); + $this->assertEquals('xyz', $server['HTTP_REFERER'], '->request() allows referer to be overridden'); + } + public function testRequestHistory() { $client = $this->getBrowser(); diff --git a/src/Symfony/Component/VarDumper/Caster/SplCaster.php b/src/Symfony/Component/VarDumper/Caster/SplCaster.php index ed19297a34f2..0bb773e07b3b 100644 --- a/src/Symfony/Component/VarDumper/Caster/SplCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/SplCaster.php @@ -175,6 +175,7 @@ public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $s { $storage = []; unset($a[Caster::PREFIX_DYNAMIC."\0gcdata"]); // Don't hit https://bugs.php.net/65967 + unset($a["\0SplObjectStorage\0storage"]); $clone = clone $c; foreach ($clone as $obj) {