Skip to content

Commit

Permalink
FIX Config settings returned to normal after publishing completes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dhensby committed Feb 28, 2014
1 parent 3bb94ab commit cac7372
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions code/extensions/FilesystemPublisher.php
Expand Up @@ -160,6 +160,9 @@ public function unpublishPages($urls) {
public function publishPages($urls) {
$result = array();

//nest the config so we can make changes to the config and revert easily
Config::nest();

// Do we need to map these?
// Detect a numerically indexed arrays
if (is_numeric(join('', array_keys($urls)))) $urls = $this->urlsToPaths($urls);
Expand All @@ -181,7 +184,6 @@ public function publishPages($urls) {
// Ensure that the theme that is set gets used.
Config::inst()->update('SSViewer', 'theme_enabled', true);

$currentBaseURL = Director::baseURL();
$staticBaseUrl = Config::inst()->get('FilesystemPublisher', 'static_base_url');

if($staticBaseUrl) {
Expand All @@ -207,10 +209,6 @@ public function publishPages($urls) {
'redirect' => null,
'path' => null
);

if($staticBaseUrl) {
Config::inst()->update('Director', 'alternate_base_url', $staticBaseUrl);
}

$i++;

Expand Down Expand Up @@ -334,13 +332,8 @@ public function publishPages($urls) {
}*/
}

if(Config::inst()->get('FilesystemPublisher', 'static_base_url')) {
Config::inst()->update('Director', 'alternate_base_url', $currentBaseURL);
}

if($this->fileExtension == 'php') {
Config::inst()->update('SSViewer', 'rewrite_hash_links', true);
}
//return config to its previous state
Config::unnest();

$base = BASE_PATH . "/$this->destFolder";

Expand Down

0 comments on commit cac7372

Please sign in to comment.