Home My Page Projects FusionForge
Summary Activity Forums Tracker Lists News SCM Files Mediawiki Hudson/Jenkins

[#645] Error in function "setPluginUse" in "Group.class.php" file

Date:
2014-03-18 17:08
Priority:
3
State:
Closed
Submitted by:
Matthieu DURAND (mdurand)
Assigned to:
Franck Villaume (nerville)
Target Release:
5.3
Found in Version:
master
Severity:
major
Resolution:
Fixed
Summary:
Error in function "setPluginUse" in "Group.class.php" file

Detailed description
In the file "Group.class.php", there is the function "setPluginUse()":
https://fusionforge.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=fusionforge/fusionforge.git;a=blob_plain;f=src/common/include/Group.class.php;hb=HEAD

In this function, the last line is :
$this->normalizeAllRoles

But this code can never be reached, because returns are before this line.
Because of that, when we activate a plugin, the existing roles aren't updated.(example : we activate a Mediawiki plugin, and we cannot chose the mediawiki rights corresponding to the fusionforge role.)


The correct code is :

function setPluginUse($pluginname, $val=true) {
if ($val == $this->usesPlugin($pluginname)) {
// State is already good, returning
return true;
}
$res = db_query_params('SELECT plugin_id FROM plugins WHERE plugin_name=$1',
array($pluginname));
$rows = db_numrows($res);
if ($rows == 0) {
// Error: no plugin by that name
return false;
}
$plugin_id = db_result($res,0,'plugin_id');
// Invalidate cache
unset($this->plugins_data);
if ($val) {
$res = db_query_params('INSERT INTO group_plugin (group_id, plugin_id) VALUES ($1, $2)',
array($this->getID(),
$plugin_id));
} else {
$res = db_query_params('DELETE FROM group_plugin WHERE group_id=$1 AND plugin_id=$2',
array($this->getID(),
$plugin_id));
}
$this->normalizeAllRoles () ;
return $res;
}
Message  ↓
Date: 2014-03-20 10:30
Sender: Franck Villaume

thank for your feedback.
Fix in Branch_5_3.
commit : cd751e55bad794ae0a143a3b2843d55280c513aa

Field Old Value Date By
status_idOpen2014-03-20 10:30nerville
close_dateNone2014-03-20 10:30nerville
assigned_tonone2014-03-20 10:30nerville
Severitynormal2014-03-20 10:30nerville
ResolutionNone2014-03-20 10:30nerville