mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-04 10:32:40 +00:00
Merge branch '2.0' into 2.0-api-doc
Conflicts: lib/Cake/Test/Case/View/Helper/CacheHelperTest.php lib/Cake/Utility/Debugger.php
This commit is contained in:
commit
620a65b2fc
74 changed files with 1173 additions and 355 deletions
|
@ -55,7 +55,7 @@ class CacheHelper extends AppHelper {
|
|||
public function afterRender($viewFile) {
|
||||
$caching = (($this->_View->cacheAction != false)) && (Configure::read('Cache.check') === true);
|
||||
if ($caching) {
|
||||
$this->cache($viewFile, $this->_View->output, false);
|
||||
$this->_View->output = $this->cache($viewFile, $this->_View->output, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,11 +68,18 @@ class CacheHelper extends AppHelper {
|
|||
public function afterLayout($layoutFile) {
|
||||
$caching = (($this->_View->cacheAction != false)) && (Configure::read('Cache.check') === true);
|
||||
if ($caching) {
|
||||
$this->cache($layoutFile, $this->_View->output, true);
|
||||
$this->_View->output = $this->cache($layoutFile, $this->_View->output, true);
|
||||
}
|
||||
$this->_View->output = preg_replace('/<!--\/?nocache-->/', '', $this->_View->output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Counter used for counting nocache section tags.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
var $_counter = 0;
|
||||
|
||||
/**
|
||||
* Main method used to cache a view
|
||||
*
|
||||
|
@ -120,10 +127,13 @@ class CacheHelper extends AppHelper {
|
|||
}
|
||||
|
||||
if ($cacheTime != '' && $cacheTime > 0) {
|
||||
$out = preg_replace_callback('/<!--nocache-->/', array($this, '_replaceSection'), $out);
|
||||
|
||||
$this->_parseFile($file, $out);
|
||||
if ($cache === true) {
|
||||
$cached = $this->_parseOutput($out);
|
||||
$this->_writeFile($cached, $cacheTime, $useCallbacks);
|
||||
$out = $this->_stripTags($out);
|
||||
}
|
||||
return $out;
|
||||
} else {
|
||||
|
@ -144,7 +154,7 @@ class CacheHelper extends AppHelper {
|
|||
} elseif ($file = fileExistsInPath($file)) {
|
||||
$file = file_get_contents($file);
|
||||
}
|
||||
preg_match_all('/(<!--nocache-->(?<=<!--nocache-->)[\\s\\S]*?(?=<!--\/nocache-->)<!--\/nocache-->)/i', $cache, $outputResult, PREG_PATTERN_ORDER);
|
||||
preg_match_all('/(<!--nocache:\d{3}-->(?<=<!--nocache:\d{3}-->)[\\s\\S]*?(?=<!--\/nocache-->)<!--\/nocache-->)/i', $cache, $outputResult, PREG_PATTERN_ORDER);
|
||||
preg_match_all('/(?<=<!--nocache-->)([\\s\\S]*?)(?=<!--\/nocache-->)/i', $file, $fileResult, PREG_PATTERN_ORDER);
|
||||
$fileResult = $fileResult[0];
|
||||
$outputResult = $outputResult[0];
|
||||
|
@ -171,6 +181,30 @@ class CacheHelper extends AppHelper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Munges the output from a view with cache tags, and numbers the sections.
|
||||
* This helps solve issues with empty/duplicate content.
|
||||
*
|
||||
* @param string $content The content to munge.
|
||||
* @return string The content with cake:nocache tags replaced.
|
||||
*/
|
||||
function _replaceSection($matches) {
|
||||
$this->_counter += 1;
|
||||
return sprintf('<!--nocache:%03d-->', $this->_counter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip cake:nocache tags from a string. Since View::render()
|
||||
* only removes un-numbered nocache tags, remove all the numbered ones.
|
||||
* This is the complement to _replaceSection.
|
||||
*
|
||||
* @param string $content String to remove tags from.
|
||||
* @return string String with tags removed.
|
||||
*/
|
||||
function _stripTags($content) {
|
||||
return preg_replace('#<!--/?nocache(\:\d{3})?-->#', '', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the output and replace cache tags
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue