HOR-3260 improvement

This commit is contained in:
Roly Rudy Gutierrez Pinto
2017-05-24 15:29:26 -04:00
parent 8a68563f83
commit 68b32a35f0
2 changed files with 43 additions and 29 deletions

View File

@@ -21,24 +21,14 @@ class System
}
/**
* Flush the cache files for the specified workspace(s).
* If no workspace is specified, then the cache will be flushed in all available
* workspaces.
* Flush the cache files for the specified workspace.
*
* @param array $args
* @param array $opts
* @param object $workspace
*/
public static function flushCache($args, $opts)
public static function flushCache($workspace)
{
$workspaces = get_workspaces_from_args($args);
if (!defined("PATH_C")) {
die("ERROR: seems processmaker is not properly installed (System constants are missing)." . PHP_EOL);
}
//Update singleton file by workspace
foreach ($workspaces as $workspace) {
eprint("Update singleton in workspace " . $workspace->name . " ... ");
try {
//Update singleton file by workspace
\Bootstrap::setConstantsRelatedWs($workspace->name);
$pathSingleton = PATH_DATA . "sites" . PATH_SEP . $workspace->name . PATH_SEP . "plugin.singleton";
$oPluginRegistry = \PMPluginRegistry::loadSingleton($pathSingleton);
@@ -62,18 +52,10 @@ class System
}
}
}
eprintln("DONE");
}
//flush the cache files
\CLI::logging("Flush " . \pakeColor::colorize("system", "INFO") . " cache ... ");
\G::rm_dir(PATH_C);
\G::mk_dir(PATH_C, 0777);
echo "DONE" . PHP_EOL;
foreach ($workspaces as $workspace) {
echo "Flush workspace " . \pakeColor::colorize($workspace->name, "INFO") . " cache ... ";
//flush the cache files
\G::rm_dir(PATH_C);
\G::mk_dir(PATH_C, 0777);
\G::rm_dir($workspace->path . "/cache");
\G::mk_dir($workspace->path . "/cache", 0777);
\G::rm_dir($workspace->path . "/cachefiles");
@@ -81,7 +63,8 @@ class System
if (file_exists($workspace->path . '/routes.php')) {
unlink($workspace->path . '/routes.php');
}
echo "DONE" . PHP_EOL;
} catch (\Exception $e) {
throw new \Exception("Error: cannot perform this task. " . $e->getMessage());
}
}