Skip to content

Commit

Permalink
Fixed bug with outdated cache on theme import
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Sep 23, 2013
1 parent 0fe5cda commit bf45b2c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/MadeYourDay/Contao/CustomElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CustomElements extends \Backend
protected $fieldsConfig = array();

/**
* tl_content DCA onload callback
* tl_content and tl_module DCA onload callback
*
* Reloads config and creates the DCA fields
*
Expand Down Expand Up @@ -603,10 +603,29 @@ public static function loadConfig()
$filePath = 'system/cache/rocksolid_custom_elements_config.php';
$fileFullPath = TL_ROOT . '/' . $filePath;

$cacheHash = md5(implode(',', array_merge(
glob(TL_ROOT . '/templates/rsce_*'),
glob(TL_ROOT . '/templates/*/rsce_*')
)));

if (file_exists($fileFullPath)) {
$fileCacheHash = null;
include $fileFullPath;
if ($fileCacheHash !== $cacheHash) {
// the cache file is outdated
unlink($fileFullPath);
}
else {
// the cache file is valid and loaded
return;
}
}

if (! file_exists($fileFullPath)) {

$contents = array();
$contents[] = '<?php' . "\n";
$contents[] = '$fileCacheHash = ' . var_export($cacheHash, true) . ';' . "\n";

$templates = \Controller::getTemplateGroup('rsce_');
foreach ($templates as $template => $label) {
Expand Down

0 comments on commit bf45b2c

Please sign in to comment.