public static function installData($revision)
{
$db = Db::get();
$files = $db->fetchAll("SELECT * FROM `" . self::$tmpTable . "` WHERE revision = ?", $revision);
foreach ($files as $file) {
if ($file["action"] == "update" || $file["action"] == "add") {
if (!is_dir(dirname(PIMCORE_DOCUMENT_ROOT . $file["path"]))) {
if (!self::$dryRun) {
File::mkdir(dirname(PIMCORE_DOCUMENT_ROOT . $file["path"]));
}
}
if (array_key_exists("id", $file) && $file["id"]) {
// this is the new style, see https://www.pimcore.org/issues/browse/PIMCORE-2722
$srcFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/update/" . $revision . "/files/" . $file["id"] . "-" . $file["revision"];
} else {
// this is the old style, which we still have to support here, otherwise there's the risk that the
// running update cannot be finished
$srcFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/update/" . $revision . "/files/" . str_replace("/", "~~~", $file["path"]);
}
$destFile = PIMCORE_DOCUMENT_ROOT . $file["path"];
if (!self::$dryRun) {
if ($file["path"] == "/composer.json") {
// composer.json needs some special processing
self::installComposerJson($srcFile, $destFile);
} else {
copy($srcFile, $destFile);
}
}
} elseif ($file["action"] == "delete") {
if (!self::$dryRun) {
if (file_exists(PIMCORE_DOCUMENT_ROOT . $file["path"])) {
unlink(PIMCORE_DOCUMENT_ROOT . $file["path"]);
}
clearstatcache();
// remove also directory if its empty
if (count(glob(dirname(PIMCORE_DOCUMENT_ROOT . $file["path"]) . "/*")) === 0) {
recursiveDelete(dirname(PIMCORE_DOCUMENT_ROOT . $file["path"]), true);
}
}
}
}
self::clearOPCaches();
}