This commit is contained in:
Eric Espie
2022-11-21 09:51:11 +01:00
parent d83c45812d
commit e2e08351b0

View File

@@ -2772,7 +2772,7 @@ HTML;
if (!utils::IsDevelopmentEnvironment()) {
// Save to cache
$sCacheContent = "<?php\n\nreturn ".var_export($aMatchingClasses, true).";";
SetupUtils::builddir(dirname($sCacheFileName));
self::builddir(dirname($sCacheFileName));
file_put_contents($sCacheFileName, $sCacheContent);
}
}
@@ -3194,4 +3194,25 @@ HTML;
{
return hash('sha256', uniqid(sprintf('%x', rand()), true).sprintf('%x', rand()));
}
/**
* Helper to build the full path of a new directory
* @param $dir
*/
public static function builddir($dir)
{
if (empty($dir))
{
// avoid infinite loops :/
return;
}
if (!is_dir($dir))
{
$parent = dirname($dir);
self::builddir($parent);
if (!mkdir($dir) && !is_dir($dir)) {
throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
}
}
}
}