diff --git a/administrator/components/com_languages/controllers/override.php b/administrator/components/com_languages/controllers/override.php index 950284e448c84..d16cf3d0774fc 100644 --- a/administrator/components/com_languages/controllers/override.php +++ b/administrator/components/com_languages/controllers/override.php @@ -28,6 +28,9 @@ class LanguagesControllerOverride extends JControllerForm */ public function edit($key = null, $urlVar = null) { + // Do not cache the response to this, its a redirect + JFactory::getApplication()->allowCache(false); + $app = JFactory::getApplication(); $cid = $this->input->post->get('cid', array(), 'array'); $context = "$this->option.edit.$this->context"; diff --git a/libraries/joomla/application/web.php b/libraries/joomla/application/web.php index 0fae9c7d56bb1..6a3084f48e966 100644 --- a/libraries/joomla/application/web.php +++ b/libraries/joomla/application/web.php @@ -567,11 +567,13 @@ public function redirect($url, $status = 303) // All other cases use the more efficient HTTP header for redirection. $this->header($this->responseMap[$status]); $this->header('Location: ' . $url); - $this->header('Content-Type: text/html; charset=' . $this->charSet); } } - // Close the application after the redirect. + // Set appropriate headers + $this->respond(); + + // Close the application after the redirect. $this->close(); } diff --git a/libraries/legacy/controller/form.php b/libraries/legacy/controller/form.php index 058acb2abbaa4..641da1f313995 100644 --- a/libraries/legacy/controller/form.php +++ b/libraries/legacy/controller/form.php @@ -359,6 +359,9 @@ public function cancel($key = null) */ public function edit($key = null, $urlVar = null) { + // Do not cache the response to this, its a redirect, and mod_expires and google chrome browser bugs cache it forever! + JFactory::getApplication()->allowCache(false); + $model = $this->getModel(); $table = $model->getTable(); $cid = $this->input->post->get('cid', array(), 'array'); diff --git a/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php b/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php index 341777f2ef6e9..7488b94137335 100644 --- a/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php +++ b/tests/unit/suites/libraries/cms/application/JApplicationCmsTest.php @@ -432,12 +432,32 @@ public function testRedirect() $this->class->redirect($url, false); $this->assertEquals( - array( - array('HTTP/1.1 303 See other', true, null), - array('Location: ' . $base . $url, true, null), - array('Content-Type: text/html; charset=utf-8', true, null), - ), - $this->class->headers + array('HTTP/1.1 303 See other', true, null), + $this->class->headers[0] + ); + + $this->assertEquals( + array('Location: ' . $base . $url, true, null), + $this->class->headers[1] + ); + + $this->assertEquals( + array('Content-Type: text/html; charset=utf-8', true, null), + $this->class->headers[2] + ); + + $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + + $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + + $this->assertEquals( + array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), + $this->class->headers[5] + ); + + $this->assertEquals( + array('Pragma: no-cache', true, null), + $this->class->headers[6] ); } @@ -481,12 +501,32 @@ public function testRedirectLegacy() ); $this->assertEquals( - array( - array('HTTP/1.1 303 See other', true, null), - array('Location: ' . $base . $url, true, null), - array('Content-Type: text/html; charset=utf-8', true, null), - ), - $this->class->headers + array('HTTP/1.1 303 See other', true, null), + $this->class->headers[0] + ); + + $this->assertEquals( + array('Location: ' . $base . $url, true, null), + $this->class->headers[1] + ); + + $this->assertEquals( + array('Content-Type: text/html; charset=utf-8', true, null), + $this->class->headers[2] + ); + + $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + + $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + + $this->assertEquals( + array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), + $this->class->headers[5] + ); + + $this->assertEquals( + array('Pragma: no-cache', true, null), + $this->class->headers[6] ); } @@ -526,12 +566,32 @@ public function testRedirectLegacyWithEmptyMessageAndEmptyStatus() // The redirect gives a 303 error code $this->assertEquals( - array( - array('HTTP/1.1 303 See other', true, null), - array('Location: ' . $base . $url, true, null), - array('Content-Type: text/html; charset=utf-8', true, null), - ), - $this->class->headers + array('HTTP/1.1 303 See other', true, null), + $this->class->headers[0] + ); + + $this->assertEquals( + array('Location: ' . $base . $url, true, null), + $this->class->headers[1] + ); + + $this->assertEquals( + array('Content-Type: text/html; charset=utf-8', true, null), + $this->class->headers[2] + ); + + $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + + $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + + $this->assertEquals( + array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), + $this->class->headers[5] + ); + + $this->assertEquals( + array('Pragma: no-cache', true, null), + $this->class->headers[6] ); } @@ -621,12 +681,32 @@ public function testRedirectWithMoved() $this->class->redirect($url, true); $this->assertEquals( - array( - array('HTTP/1.1 301 Moved Permanently', true, null), - array('Location: ' . $url, true, null), - array('Content-Type: text/html; charset=utf-8', true, null), - ), - $this->class->headers + array('HTTP/1.1 301 Moved Permanently', true, null), + $this->class->headers[0] + ); + + $this->assertEquals( + array('Location: ' . $url, true, null), + $this->class->headers[1] + ); + + $this->assertEquals( + array('Content-Type: text/html; charset=utf-8', true, null), + $this->class->headers[2] + ); + + $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + + $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + + $this->assertEquals( + array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), + $this->class->headers[5] + ); + + $this->assertEquals( + array('Pragma: no-cache', true, null), + $this->class->headers[6] ); } diff --git a/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php b/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php index 83435492c3791..ef1251f28a3a2 100644 --- a/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php +++ b/tests/unit/suites/libraries/joomla/application/JApplicationWebTest.php @@ -1086,12 +1086,32 @@ public function testRedirect() $this->class->redirect($url, false); $this->assertEquals( - array( - array('HTTP/1.1 303 See other', true, null), - array('Location: ' . $base . $url, true, null), - array('Content-Type: text/html; charset=utf-8', true, null), - ), - $this->class->headers + array('HTTP/1.1 303 See other', true, null), + $this->class->headers[0] + ); + + $this->assertEquals( + array('Location: ' . $base . $url, true, null), + $this->class->headers[1] + ); + + $this->assertEquals( + array('Content-Type: text/html; charset=utf-8', true, null), + $this->class->headers[2] + ); + + $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + + $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + + $this->assertEquals( + array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), + $this->class->headers[5] + ); + + $this->assertEquals( + array('Pragma: no-cache', true, null), + $this->class->headers[6] ); } @@ -1178,12 +1198,32 @@ public function testRedirectWithMoved() $this->class->redirect($url, true); $this->assertEquals( - array( - array('HTTP/1.1 301 Moved Permanently', true, null), - array('Location: ' . $url, true, null), - array('Content-Type: text/html; charset=utf-8', true, null), - ), - $this->class->headers + array('HTTP/1.1 301 Moved Permanently', true, null), + $this->class->headers[0] + ); + + $this->assertEquals( + array('Location: ' . $url, true, null), + $this->class->headers[1] + ); + + $this->assertEquals( + array('Content-Type: text/html; charset=utf-8', true, null), + $this->class->headers[2] + ); + + $this->assertRegexp('/Expires/',$this->class->headers[3][0]); + + $this->assertRegexp('/Last-Modified/',$this->class->headers[4][0]); + + $this->assertEquals( + array('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true, null), + $this->class->headers[5] + ); + + $this->assertEquals( + array('Pragma: no-cache', true, null), + $this->class->headers[6] ); }