Squidix Web Hosting Posted March 27, 2015 Report Posted March 27, 2015 Every time I edit a package, it breaks the ordering. Usually bumps it up to the top of the list. a. Order packages under "groups" in the admin b. Edit a package (change any value) No errors /clients/admin/packages/ http://awesomescreenshot.com/0214qpnu6d http://awesomescreenshot.com/0af4qpo6e6 http://awesomescreenshot.com/0c64qpo5e4 cPanel + PHP 5.4, blesta 3.4.2, solusvm module PauloV 1
Michael Posted March 27, 2015 Report Posted March 27, 2015 You go to Packages > Groups > select one and move it I've had to move the bottom to the top and then move the back into normal, it's just random editing like for me it's only my SSL packages. I have a lot of them.
Tyson Posted March 27, 2015 Report Posted March 27, 2015 It looks like this is a bug because the package group order should not change. I've created a task (CORE-1618) for us to look into it further. PauloV and Michael 2
Squidix Web Hosting Posted March 28, 2015 Author Report Posted March 28, 2015 It appears that when a package is edited, groups are removed and re-added? If so this should be expected behavior. In edit function: if (isset($vars['groups'])) $this->setGroups($package_id, $vars['groups']); setGroups function: private function setGroups($package_id, $groups=null) { // Remove all existing groups $this->Record->from("package_group")-> where("package_id", "=", $package_id)->delete(); // Add all given groups if (!empty($groups) && is_array($groups)) { for ($i=0; $i<count($groups); $i++) { $vars = array( 'package_id'=>$package_id, 'package_group_id'=>$groups[$i] ); $this->Record->insert("package_group", $vars); } } }
Squidix Web Hosting Posted March 28, 2015 Author Report Posted March 28, 2015 Here, I've fixed it: Starting at line 305 in package model. However this is not ideal, as it won't retain ordering if a group is added (even if old groups are kept) What should be done is - empty the group/package relationship table (excluding the ids of groups in the array from the submitted form), then do an array diff on the group ids, and add the new groups. that way the old relationship records are kept instead of blanked every time. since the ordering appears to be in the table for the many to many relationship between groups and packages. I'll try to implement when I have some time but keep in mind I have been working with the internal code for all of 2 days now so I am not very familiar. $group_ids = array(); foreach ($package->groups as $group) { $group_ids[] = $group->id; } // Replace all group assignments with those that are given (if any given) if (isset($vars['groups']) && $vars['groups'] != $group_ids) $this->setGroups($package_id, $vars['groups']); Blesta Addons 1
Tyson Posted April 9, 2015 Report Posted April 9, 2015 This is resolved for v3.5.0 in CORE-1618. Existing group ordering will be kept, and any new packages will continue their current behavior of being at the top of the list until re-ordered. Michael 1
Recommended Posts