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');
|
||||||
|
|
||||||
@@ -275,7 +278,7 @@ function convertPhpName($f) {
|
|||||||
function copyPluginFile($tplName, $fName, $class) {
|
function copyPluginFile($tplName, $fName, $class) {
|
||||||
$pluginOutDirectory = PATH_OUTTRUNK . "plugins" . PATH_SEP . $class . PATH_SEP;
|
$pluginOutDirectory = PATH_OUTTRUNK . "plugins" . PATH_SEP . $class . PATH_SEP;
|
||||||
$pluginFilename = $pluginOutDirectory . $fName;
|
$pluginFilename = $pluginOutDirectory . $fName;
|
||||||
|
|
||||||
$fileTpl = PATH_GULLIVER_HOME . 'bin' . PATH_SEP . 'tasks' . PATH_SEP . 'templates' . PATH_SEP . $tplName . '.tpl';
|
$fileTpl = PATH_GULLIVER_HOME . 'bin' . PATH_SEP . 'tasks' . PATH_SEP . 'templates' . PATH_SEP . $tplName . '.tpl';
|
||||||
$content = file_get_contents($fileTpl);
|
$content = file_get_contents($fileTpl);
|
||||||
$iSize = file_put_contents($pluginFilename, $content);
|
$iSize = file_put_contents($pluginFilename, $content);
|
||||||
@@ -293,7 +296,7 @@ function savePluginFile($fName, $tplName, $class, $tableName, $fields = null, $u
|
|||||||
$template->assign('className', $class);
|
$template->assign('className', $class);
|
||||||
$template->assign('tableName', $tableName);
|
$template->assign('tableName', $tableName);
|
||||||
$template->assign('menuId', 'ID_' . strtoupper($class));
|
$template->assign('menuId', 'ID_' . strtoupper($class));
|
||||||
|
|
||||||
if( is_array($fields) ) {
|
if( is_array($fields) ) {
|
||||||
foreach( $fields as $block => $data ) {
|
foreach( $fields as $block => $data ) {
|
||||||
$template->gotoBlock("_ROOT");
|
$template->gotoBlock("_ROOT");
|
||||||
@@ -704,7 +707,7 @@ function run_new_plugin($task, $args) {
|
|||||||
$fields["dashboard"][] = array(
|
$fields["dashboard"][] = array(
|
||||||
"className" => $pluginName
|
"className" => $pluginName
|
||||||
);
|
);
|
||||||
|
|
||||||
$fields["dashboardAttribute"] = "private \$dashletsUids;";
|
$fields["dashboardAttribute"] = "private \$dashletsUids;";
|
||||||
$fields["dashboardAttributeValue"] = "
|
$fields["dashboardAttributeValue"] = "
|
||||||
\$this->dashletsUids = array(
|
\$this->dashletsUids = array(
|
||||||
@@ -720,9 +723,9 @@ function run_new_plugin($task, $args) {
|
|||||||
$fields["dashboardSetup"] = "\$this->registerDashlets();";
|
$fields["dashboardSetup"] = "\$this->registerDashlets();";
|
||||||
$fields["dashboardEnable"] = "\$this->dashletInsert();";
|
$fields["dashboardEnable"] = "\$this->dashletInsert();";
|
||||||
$fields["dashboardDisable"] = "\$this->dashletDelete();";
|
$fields["dashboardDisable"] = "\$this->dashletDelete();";
|
||||||
|
|
||||||
G::verifyPath($pluginHome . PATH_SEP . "views", true);
|
G::verifyPath($pluginHome . PATH_SEP . "views", true);
|
||||||
|
|
||||||
savePluginFile($pluginName . PATH_SEP . "classes" . PATH_SEP . "class.dashlet". $pluginName . ".php", "pluginDashletClass.php", $pluginName, $pluginName);
|
savePluginFile($pluginName . PATH_SEP . "classes" . PATH_SEP . "class.dashlet". $pluginName . ".php", "pluginDashletClass.php", $pluginName, $pluginName);
|
||||||
copyPluginFile("pluginDashlet.html", $pluginName . PATH_SEP . "views" . PATH_SEP . "dashlet". $pluginName . ".html", $pluginName, null, true);
|
copyPluginFile("pluginDashlet.html", $pluginName . PATH_SEP . "views" . PATH_SEP . "dashlet". $pluginName . ".html", $pluginName, null, true);
|
||||||
}
|
}
|
||||||
@@ -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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -260,7 +260,7 @@ class PMPluginRegistry
|
|||||||
//register the default directory, later we can have more
|
//register the default directory, later we can have more
|
||||||
$this->_aPluginDetails[$sNamespace]->enabled = true;
|
$this->_aPluginDetails[$sNamespace]->enabled = true;
|
||||||
if (class_exists($detail->sClassName)) {
|
if (class_exists($detail->sClassName)) {
|
||||||
$oPlugin = new $detail->sClassName( $detail->sNamespace, $detail->sFilename );
|
$oPlugin = new $detail->sClassName( $detail->sNamespace, $detail->sFilename );
|
||||||
} else {
|
} else {
|
||||||
$oPlugin = $detail;
|
$oPlugin = $detail;
|
||||||
}
|
}
|
||||||
@@ -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