PM-404 "En la actualizacion de un plugin no se actualiza el singleton" SOLVED
Issue:
Al modificar los atributos de un plugin, este cambio no se refleja en el archivo "plugin.singleton" de cada workspace
Cause:
ProcessMaker no detecta cuando el archivo principal de un plugin es editado
Solution:
Se ha añdo un nuevo comando, el mismo actualiza el archivo "plugin.singleton" en cada workspace, segun los
atributos del plugin, el comando es el siguiente:
$ ./gulliver update-plugin-attributes pluginName
This commit is contained in:
@@ -49,6 +49,9 @@ pake_task('new-project', 'project_exists');
|
|||||||
pake_desc("build new plugin \n args: <name>");
|
pake_desc("build new plugin \n args: <name>");
|
||||||
pake_task('new-plugin', 'project_exists');
|
pake_task('new-plugin', 'project_exists');
|
||||||
|
|
||||||
|
pake_desc("Update the plugin attributes in all workspaces\n args: <plugin-name>");
|
||||||
|
pake_task("update-plugin-attributes", "project_exists");
|
||||||
|
|
||||||
pake_desc("pack plugin in .tar file \n args: <plugin>");
|
pake_desc("pack plugin in .tar file \n args: <plugin>");
|
||||||
pake_task('pack-plugin', 'project_exists');
|
pake_task('pack-plugin', 'project_exists');
|
||||||
|
|
||||||
@@ -2613,3 +2616,28 @@ function run_check_standard_code ( $task, $options) {
|
|||||||
pakeColor::colorize($val['dos'] ? 'dos' : ' ', 'INFO'), $val['file'] );
|
pakeColor::colorize($val['dos'] ? 'dos' : ' ', 'INFO'), $val['file'] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function run_update_plugin_attributes($task, $args)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
G::LoadClass("plugin");
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
if (!isset($args[0])) {
|
||||||
|
throw new Exception("Error: You must specify the name of a plugin");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set variables
|
||||||
|
$pluginName = $args[0];
|
||||||
|
|
||||||
|
//Update plugin attributes
|
||||||
|
$pmPluginRegistry = &PMPluginRegistry::getSingleton();
|
||||||
|
|
||||||
|
$pmPluginRegistry->updatePluginAttributesInAllWorkspaces($pluginName);
|
||||||
|
|
||||||
|
echo "Done!\n";
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage() . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1513,5 +1513,88 @@ class PMPluginRegistry
|
|||||||
{
|
{
|
||||||
return $this->_aCronFiles;
|
return $this->_aCronFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the plugin attributes in all workspaces
|
||||||
|
*
|
||||||
|
* @param string $pluginName Plugin name
|
||||||
|
*
|
||||||
|
* return void
|
||||||
|
*/
|
||||||
|
public function updatePluginAttributesInAllWorkspaces($pluginName)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
G::LoadClass("system");
|
||||||
|
G::LoadClass("wsTools");
|
||||||
|
|
||||||
|
//Set variables
|
||||||
|
$pluginFileName = $pluginName . ".php";
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
if (!file_exists(PATH_PLUGINS . $pluginFileName)) {
|
||||||
|
throw new Exception("Error: The plugin not exists");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update plugin attributes
|
||||||
|
require_once(PATH_PLUGINS . $pluginFileName);
|
||||||
|
|
||||||
|
$pmPluginRegistry = &PMPluginRegistry::getSingleton();
|
||||||
|
|
||||||
|
$pluginDetails = $pmPluginRegistry->getPluginDetails($pluginFileName);
|
||||||
|
|
||||||
|
if (isset($pluginDetails->aWorkspaces) && is_array($pluginDetails->aWorkspaces) && count($pluginDetails->aWorkspaces) > 0) {
|
||||||
|
$arrayWorkspace = array();
|
||||||
|
|
||||||
|
foreach (System::listWorkspaces() as $value) {
|
||||||
|
$workspaceTools = $value;
|
||||||
|
|
||||||
|
$arrayWorkspace[] = $workspaceTools->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayWorkspaceAux = array_diff($arrayWorkspace, $pluginDetails->aWorkspaces); //Workspaces to update
|
||||||
|
$strWorkspaceNoWritable = "";
|
||||||
|
|
||||||
|
$arrayWorkspace = array();
|
||||||
|
|
||||||
|
foreach ($arrayWorkspaceAux as $value) {
|
||||||
|
$workspace = $value;
|
||||||
|
|
||||||
|
$workspacePathDataSite = PATH_DATA . "sites" . PATH_SEP . $workspace . PATH_SEP;
|
||||||
|
|
||||||
|
if (file_exists($workspacePathDataSite . "plugin.singleton")) {
|
||||||
|
$pmPluginRegistry = PMPluginRegistry::loadSingleton($workspacePathDataSite . "plugin.singleton");
|
||||||
|
|
||||||
|
if (isset($pmPluginRegistry->_aPluginDetails[$pluginName])) {
|
||||||
|
if (!is_writable($workspacePathDataSite . "plugin.singleton")) {
|
||||||
|
$strWorkspaceNoWritable .= (($strWorkspaceNoWritable != "")? ", " : "") . $workspace;
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayWorkspace[] = $workspace;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
if ($strWorkspaceNoWritable != "") {
|
||||||
|
throw new Exception("Error: The workspaces \"$strWorkspaceNoWritable\" has problems of permissions of write in file \"plugin.singleton\", solve this problem");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update plugin attributes
|
||||||
|
foreach ($arrayWorkspace as $value) {
|
||||||
|
$workspace = $value;
|
||||||
|
|
||||||
|
$workspacePathDataSite = PATH_DATA . "sites" . PATH_SEP . $workspace . PATH_SEP;
|
||||||
|
|
||||||
|
$pmPluginRegistry = PMPluginRegistry::loadSingleton($workspacePathDataSite . "plugin.singleton");
|
||||||
|
|
||||||
|
$pmPluginRegistry->disablePlugin($pluginName);
|
||||||
|
|
||||||
|
file_put_contents($workspacePathDataSite . "plugin.singleton", $pmPluginRegistry->serializeInstance());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user