FIX Config settings returned to normal after publishing completes

When calling this function onAfterWrite of a DO, the site theme was used to render the CMS form. This fix corrects that by restoring all the config options that are changed
This commit is contained in:
Daniel Hensby 2013-07-17 15:12:16 +01:00
parent 3bb94ab139
commit cac7372f33

View File

@ -160,6 +160,9 @@ class FilesystemPublisher extends StaticPublisher {
public function publishPages($urls) { public function publishPages($urls) {
$result = array(); $result = array();
//nest the config so we can make changes to the config and revert easily
Config::nest();
// Do we need to map these? // Do we need to map these?
// Detect a numerically indexed arrays // Detect a numerically indexed arrays
if (is_numeric(join('', array_keys($urls)))) $urls = $this->urlsToPaths($urls); if (is_numeric(join('', array_keys($urls)))) $urls = $this->urlsToPaths($urls);
@ -181,7 +184,6 @@ class FilesystemPublisher extends StaticPublisher {
// Ensure that the theme that is set gets used. // Ensure that the theme that is set gets used.
Config::inst()->update('SSViewer', 'theme_enabled', true); Config::inst()->update('SSViewer', 'theme_enabled', true);
$currentBaseURL = Director::baseURL();
$staticBaseUrl = Config::inst()->get('FilesystemPublisher', 'static_base_url'); $staticBaseUrl = Config::inst()->get('FilesystemPublisher', 'static_base_url');
if($staticBaseUrl) { if($staticBaseUrl) {
@ -208,10 +210,6 @@ class FilesystemPublisher extends StaticPublisher {
'path' => null 'path' => null
); );
if($staticBaseUrl) {
Config::inst()->update('Director', 'alternate_base_url', $staticBaseUrl);
}
$i++; $i++;
if($url && !is_string($url)) { if($url && !is_string($url)) {
@ -334,13 +332,8 @@ class FilesystemPublisher extends StaticPublisher {
}*/ }*/
} }
if(Config::inst()->get('FilesystemPublisher', 'static_base_url')) { //return config to its previous state
Config::inst()->update('Director', 'alternate_base_url', $currentBaseURL); Config::unnest();
}
if($this->fileExtension == 'php') {
Config::inst()->update('SSViewer', 'rewrite_hash_links', true);
}
$base = BASE_PATH . "/$this->destFolder"; $base = BASE_PATH . "/$this->destFolder";