Merge pull request #3677 from jonom/3093-flush-bugs

FIX: Manifest flushing
This commit is contained in:
Damian Mooyman 2014-11-27 11:24:40 +13:00
commit 3b3478136d
2 changed files with 12 additions and 10 deletions

View File

@ -95,9 +95,9 @@ Injector::set_inst($injector);
// Regenerate the manifest if ?flush is set, or if the database is being built. // Regenerate the manifest if ?flush is set, or if the database is being built.
// The coupling is a hack, but it removes an annoying bug where new classes // The coupling is a hack, but it removes an annoying bug where new classes
// referenced in _config.php files can be referenced during the build process. // referenced in _config.php files can be referenced during the build process.
$flush = (isset($_GET['flush']) || isset($_REQUEST['url']) && ( $requestURL = isset($_REQUEST['url']) ? trim($_REQUEST['url'], '/') : false;
$_REQUEST['url'] == 'dev/build' || $_REQUEST['url'] == BASE_URL . '/dev/build' $flush = (isset($_GET['flush']) || $requestURL == 'dev/build' || $requestURL == BASE_URL . '/dev/build');
));
global $manifest; global $manifest;
$manifest = new SS_ClassManifest(BASE_PATH, false, $flush); $manifest = new SS_ClassManifest(BASE_PATH, false, $flush);
@ -111,16 +111,17 @@ if(file_exists(BASE_PATH . '/vendor/autoload.php')) {
require_once BASE_PATH . '/vendor/autoload.php'; require_once BASE_PATH . '/vendor/autoload.php';
} }
// Now that the class manifest is up, load the configuration // Now that the class manifest is up, load the static configuration
$configManifest = new SS_ConfigStaticManifest(BASE_PATH, false, $flush); $configManifest = new SS_ConfigStaticManifest(BASE_PATH, false, $flush);
Config::inst()->pushConfigStaticManifest($configManifest); Config::inst()->pushConfigStaticManifest($configManifest);
// Now that the class manifest is up, load the configuration // And then the yaml configuration
$configManifest = new SS_ConfigManifest(BASE_PATH, false, $flush); $configManifest = new SS_ConfigManifest(BASE_PATH, false, $flush);
Config::inst()->pushConfigYamlManifest($configManifest); Config::inst()->pushConfigYamlManifest($configManifest);
// Load template manifest
SS_TemplateLoader::instance()->pushManifest(new SS_TemplateManifest( SS_TemplateLoader::instance()->pushManifest(new SS_TemplateManifest(
BASE_PATH, project(), false, isset($_GET['flush']) BASE_PATH, project(), false, $flush
)); ));
// If in live mode, ensure deprecation, strict and notices are not reported // If in live mode, ensure deprecation, strict and notices are not reported

View File

@ -16,7 +16,6 @@ class SS_TemplateManifest {
protected $cacheKey; protected $cacheKey;
protected $project; protected $project;
protected $inited; protected $inited;
protected $forceRegen;
protected $templates = array(); protected $templates = array();
/** /**
@ -40,7 +39,9 @@ class SS_TemplateManifest {
$this->cache = new $cacheClass('templatemanifest'.($includeTests ? '_tests' : '')); $this->cache = new $cacheClass('templatemanifest'.($includeTests ? '_tests' : ''));
$this->cacheKey = $this->getCacheKey($includeTests); $this->cacheKey = $this->getCacheKey($includeTests);
$this->forceRegen = $forceRegen; if ($forceRegen) {
$this->regenerate();
}
} }
/** /**
@ -208,7 +209,7 @@ class SS_TemplateManifest {
} }
protected function init() { protected function init() {
if (!$this->forceRegen && $data = $this->cache->load($this->cacheKey)) { if ($data = $this->cache->load($this->cacheKey)) {
$this->templates = $data; $this->templates = $data;
$this->inited = true; $this->inited = true;
} else { } else {