diff --git a/cake/libs/view/helpers/cache.php b/cake/libs/view/helpers/cache.php index 1e388f802..917128e31 100644 --- a/cake/libs/view/helpers/cache.php +++ b/cake/libs/view/helpers/cache.php @@ -32,21 +32,19 @@ class CacheHelper extends AppHelper { /** * Array of strings replaced in cached views. - * The strings are found between in views + * The strings are found between `` in views * * @var array - * @access private */ - private $__replace = array(); + protected $_replace = array(); /** * Array of string that are replace with there var replace above. - * The strings are any content inside and includes the tags in views + * The strings are any content inside `` and includes the tags in views * * @var array - * @access private */ - private $__match = array(); + protected $_match = array(); /** * Parses the view file and stores content for cache file building. @@ -143,14 +141,14 @@ class CacheHelper extends AppHelper { } elseif ($file = fileExistsInPath($file)) { $file = file_get_contents($file); } - preg_match_all('/((?<=)[\\s\\S]*?(?=<\/cake:nocache>)<\/cake:nocache>)/i', $cache, $outputResult, PREG_PATTERN_ORDER); - preg_match_all('/(?<=)([\\s\\S]*?)(?=<\/cake:nocache>)/i', $file, $fileResult, PREG_PATTERN_ORDER); + preg_match_all('/((?<=)[\\s\\S]*?(?=))/i', $cache, $outputResult, PREG_PATTERN_ORDER); + preg_match_all('/(?<=)([\\s\\S]*?)(?=)/i', $file, $fileResult, PREG_PATTERN_ORDER); $fileResult = $fileResult[0]; $outputResult = $outputResult[0]; - if (!empty($this->__replace)) { + if (!empty($this->_replace)) { foreach ($outputResult as $i => $element) { - $index = array_search($element, $this->__match); + $index = array_search($element, $this->_match); if ($index !== false) { unset($outputResult[$i]); } @@ -162,8 +160,8 @@ class CacheHelper extends AppHelper { $i = 0; foreach ($fileResult as $cacheBlock) { if (isset($outputResult[$i])) { - $this->__replace[] = $cacheBlock; - $this->__match[] = $outputResult[$i]; + $this->_replace[] = $cacheBlock; + $this->_match[] = $outputResult[$i]; } $i++; } @@ -174,13 +172,13 @@ class CacheHelper extends AppHelper { * Parse the output and replace cache tags * * @param string $cache Output to replace content in. - * @return string with all replacements made to + * @return string with all replacements made to * @access private */ function __parseOutput($cache) { $count = 0; - if (!empty($this->__match)) { - foreach ($this->__match as $found) { + if (!empty($this->_match)) { + foreach ($this->_match as $found) { $original = $cache; $length = strlen($found); $position = 0; @@ -190,7 +188,7 @@ class CacheHelper extends AppHelper { if ($position !== false) { $cache = substr($original, 0, $position); - $cache .= $this->__replace[$count]; + $cache .= $this->_replace[$count]; $cache .= substr($original, $position + $length); } else { break; diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 43b74f852..698b7fe4d 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -418,7 +418,7 @@ class View extends Object { ); if ($isCached) { - $replace = array('', ''); + $replace = array('', ''); $this->output = str_replace($replace, '', $this->output); } } diff --git a/cake/tests/cases/libs/view/helpers/cache.test.php b/cake/tests/cases/libs/view/helpers/cache.test.php index dc24ec5a1..95d8e9a01 100644 --- a/cake/tests/cases/libs/view/helpers/cache.test.php +++ b/cake/tests/cases/libs/view/helpers/cache.test.php @@ -198,7 +198,7 @@ class CacheHelperTest extends CakeTestCase { } /** - * test that multiple tags function with multiple nocache tags in the layout. + * test that multiple tags function with multiple nocache tags in the layout. * * @return void */ diff --git a/cake/tests/test_app/views/elements/nocache/contains_nocache.ctp b/cake/tests/test_app/views/elements/nocache/contains_nocache.ctp index 588197e03..d44550ecc 100644 --- a/cake/tests/test_app/views/elements/nocache/contains_nocache.ctp +++ b/cake/tests/test_app/views/elements/nocache/contains_nocache.ctp @@ -1,5 +1,5 @@

Cache Me

- +

F. In Element With No Cache Tags

log('6. In element with no cache tags') ?> -
+ diff --git a/cake/tests/test_app/views/elements/nocache/sub1.ctp b/cake/tests/test_app/views/elements/nocache/sub1.ctp index ea85a9fd8..8557e05ce 100644 --- a/cake/tests/test_app/views/elements/nocache/sub1.ctp +++ b/cake/tests/test_app/views/elements/nocache/sub1.ctp @@ -1,8 +1,8 @@ element('nocache/sub2'); ?> - + - + \ No newline at end of file diff --git a/cake/tests/test_app/views/elements/nocache/sub2.ctp b/cake/tests/test_app/views/elements/nocache/sub2.ctp index 236cd75c5..991e3b17f 100644 --- a/cake/tests/test_app/views/elements/nocache/sub2.ctp +++ b/cake/tests/test_app/views/elements/nocache/sub2.ctp @@ -1,6 +1,6 @@ - + - + \ No newline at end of file diff --git a/cake/tests/test_app/views/layouts/cache_empty_sections.ctp b/cake/tests/test_app/views/layouts/cache_empty_sections.ctp index 3b1777fd4..dae25af94 100644 --- a/cake/tests/test_app/views/layouts/cache_empty_sections.ctp +++ b/cake/tests/test_app/views/layouts/cache_empty_sections.ctp @@ -2,12 +2,12 @@ <?php echo $title_for_layout; ?> - + - - + + - + \ No newline at end of file diff --git a/cake/tests/test_app/views/layouts/cache_layout.ctp b/cake/tests/test_app/views/layouts/cache_layout.ctp index a5b1704e7..1fd6ff624 100644 --- a/cake/tests/test_app/views/layouts/cache_layout.ctp +++ b/cake/tests/test_app/views/layouts/cache_layout.ctp @@ -18,15 +18,15 @@ */ ?>

This is regular text

- + - + - + - +

Additional regular text.

\ No newline at end of file diff --git a/cake/tests/test_app/views/layouts/multi_cache.ctp b/cake/tests/test_app/views/layouts/multi_cache.ctp index 2ed0dd1b8..d3bb46503 100644 --- a/cake/tests/test_app/views/layouts/multi_cache.ctp +++ b/cake/tests/test_app/views/layouts/multi_cache.ctp @@ -18,23 +18,23 @@ */ ?>

This is regular text

- +

A. Layout Before Content

log('1. layout before content') ?> -
-element('nocache/plain'); ?> - + +element('nocache/plain'); ?> +

C. Layout After Test Element But Before Content

log('3. layout after test element but before content') ?> -
+ - +

E. Layout After Content

log('5. layout after content') ?> -
+

Additional regular text.

element('nocache/contains_nocache'); stub?> - +

G. Layout After Content And After Element With No Cache Tags

log('7. layout after content and after element with no cache tags') ?> -
\ No newline at end of file + \ No newline at end of file diff --git a/cake/tests/test_app/views/posts/cache_empty_sections.ctp b/cake/tests/test_app/views/posts/cache_empty_sections.ctp index ab6fb3ae9..0bb2bc45b 100644 --- a/cake/tests/test_app/views/posts/cache_empty_sections.ctp +++ b/cake/tests/test_app/views/posts/cache_empty_sections.ctp @@ -1,2 +1,2 @@ View Content - + diff --git a/cake/tests/test_app/views/posts/cache_form.ctp b/cake/tests/test_app/views/posts/cache_form.ctp index 7cf121904..6f782af6d 100644 --- a/cake/tests/test_app/views/posts/cache_form.ctp +++ b/cake/tests/test_app/views/posts/cache_form.ctp @@ -1,5 +1,5 @@
- + Form->create('User');?>
@@ -10,5 +10,5 @@ ?>
Form->end('Submit');?> -
+
\ No newline at end of file diff --git a/cake/tests/test_app/views/posts/multiple_nocache.ctp b/cake/tests/test_app/views/posts/multiple_nocache.ctp index eb397e492..4ee095b36 100644 --- a/cake/tests/test_app/views/posts/multiple_nocache.ctp +++ b/cake/tests/test_app/views/posts/multiple_nocache.ctp @@ -1,15 +1,15 @@ --view start-- - + - + this view has 3 nocache blocks - + - + - + - + --view end-- \ No newline at end of file diff --git a/cake/tests/test_app/views/posts/nocache_multiple_element.ctp b/cake/tests/test_app/views/posts/nocache_multiple_element.ctp index a72788305..d6770e23b 100644 --- a/cake/tests/test_app/views/posts/nocache_multiple_element.ctp +++ b/cake/tests/test_app/views/posts/nocache_multiple_element.ctp @@ -1,9 +1,9 @@ - + - + - + - + element('nocache/sub1'); ?> \ No newline at end of file diff --git a/cake/tests/test_app/views/posts/sequencial_nocache.ctp b/cake/tests/test_app/views/posts/sequencial_nocache.ctp index 215f68a4e..7fa93fa5c 100644 --- a/cake/tests/test_app/views/posts/sequencial_nocache.ctp +++ b/cake/tests/test_app/views/posts/sequencial_nocache.ctp @@ -18,7 +18,7 @@ */ ?>

Content

- +

D. In View File

log('4. in view file') ?> -
\ No newline at end of file + \ No newline at end of file diff --git a/cake/tests/test_app/views/posts/test_nocache_tags.ctp b/cake/tests/test_app/views/posts/test_nocache_tags.ctp index 1692f1550..d489f6f78 100644 --- a/cake/tests/test_app/views/posts/test_nocache_tags.ctp +++ b/cake/tests/test_app/views/posts/test_nocache_tags.ctp @@ -18,7 +18,7 @@ */ ?>

- + - +