FOG 1.5.2.11 GUI bug in Host and Group Membership Edit
-
Can you please repull? Is there any new data pulled in? I ask because I rewrote this method to implicitely get the proper id->name pairs which was not the case for a little bit. This ultimately means, with the most current
working
branch, this is essentially impossible. The membership tabs are common between all objects, (Groups, Hosts, Images, Snapins, Printers) with the only minor exception being hosts, who’s membership tab displays groups where everything else displays hosts. -
This is the exact PHP code used for this too: I’ll try to break it down a little later on.
/** * Returns only the ids and names of the class passed in. * * @param string $class The class to get list of. * @param string $whereItems If we want to filter items. * * @return void */ public function names($class, $whereItems = []) { $data = []; $names = self::getSubObjectIDs( $class, [], 'name' ); $ids = self::getSubObjectIDs( $class, [], 'id' ); $classname = strtolower($class); $classVars = self::getClass( $class, '', true ); $sql = 'SELECT `' . $classVars['databaseFields']['id'] . '`,`' . $classVars['databaseFields']['name'] . '` FROM `' . $classVars['databaseTable'] . '`'; if (count($whereItems) > 0) { $where = ''; foreach ($whereItems as $key => &$field) { if (!$where) { $where = ' WHERE `' . $classVars['databaseFields'][$key] . '`'; } else { $where .= ' AND `' . $classVars['databaseFields'][$key] . '`'; } if (is_array($field)) { $where .= " IN ('" . implode("','", $field) . "')"; } else { $where .= " = '" . $field . "'"; } } $sql .= $where; } $vals = self::$DB->query($sql)->fetch('', 'fetch_all')->get(); foreach ($vals as &$val) { $data[] = [ 'id' => $val[$classVars['databaseFields']['id']], 'name' => $val[$classVars['databaseFields']['name']] ]; unset($val); } self::$data = $data; }
Basically, the code gathering is sending the object id’s we want to gather at the time it’s gathering…
hostsnotinme
,hosts
,groupsnotinme
,groups
. (the$whereItems
variable is sent:['id'=> [1,2,3]]
(in the case of membership).The names and ids lines with the (getSubObjectIDs are just the old method of handling this, I will remove them as they don’t do anything but take up memory now).
$data = [];
Just initializes our storage point as an array.
$classname = strtolower($class);
Sets the class we’re working with (host, group, image, etc…) in lower case form.Below just gets the classes variables (database fields, table, etc…)
$classVars = self::getClass( $class, '', true );
Sets up the sql query to call based on the relevant fields. This is not complete quite yet.
$sql = 'SELECT `' . $classVars['databaseFields']['id'] . '`,`' . $classVars['databaseFields']['name'] . '` FROM `' . $classVars['databaseTable'] . '`';
The below stanza is just to help setup our where clause, if needed. (If you pass the api
/fog/host/names
it will return a list of all hosts ids and names, this api was generated with the intent of correcting the issues of non-matching id->name pairs.).
To clarify a bit, whereItems is an associative array, and the values of the left can be string or array. If they’re an array, we setup the where clause to do an IN search (WHERE {field} IN ('val1','val2','val3')
. If the right is not an array (e.g. [‘id’ => 1]), it would do an equal search (WHERE {field} = 'val1'
).if (count($whereItems) > 0) { $where = ''; foreach ($whereItems as $key => &$field) { if (!$where) { $where = ' WHERE `' . $classVars['databaseFields'][$key] . '`'; } else { $where .= ' AND `' . $classVars['databaseFields'][$key] . '`'; } if (is_array($field)) { $where .= " IN ('" . implode("','", $field) . "')"; } else { $where .= " = '" . $field . "'"; } } $sql .= $where; }
$vals = self::$DB->query($sql)->fetch('', 'fetch_all')->get();
This actually pulls the information from the db.The below element sets the value that will be returned in json format. (e.g. [{‘id’: 1,‘name’: ‘name1’},{‘id’: 2,‘name’:‘name2’}]).
foreach ($vals as &$val) { $data[] = [ 'id' => $val[$classVars['databaseFields']['id']], 'name' => $val[$classVars['databaseFields']['name']] ]; unset($val); } self::$data = $data;
That’s all there is to it. I know it seems like a lot, but it’s really not that much code behind it. most of the lines seen are just to help maintain readability and keep line lengths down to < 85 characters.
-
Sorry, cannot check that.
1.5.2.11 had a critical bug while imaging (kernel panic, something with init not present). I pulled 1.5.2.11 only to check whether the problem was still there. I immediately returned to 1.5.2.2
-
FOG 1.5.2.20
Not fixed yet.
-
@trialanderror what’s not fixed yet. Can you show exactly what needs to be done to replicate the problem on the version you’re claiming doesn’t work?
-
@trialanderror said in FOG 1.5.2.11 GUI bug in Host and Group Membership Edit:
If I tick a group/host (to remove a host from a group) and click “Remove” not the ticked but another (random) goup/host will be removed.
Obviously my English is too bad. Another try:
For example:
- Navigate to Group Mangement Edit: ‘groupname’
- Tick off (?) a host of your choice.
- Left click on ‘Remove’
- Wonder
-
I have the same problem “If I tick a group/host (to remove a host from a group) and click “Remove” not the ticked but another (random) goup/host will be removed.”
with : Ubuntu 16.04 and Fog 1.5.0.38, Fog 1.5.2, Fog 1.5.2.20
I don’t know from which version I have this problem -
Please update and try again? I’ve rewritten quite a bit in hopes to address this, however I haven’t been able to replicate it which is why I asked for more specific means. It wasn’t saying your instruction was not able to be followed, it was so I could try things so I CAN replicate the problem.
-
Fog 1.5.2 : The checkbox does not match the host name and when I click remove, the wrong host is removed
Fog 1.5.2.23 : The check box corresponds well to the name of the host. But when I click remove, the wrong host is deleted
-
Fog 1.5.2.24 : the same as Fog 1.5.2.23
-
@fredg what’s the link for that host show? It appears to me to be host id 441, can you show the link as well? At the least the uri portion of that link.
-
Okay found, I think, where the issue was. Adding always worked properly, but I made a typo on the remove element. Not that it matters to many but I was passing the array for remove rather than the individual item. Once I corrected this, I was able to see the proper item removing. I happened to have luck earlier so I just added a few more hosts so I could see what was happening.
I’m fairly confident the latest working version has this corrected for. Just need a few to test and report.
Thank you
-
Fog 1.5.2.26 : OK it works!
Thank you -
@tom-elliott : can we have the default list of members in alphabetical order?
-
Hi, I am experiencing the same issue. When I try to select hosts in the group memebership tabs and remove them from group or get to the hostpreferences a different host is edited. On mouse-over the hyperlink of the host has a different id in it. It looks like the id variable is incremented by one or maybe it is an issue caused by a loop in the source which runs one more time than it should.
My further investigation showed:
If I create a new group an edit memberships (delete, select host for editing preferences) everything works as it should(the host-id in the hyperlink is correct) as long as the server is not rebooted.
By the way when in the hoststab itself the hostids are correct, the incrementation happens only if i switch to the grouptab.
I am runnning ubuntu 16.04 with fog 1.5.2 and php7. The only changes i did to the clean fog-setup, were:Editing the fog vhost configuration(Moving </Directory> Tag) and setiing a different php-fpm max_children count higher to get rid of the Updating database error 503 after multicast-deploy. I don’t think there is some connection between my changes and the webguibug.
Please excuse my bad English, I hope this information helps to target the problem.
-
@fredg I can add the sorting yes.
-
@pedro please try installing the working branch as has been discussed that should fix the issue you’re talking about. It shouldn’t be too long before I can push 1.5.3 proper but I’m waiting for feed back in a few other bugs as well.
-
@fredg Added element to always sort by name field, unless the name field is not available in which case it defaults to order by the id field.
-
@tom-elliott : Items are sorted by name field except for membership.
-
@tom-elliott This works after upgrading to version 1.5.2.28