Skip to content

Commit

Permalink
Web installer now preserve subsites when upgrading (#27).
Browse files Browse the repository at this point in the history
  • Loading branch information
Jemt committed Mar 3, 2018
1 parent 2f814a4 commit 057704a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion upgrade.php
Expand Up @@ -422,7 +422,7 @@ function exceptionHandler($exception)

if ($upgrade === true) // Preserve config, files, data, active template(s), and extensions (3rd party extensions may have been installed)
{
logMsg("This is an upgrade - preserving translations, configuration, data, and extensions");
logMsg("This is an upgrade - preserving translations, configuration, data, extensions, and subsites");

$dsType = getDataSourceType();

Expand All @@ -432,6 +432,7 @@ function exceptionHandler($exception)
rename("data", "data." . $ts);
rename("templates", "templates." . $ts);
rename("extensions", "extensions." . $ts);
rename("sites", "sites." . $ts);
}

logMsg("Moving files from temporary folder '" . $extDir . "' to active Sitemagic installation path");
Expand Down Expand Up @@ -515,6 +516,26 @@ function exceptionHandler($exception)
}
}

logMsg("Restoring subsites");

foreach (scandir("sites." . $ts) as $site)
{
if ($site === "." || $site === "..")
continue;

if (is_dir("sites." . $ts . "/" . $site) === true)
{
rename("sites." . $ts . "/" . $site, "sites/" . $site);

copy("index.php", "sites/" . $site . "/index.php");

if (is_file("sites/" . $site . "/files/.htaccess") === true)
copy("sites/htaccess.fls", "sites/" . $site . "/files/.htaccess");
if (is_file("sites/" . $site . "/templates/.htaccess") === true)
copy("sites/htaccess.tpls", "sites/" . $site . "/templates/.htaccess");
}
}

logMsg("Restoring translations not part of the default package");

if (is_dir("base." . $ts . "/Languages") === true) // Older versions did not have translations for base
Expand Down Expand Up @@ -554,6 +575,7 @@ function exceptionHandler($exception)
removeDir("base." . $ts);
removeDir("templates." . $ts);
removeDir("extensions." . $ts);
removeDir("sites." . $ts);

if ($dsType === "MySQL")
{
Expand Down

0 comments on commit 057704a

Please sign in to comment.