Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: 5.12.3
-
Fix Version/s: 5.13.0
-
Component/s: Client Interface, Staff Interface
-
Labels:None
Description
To reproduce:
- Create a Package using a module with multiple server groups
- Select a server group and save the package (may or may not be necessary)
- Edit the Package, choose "Any" for the group and check the box "Allow Client to Select Server Group"
- The group the client chooses is not used when provisioning.
The bug is at ~/app/models/services.php:2022 where strict comparison (!==) is used inconsistently with the rest of the codebase.
Root Cause
1. Database Field Type: The module_group_client field is validated as a string in packages.php:2472:
'rule' => ['in_array', ['0', '1']]
2. Type Inconsistency: When the database returns this value, it may come back as integer 1 instead of string '1', especially under PHP 8.2's stricter type handling.
3. The Bug: At line 2022, the strict comparison creates incorrect logic:
if ($package->module_row && $package->module_group_client !== '1') { $vars['module_row_id'] = $package->module_row; // Uses package's server } else if ($package->module_group_client == '1' && isset($vars['module_group_id'])) { $vars['module_row_id'] = $module->selectModuleRow($vars['module_group_id']); // Uses client's selection }
3. When module_group_client is integer 1:
- 1 !== '1' -> TRUE (wrong branch taken, uses package's module_row)
- 1 == '1' -> TRUE (correct, but never reached)
Change line 2022 from:
if ($package->module_row && $package->module_group_client !== '1') {
To:
if ($package->module_row && $package->module_group_client != '1') {