mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Added Configure option Asset.timestamp = 'force', to force asset timestamps in production mode, fixes #921
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6461 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
d301d7a566
commit
0073683a54
4 changed files with 25 additions and 2 deletions
|
@ -350,7 +350,7 @@ class HtmlHelper extends AppHelper {
|
|||
if (strpos($path, '.css') === false) {
|
||||
$path .= '.css';
|
||||
}
|
||||
if (Configure::read('Asset.timestamp') == true && Configure::read() > 0) {
|
||||
if ((Configure::read('Asset.timestamp') === true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') {
|
||||
$path .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $path));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ class JavascriptHelper extends AppHelper {
|
|||
if (strpos($url, '.js') === false) {
|
||||
$url .= '.js';
|
||||
}
|
||||
if (Configure::read('Asset.timestamp') == true && Configure::read() > 0) {
|
||||
if ((Configure::read('Asset.timestamp') === true && Configure::read() > 0) || Configure::read('Asset.timestamp') === 'force') {
|
||||
$url .= '?' . @filemtime(WWW_ROOT . str_replace('/', DS, $url));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,18 @@ class HtmlHelperTest extends UnitTestCase {
|
|||
Configure::write('Asset.timestamp', true);
|
||||
$result = $this->Html->css('cake.generic');
|
||||
$this->assertPattern('/^<link[^<>]+href=".*css\/cake\.generic\.css\?[0-9]+"[^<>]+\/>$/', $result);
|
||||
|
||||
$debug = Configure::read('debug');
|
||||
Configure::write('debug', 0);
|
||||
$result = $this->Html->css('cake.generic');
|
||||
$this->assertPattern('/^<link[^<>]+href=".*css\/cake\.generic\.css"[^<>]+\/>$/', $result);
|
||||
|
||||
Configure::write('Asset.timestamp', 'force');
|
||||
$result = $this->Html->css('cake.generic');
|
||||
$this->assertPattern('/^<link[^<>]+href=".*css\/cake\.generic\.css\?[0-9]+"[^<>]+\/>$/', $result);
|
||||
|
||||
Configure::write('Asset.timestamp', false);
|
||||
Configure::write('debug', $debug);
|
||||
|
||||
Configure::write('Asset.filter.css', 'css.php');
|
||||
$result = $this->Html->css('cake.generic');
|
||||
|
|
|
@ -74,6 +74,18 @@ class JavascriptTest extends UnitTestCase {
|
|||
Configure::write('Asset.timestamp', true);
|
||||
$result = $this->Javascript->link('jquery-1.1.2');
|
||||
$this->assertPattern('/^<script[^<>]+src=".*js\/jquery-1\.1\.2\.js\?"[^<>]*>/', $result);
|
||||
|
||||
$debug = Configure::read('debug');
|
||||
Configure::write('debug', 0);
|
||||
$result = $this->Javascript->link('jquery-1.1.2');
|
||||
$expected = '<script type="text/javascript" src="js/jquery-1.1.2.js"></script>';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
Configure::write('Asset.timestamp', 'force');
|
||||
$result = $this->Javascript->link('jquery-1.1.2');
|
||||
$this->assertPattern('/^<script[^<>]+src=".*js\/jquery-1\.1\.2\.js\?"[^<>]*>/', $result);
|
||||
|
||||
Configure::write('debug', $debug);
|
||||
Configure::write('Asset.timestamp', false);
|
||||
|
||||
Configure::write('Asset.filter.js', 'js.php');
|
||||
|
|
Loading…
Add table
Reference in a new issue