Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Disabling caching of JS files by default. Requiring webroot to be

writable by default it not a good idea.
  • Loading branch information...
commit f15b793a4a35259af965222b92785d66034acc66 1 parent 0bd3cc9
@markstory markstory authored
View
4 cake/libs/view/helpers/js.php
@@ -122,7 +122,7 @@ function call__($method, $params) {
*
* - 'inline' - Set to true to have scripts output as a script block inline
* if 'cache' is also true, a script link tag will be generated. (default true)
- * - 'cache' - Set to true to have scripts cached to a file and linked in (default true)
+ * - 'cache' - Set to true to have scripts cached to a file and linked in (default false)
* - 'clear' - Set to false to prevent script cache from being cleared (default true)
* - 'onDomReady' - wrap cached scripts in domready event (default true)
* - 'safe' - if an inline block is generated should it be wrapped in <![CDATA[ ... ]]> (default true)
@@ -131,7 +131,7 @@ function call__($method, $params) {
* @return string completed javascript tag.
**/
function writeScripts($options = array()) {
- $defaults = array('onDomReady' => true, 'inline' => true, 'cache' => true, 'clear' => true, 'safe' => true);
+ $defaults = array('onDomReady' => true, 'inline' => true, 'cache' => false, 'clear' => true, 'safe' => true);
$options = array_merge($defaults, $options);
$script = implode("\n", $this->getCache($options['clear']));
View
4 cake/tests/cases/libs/view/helpers/js.test.php
@@ -171,7 +171,7 @@ function testWriteScriptsInFile() {
$this->Js->JsBaseEngine = new TestJsEngineHelper();
$this->Js->writeCache('one = 1;');
$this->Js->writeCache('two = 2;');
- $result = $this->Js->writeScripts(array('onDomReady' => false));
+ $result = $this->Js->writeScripts(array('onDomReady' => false, 'cache' => true));
$expected = array(
'script' => array('type' => 'text/javascript', 'src' => 'preg:/(.)*\.js/'),
);
@@ -180,6 +180,8 @@ function testWriteScriptsInFile() {
$this->assertTrue(file_exists(WWW_ROOT . $filename[1]));
$contents = file_get_contents(WWW_ROOT . $filename[1]);
$this->assertPattern('/one\s=\s1;\ntwo\s=\s2;/', $contents);
+
+ @unlink(WWW_ROOT . $filename[1]);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.