Merge branch '2.3' into 2.7

* 2.3:
  bumped Symfony version to 2.3.40
  set s-maxage only if all responses are cacheable
  updated VERSION for 2.3.39
  update CONTRIBUTORS for 2.3.39
  updated CHANGELOG for 2.3.39
  Improved the "branch" row of the PR table
  Fix typos #18090 1. PHPs session design to PHP's session design 2. Symfony HttpKernel offers to Symfony's HttpKernel offers 3. in which case it it should to in which case it should
  Fix for Isssue #18091
  replace perfom by perform
  minor #18088 Fix typo for profiler
This commit is contained in:
Fabien Potencier 2016-03-15 07:08:00 +01:00
commit fef2474d4e
6 changed files with 145 additions and 23 deletions

View File

@ -1,6 +1,6 @@
| Q | A | Q | A
| ------------- | --- | ------------- | ---
| Branch | master for features and deprecations / lowest applicable and maintained version otherwise | Branch? | "master" for new features / 2.3, 2.7, 2.8 or 3.0 for fixes
| Bug fix? | yes/no | Bug fix? | yes/no
| New feature? | yes/no | New feature? | yes/no
| BC breaks? | yes/no | BC breaks? | yes/no

View File

@ -7,6 +7,31 @@ in 2.3 minor versions.
To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash To get the diff for a specific change, go to https://github.com/symfony/symfony/commit/XXX where XXX is the change hash
To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1 To get the diff between two versions, go to https://github.com/symfony/symfony/compare/v2.3.0...v2.3.1
* 2.3.39 (2016-03-13)
* bug #18080 [HttpFoundation] Set the Content-Range header if the requested Range is unsatisfied (jakzal)
* bug #18084 [HttpFoundation] Avoid warnings when checking malicious IPs (jakzal)
* bug #18048 [HttpKernel] Fix mem usage when stripping the prod container (nicolas-grekas)
* bug #18065 [Finder] Partially revert #17134 to fix a regression (jakzal)
* bug #18018 [HttpFoundation] exception when registering bags for started sessions (xabbuh)
* bug #18054 [Filesystem] Fix false positive in ->remove() (nicolas-grekas)
* bug #18049 [Validator] Fix the locale validator so it treats a locale alias as a valid locale (jakzal)
* bug #18019 [Intl] Update ICU to version 55 (jakzal)
* bug #16656 [HttpFoundation] automatically generate safe fallback filename (xabbuh)
* bug #15794 [Console] default to stderr in the console helpers (alcohol)
* bug #17984 Allow to normalize \Traversable when serializing xml (Ener-Getick)
* bug #17434 Improved the error message when a template is not found (rvanginneken, javiereguiluz)
* bug #17894 [FrameworkBundle] Fix a regression in handling absolute template paths (jakzal)
* bug #17595 [HttpKernel] Remove _path from query parameters when fragment is a subrequest (cmenning)
* bug #17986 [DomCrawler] Dont use LIBXML_PARSEHUGE by default (nicolas-grekas)
* bug #17668 add 'guid' to list of exception to filter out (garak)
* bug #17615 Ensure backend slashes for symlinks on Windows systems (cpsitgmbh)
* bug #17626 Try to delete broken symlinks (IchHabRecht)
* bug #17978 [Yaml] ensure dump indentation to be greather than zero (xabbuh)
* bug #17976 [WebProfilerBundle] fix debug toolbar rendering by removing inadvertently added links (craue)
* bug #17971 Variadic controller params (NiR-, fabpot)
* bug #17925 [Bridge] The WebProcessor now forwards the client IP (magnetik)
* 2.3.38 (2016-02-28) * 2.3.38 (2016-02-28)
* bug #17947 Fix - #17676 (backport #17919 to 2.3) (Ocramius) * bug #17947 Fix - #17676 (backport #17919 to 2.3) (Ocramius)

View File

@ -16,8 +16,8 @@ Symfony is the result of the work of many people who made the code better
- Kris Wallsmith (kriswallsmith) - Kris Wallsmith (kriswallsmith)
- Jakub Zalas (jakubzalas) - Jakub Zalas (jakubzalas)
- Ryan Weaver (weaverryan) - Ryan Weaver (weaverryan)
- Hugo Hamon (hhamon)
- Javier Eguiluz (javier.eguiluz) - Javier Eguiluz (javier.eguiluz)
- Hugo Hamon (hhamon)
- Abdellatif Ait boudad (aitboudad) - Abdellatif Ait boudad (aitboudad)
- Pascal Borreli (pborreli) - Pascal Borreli (pborreli)
- Kévin Dunglas (dunglas) - Kévin Dunglas (dunglas)
@ -35,8 +35,8 @@ Symfony is the result of the work of many people who made the code better
- Eriksen Costa (eriksencosta) - Eriksen Costa (eriksencosta)
- Sarah Khalil (saro0h) - Sarah Khalil (saro0h)
- Jonathan Wage (jwage) - Jonathan Wage (jwage)
- Maxime Steinhausser (ogizanagi)
- Diego Saint Esteben (dosten) - Diego Saint Esteben (dosten)
- Maxime Steinhausser (ogizanagi)
- Alexandre Salomé (alexandresalome) - Alexandre Salomé (alexandresalome)
- William Durand (couac) - William Durand (couac)
- ornicar - ornicar
@ -56,12 +56,12 @@ Symfony is the result of the work of many people who made the code better
- Michel Weimerskirch (mweimerskirch) - Michel Weimerskirch (mweimerskirch)
- Eric Clemmons (ericclemmons) - Eric Clemmons (ericclemmons)
- Andrej Hudec (pulzarraider) - Andrej Hudec (pulzarraider)
- Christian Raue
- Matthias Pigulla (mpdude) - Matthias Pigulla (mpdude)
- Peter Rehm (rpet) - Peter Rehm (rpet)
- Deni - Deni
- Henrik Westphal (snc) - Henrik Westphal (snc)
- Dariusz Górecki (canni) - Dariusz Górecki (canni)
- Christian Raue
- Arnout Boks (aboks) - Arnout Boks (aboks)
- Douglas Greenshields (shieldo) - Douglas Greenshields (shieldo)
- Lee McDermott - Lee McDermott
@ -79,16 +79,18 @@ Symfony is the result of the work of many people who made the code better
- Iltar van der Berg (kjarli) - Iltar van der Berg (kjarli)
- Arnaud Le Blanc (arnaud-lb) - Arnaud Le Blanc (arnaud-lb)
- Jérôme Tamarelle (gromnan) - Jérôme Tamarelle (gromnan)
- Jules Pietri (heah)
- Michal Piotrowski (eventhorizon) - Michal Piotrowski (eventhorizon)
- Tim Nagel (merk) - Tim Nagel (merk)
- Paráda József (paradajozsef)
- Brice BERNARD (brikou) - Brice BERNARD (brikou)
- Ener-Getick (energetick)
- Charles Sarrazin (csarrazi) - Charles Sarrazin (csarrazi)
- Alexander M. Turek (derrabus) - Alexander M. Turek (derrabus)
- Dariusz Ruminski - Dariusz Ruminski
- marc.weistroff - marc.weistroff
- lenar - lenar
- Włodzimierz Gajda (gajdaw) - Włodzimierz Gajda (gajdaw)
- Paráda József (paradajozsef)
- Alexander Schwenn (xelaris) - Alexander Schwenn (xelaris)
- Florian Voutzinos (florianv) - Florian Voutzinos (florianv)
- Colin Frei - Colin Frei
@ -98,13 +100,12 @@ Symfony is the result of the work of many people who made the code better
- Peter Kokot (maastermedia) - Peter Kokot (maastermedia)
- excelwebzone - excelwebzone
- Jacob Dreesen (jdreesen) - Jacob Dreesen (jdreesen)
- Konstantin Myakshin (koc)
- Jérémy DERUSSÉ (jderusse) - Jérémy DERUSSÉ (jderusse)
- Vladimir Reznichenko (kalessil) - Vladimir Reznichenko (kalessil)
- Baptiste Clavié (talus) - Baptiste Clavié (talus)
- Ener-Getick (energetick)
- Fabien Pennequin (fabienpennequin) - Fabien Pennequin (fabienpennequin)
- Gordon Franke (gimler) - Gordon Franke (gimler)
- Konstantin Myakshin (koc)
- Tomáš Votruba (tomas_votruba) - Tomáš Votruba (tomas_votruba)
- Jáchym Toušek - Jáchym Toušek
- Robert Schönthal (digitalkaoz) - Robert Schönthal (digitalkaoz)
@ -117,7 +118,6 @@ Symfony is the result of the work of many people who made the code better
- Sebastian Hörl (blogsh) - Sebastian Hörl (blogsh)
- Daniel Gomes (danielcsgomes) - Daniel Gomes (danielcsgomes)
- Hidenori Goto (hidenorigoto) - Hidenori Goto (hidenorigoto)
- Jules Pietri (heah)
- Evgeniy (ewgraf) - Evgeniy (ewgraf)
- Guilherme Blanco (guilhermeblanco) - Guilherme Blanco (guilhermeblanco)
- Pablo Godel (pgodel) - Pablo Godel (pgodel)
@ -146,6 +146,8 @@ Symfony is the result of the work of many people who made the code better
- Dmitrii Chekaliuk (lazyhammer) - Dmitrii Chekaliuk (lazyhammer)
- Clément JOBEILI (dator) - Clément JOBEILI (dator)
- Daniel Wehner - Daniel Wehner
- Richard van Laak (rvanlaak)
- Possum
- Dorian Villet (gnutix) - Dorian Villet (gnutix)
- Javier Spagnoletti (phansys) - Javier Spagnoletti (phansys)
- Richard Miller (mr_r_miller) - Richard Miller (mr_r_miller)
@ -154,11 +156,10 @@ Symfony is the result of the work of many people who made the code better
- Benjamin Dulau (dbenjamin) - Benjamin Dulau (dbenjamin)
- Andreas Hucks (meandmymonkey) - Andreas Hucks (meandmymonkey)
- Noel Guilbert (noel) - Noel Guilbert (noel)
- Richard van Laak (rvanlaak) - Stepan Anchugov (kix)
- bronze1man - bronze1man
- sun (sun) - sun (sun)
- Larry Garfield (crell) - Larry Garfield (crell)
- Possum
- Martin Schuhfuß (usefulthink) - Martin Schuhfuß (usefulthink)
- Matthieu Bontemps (mbontemps) - Matthieu Bontemps (mbontemps)
- Pierre Minnieur (pminnieur) - Pierre Minnieur (pminnieur)
@ -177,7 +178,6 @@ Symfony is the result of the work of many people who made the code better
- Sven Paulus (subsven) - Sven Paulus (subsven)
- Lars Strojny (lstrojny) - Lars Strojny (lstrojny)
- Rui Marinho (ruimarinho) - Rui Marinho (ruimarinho)
- Stepan Anchugov (kix)
- Eugene Wissner - Eugene Wissner
- Julien Brochet (mewt) - Julien Brochet (mewt)
- Sergey Linnik (linniksa) - Sergey Linnik (linniksa)
@ -186,6 +186,7 @@ Symfony is the result of the work of many people who made the code better
- Titouan Galopin (tgalopin) - Titouan Galopin (tgalopin)
- Loïc Faugeron - Loïc Faugeron
- Jannik Zschiesche (apfelbox) - Jannik Zschiesche (apfelbox)
- Marco Pivetta (ocramius)
- julien pauli (jpauli) - julien pauli (jpauli)
- Michael Lee (zerustech) - Michael Lee (zerustech)
- Lorenz Schori - Lorenz Schori
@ -265,11 +266,11 @@ Symfony is the result of the work of many people who made the code better
- Bob den Otter (bopp) - Bob den Otter (bopp)
- Adrian Rudnik (kreischweide) - Adrian Rudnik (kreischweide)
- Francesc Rosàs (frosas) - Francesc Rosàs (frosas)
- Massimiliano Arione (garak)
- Julien Galenski (ruian) - Julien Galenski (ruian)
- Bongiraud Dominique - Bongiraud Dominique
- janschoenherr - janschoenherr
- Thomas Schulz (king2500) - Thomas Schulz (king2500)
- Marco Pivetta (ocramius)
- Berny Cantos (xphere81) - Berny Cantos (xphere81)
- Ricard Clau (ricardclau) - Ricard Clau (ricardclau)
- Mark Challoner (markchalloner) - Mark Challoner (markchalloner)
@ -314,6 +315,7 @@ Symfony is the result of the work of many people who made the code better
- Endre Fejes - Endre Fejes
- Tobias Naumann (tna) - Tobias Naumann (tna)
- Shein Alexey - Shein Alexey
- Baptiste Lafontaine
- Joe Lencioni - Joe Lencioni
- Daniel Tschinder - Daniel Tschinder
- Kai - Kai
@ -336,7 +338,6 @@ Symfony is the result of the work of many people who made the code better
- Oscar Cubo Medina (ocubom) - Oscar Cubo Medina (ocubom)
- Karel Souffriau - Karel Souffriau
- Christophe L. (christophelau) - Christophe L. (christophelau)
- Massimiliano Arione (garak)
- Anthon Pang (robocoder) - Anthon Pang (robocoder)
- Emanuele Gaspari (inmarelibero) - Emanuele Gaspari (inmarelibero)
- Dariusz Rumiński - Dariusz Rumiński
@ -388,6 +389,7 @@ Symfony is the result of the work of many people who made the code better
- Roman Lapin (memphys) - Roman Lapin (memphys)
- Yoshio HANAWA - Yoshio HANAWA
- Gladhon - Gladhon
- Benoît Burnichon (bburnichon)
- Sebastian Bergmann - Sebastian Bergmann
- Pablo Díez (pablodip) - Pablo Díez (pablodip)
- Kevin McBride - Kevin McBride
@ -397,6 +399,7 @@ Symfony is the result of the work of many people who made the code better
- Ilya Antipenko (aivus) - Ilya Antipenko (aivus)
- Iker Ibarguren (ikerib) - Iker Ibarguren (ikerib)
- Ricardo Oliveira (ricardolotr) - Ricardo Oliveira (ricardolotr)
- Roy Van Ginneken (rvanginneken)
- ondrowan - ondrowan
- Barry vd. Heuvel (barryvdh) - Barry vd. Heuvel (barryvdh)
- Jerzy Zawadzki (jzawadzki) - Jerzy Zawadzki (jzawadzki)
@ -458,7 +461,6 @@ Symfony is the result of the work of many people who made the code better
- Johnny Robeson (johnny) - Johnny Robeson (johnny)
- Disquedur - Disquedur
- Michiel Boeckaert (milio) - Michiel Boeckaert (milio)
- Baptiste Lafontaine
- Geoffrey Tran (geoff) - Geoffrey Tran (geoff)
- Jan Behrens - Jan Behrens
- Mantas Var (mvar) - Mantas Var (mvar)
@ -514,6 +516,7 @@ Symfony is the result of the work of many people who made the code better
- Luc Vieillescazes (iamluc) - Luc Vieillescazes (iamluc)
- Johann Saunier (prophet777) - Johann Saunier (prophet777)
- Antoine Corcy - Antoine Corcy
- Rob Bast
- Artur Eshenbrener - Artur Eshenbrener
- Arturs Vonda - Arturs Vonda
- Sascha Grossenbacher - Sascha Grossenbacher
@ -522,6 +525,7 @@ Symfony is the result of the work of many people who made the code better
- Benjamin Zikarsky (bzikarsky) - Benjamin Zikarsky (bzikarsky)
- Simon Schick (simonsimcity) - Simon Schick (simonsimcity)
- redstar504 - redstar504
- Tristan Roussel
- Hossein Bukhamsin - Hossein Bukhamsin
- Disparity - Disparity
- origaminal - origaminal
@ -615,7 +619,6 @@ Symfony is the result of the work of many people who made the code better
- Emanuele Iannone - Emanuele Iannone
- Tony Malzhacker - Tony Malzhacker
- Mathieu MARCHOIS - Mathieu MARCHOIS
- Benoît Burnichon (bburnichon)
- Cyril Quintin (cyqui) - Cyril Quintin (cyqui)
- Gerard van Helden (drm) - Gerard van Helden (drm)
- Johnny Peck (johnnypeck) - Johnny Peck (johnnypeck)
@ -719,17 +722,20 @@ Symfony is the result of the work of many people who made the code better
- Danilo Silva - Danilo Silva
- Zachary Tong (polyfractal) - Zachary Tong (polyfractal)
- Hryhorii Hrebiniuk - Hryhorii Hrebiniuk
- mcfedr (mcfedr)
- dantleech - dantleech
- Xavier Leune - Xavier Leune
- Tero Alén (tero) - Tero Alén (tero)
- DerManoMann - DerManoMann
- Guillaume Royer - Guillaume Royer
- Artem (digi) - Artem (digi)
- boite
- dantleech - dantleech
- Vadim Tyukov (vatson) - Vadim Tyukov (vatson)
- Sortex - Sortex
- chispita - chispita
- Wojciech Sznapka - Wojciech Sznapka
- Arjan Keeman
- Máximo Cuadros (mcuadros) - Máximo Cuadros (mcuadros)
- tamirvs - tamirvs
- julien.galenski - julien.galenski
@ -807,7 +813,6 @@ Symfony is the result of the work of many people who made the code better
- spdionis - spdionis
- Eduardo García Sanz (coma) - Eduardo García Sanz (coma)
- James Gilliland - James Gilliland
- Roy Van Ginneken
- David de Boer (ddeboer) - David de Boer (ddeboer)
- Gilles Doge (gido) - Gilles Doge (gido)
- abulford - abulford
@ -869,6 +874,7 @@ Symfony is the result of the work of many people who made the code better
- Ludek Stepan - Ludek Stepan
- Geoffrey Brier - Geoffrey Brier
- Aaron Stephens (astephens) - Aaron Stephens (astephens)
- Craig Menning (cmenning)
- Balázs Benyó (duplabe) - Balázs Benyó (duplabe)
- Erika Heidi Reinaldo (erikaheidi) - Erika Heidi Reinaldo (erikaheidi)
- Pierre Tachoire (krichprollsch) - Pierre Tachoire (krichprollsch)
@ -881,6 +887,7 @@ Symfony is the result of the work of many people who made the code better
- Karol Sójko (karolsojko) - Karol Sójko (karolsojko)
- sl_toto (sl_toto) - sl_toto (sl_toto)
- Walter Dal Mut (wdalmut) - Walter Dal Mut (wdalmut)
- Albin Kerouaton
- Sébastien HOUZÉ - Sébastien HOUZÉ
- Jingyu Wang - Jingyu Wang
- Daniel Espendiller - Daniel Espendiller
@ -900,6 +907,7 @@ Symfony is the result of the work of many people who made the code better
- Daniel Richter (richtermeister) - Daniel Richter (richtermeister)
- ChrisC - ChrisC
- Ilya Biryukov - Ilya Biryukov
- Kim Laï Trinh
- Jason Desrosiers - Jason Desrosiers
- m.chwedziak - m.chwedziak
- Philip Frank - Philip Frank
@ -958,7 +966,6 @@ Symfony is the result of the work of many people who made the code better
- Jānis Lukss - Jānis Lukss
- rkerner - rkerner
- Alex Silcock - Alex Silcock
- Rob Bast
- Matthew J Mucklo - Matthew J Mucklo
- fdgdfg (psampaz) - fdgdfg (psampaz)
- Stéphane Seng - Stéphane Seng
@ -1024,6 +1031,7 @@ Symfony is the result of the work of many people who made the code better
- Alexandre Segura - Alexandre Segura
- Josef Cech - Josef Cech
- Arnau González (arnaugm) - Arnau González (arnaugm)
- Simon Bouland (bouland)
- Nate (frickenate) - Nate (frickenate)
- Matthew Foster (mfoster) - Matthew Foster (mfoster)
- Paul Seiffert (seiffert) - Paul Seiffert (seiffert)
@ -1087,16 +1095,20 @@ Symfony is the result of the work of many people who made the code better
- Jordi Llonch (jordillonch) - Jordi Llonch (jordillonch)
- Cédric Dugat (ph3nol) - Cédric Dugat (ph3nol)
- Philip Dahlstrøm (phidah) - Philip Dahlstrøm (phidah)
- Alex Rock Ancelet (pierstoval)
- Milos Colakovic (project2481) - Milos Colakovic (project2481)
- Rénald Casagraude (rcasagraude) - Rénald Casagraude (rcasagraude)
- Robin Duval (robin-duval) - Robin Duval (robin-duval)
- Grinbergs Reinis (shima5) - Grinbergs Reinis (shima5)
- Artem Lopata (bumz) - Artem Lopata (bumz)
- Nicole Cordes
- Alexey Popkov - Alexey Popkov
- Artyom Protaskin - Artyom Protaskin
- Nathanael d. Noblet - Nathanael d. Noblet
- helmer - helmer
- ged15
- Daan van Renterghem - Daan van Renterghem
- Nicole Cordes
- Bram Van der Sype (brammm) - Bram Van der Sype (brammm)
- Julien Moulin (lizjulien) - Julien Moulin (lizjulien)
- Nikita Nefedov (nikita2206) - Nikita Nefedov (nikita2206)
@ -1316,7 +1328,6 @@ Symfony is the result of the work of many people who made the code better
- Sema - Sema
- Elan Ruusamäe - Elan Ruusamäe
- Thorsten Hallwas - Thorsten Hallwas
- Tristan Roussel
- Michael Squires - Michael Squires
- Norman Soetbeer - Norman Soetbeer
- zorn - zorn
@ -1399,6 +1410,7 @@ Symfony is the result of the work of many people who made the code better
- Ala Eddine Khefifi (nayzo) - Ala Eddine Khefifi (nayzo)
- emilienbouard (neime) - emilienbouard (neime)
- Nicholas Byfleet (nickbyfleet) - Nicholas Byfleet (nickbyfleet)
- Tomas Norkūnas (norkunas)
- ollie harridge (ollietb) - ollie harridge (ollietb)
- Paul Andrieux (paulandrieux) - Paul Andrieux (paulandrieux)
- Paweł Szczepanek (pauluz) - Paweł Szczepanek (pauluz)

View File

@ -76,10 +76,10 @@ interface SessionStorageInterface
* Note regenerate+destroy should not clear the session data in memory * Note regenerate+destroy should not clear the session data in memory
* only delete the session data from persistent storage. * only delete the session data from persistent storage.
* *
* Care: When regenerating the session ID no locking is involved in PHPs * Care: When regenerating the session ID no locking is involved in PHP's
* session design. See https://bugs.php.net/bug.php?id=61470 for a discussion. * session design. See https://bugs.php.net/bug.php?id=61470 for a discussion.
* So you must make sure the regenerated session is saved BEFORE sending the * So you must make sure the regenerated session is saved BEFORE sending the
* headers with the new ID. Symfonys HttpKernel offers a listener for this. * headers with the new ID. Symfony's HttpKernel offers a listener for this.
* See Symfony\Component\HttpKernel\EventListener\SaveSessionListener. * See Symfony\Component\HttpKernel\EventListener\SaveSessionListener.
* Otherwise session data could get lost again for concurrent requests with the * Otherwise session data could get lost again for concurrent requests with the
* new ID. One result could be that you get logged out after just logging in. * new ID. One result could be that you get logged out after just logging in.
@ -101,7 +101,7 @@ interface SessionStorageInterface
* *
* This method must invoke session_write_close() unless this interface is * This method must invoke session_write_close() unless this interface is
* used for a storage object design for unit or functional testing where * used for a storage object design for unit or functional testing where
* a real PHP session would interfere with testing, in which case it * a real PHP session would interfere with testing, in which case
* it should actually persist the session data if required. * it should actually persist the session data if required.
* *
* @throws \RuntimeException If the session is saved without being started, or if the session * @throws \RuntimeException If the session is saved without being started, or if the session

View File

@ -32,6 +32,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
private $embeddedResponses = 0; private $embeddedResponses = 0;
private $ttls = array(); private $ttls = array();
private $maxAges = array(); private $maxAges = array();
private $isNotCacheableResponseEmbedded = false;
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -41,8 +42,13 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
if ($response->isValidateable()) { if ($response->isValidateable()) {
$this->cacheable = false; $this->cacheable = false;
} else { } else {
$maxAge = $response->getMaxAge();
$this->ttls[] = $response->getTtl(); $this->ttls[] = $response->getTtl();
$this->maxAges[] = $response->getMaxAge(); $this->maxAges[] = $maxAge;
if (null === $maxAge) {
$this->isNotCacheableResponseEmbedded = true;
}
} }
++$this->embeddedResponses; ++$this->embeddedResponses;
@ -76,7 +82,9 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
$this->ttls[] = $response->getTtl(); $this->ttls[] = $response->getTtl();
$this->maxAges[] = $response->getMaxAge(); $this->maxAges[] = $response->getMaxAge();
if (null !== $maxAge = min($this->maxAges)) { if ($this->isNotCacheableResponseEmbedded) {
$response->headers->removeCacheControlDirective('s-maxage');
} elseif (null !== $maxAge = min($this->maxAges)) {
$response->setSharedMaxAge($maxAge); $response->setSharedMaxAge($maxAge);
$response->headers->set('Age', $maxAge - min($this->ttls)); $response->headers->set('Age', $maxAge - min($this->ttls));
} }

View File

@ -0,0 +1,77 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This code is partially based on the Rack-Cache library by Ryan Tomayko,
* which is released under the MIT license.
* (based on commit 02d2b48d75bcb63cf1c0c7149c077ad256542801)
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\HttpKernel\Tests\HttpCache;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpCache\EsiResponseCacheStrategy;
class EsiResponseCacheStrategyTest extends \PHPUnit_Framework_TestCase
{
public function testMinimumSharedMaxAgeWins()
{
$cacheStrategy = new EsiResponseCacheStrategy();
$response1 = new Response();
$response1->setSharedMaxAge(60);
$cacheStrategy->add($response1);
$response2 = new Response();
$response2->setSharedMaxAge(3600);
$cacheStrategy->add($response2);
$response = new Response();
$response->setSharedMaxAge(86400);
$cacheStrategy->update($response);
$this->assertSame('60', $response->headers->getCacheControlDirective('s-maxage'));
}
public function testSharedMaxAgeNotSetIfNotSetInAnyEmbeddedRequest()
{
$cacheStrategy = new EsiResponseCacheStrategy();
$response1 = new Response();
$response1->setSharedMaxAge(60);
$cacheStrategy->add($response1);
$response2 = new Response();
$cacheStrategy->add($response2);
$response = new Response();
$response->setSharedMaxAge(86400);
$cacheStrategy->update($response);
$this->assertFalse($response->headers->hasCacheControlDirective('s-maxage'));
}
public function testSharedMaxAgeNotSetIfNotSetInMasterRequest()
{
$cacheStrategy = new EsiResponseCacheStrategy();
$response1 = new Response();
$response1->setSharedMaxAge(60);
$cacheStrategy->add($response1);
$response2 = new Response();
$response2->setSharedMaxAge(3600);
$cacheStrategy->add($response2);
$response = new Response();
$cacheStrategy->update($response);
$this->assertFalse($response->headers->hasCacheControlDirective('s-maxage'));
}
}