Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-5615

When allowing a client to choose the server group the correct group is not used

    Details

      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') {
      

        Activity

        admin Paul Phillips created issue -
        admin Paul Phillips made changes -
        Field Original Value New Value
        Rank Ranked higher
        admin Paul Phillips made changes -
        Priority Major [ 3 ] Blocker [ 1 ]
        admin Paul Phillips made changes -
        Fix Version/s 6.0.0-b1 [ 12217 ]
        admin Paul Phillips made changes -
        Assignee Paul Phillips [ admin ]
        admin Paul Phillips made changes -
        Status Open [ 1 ] In Review [ 5 ]
        Fix Version/s 6.0.0-b1 [ 12217 ]
        Resolution Fixed [ 1 ]
        jonathan Jonathan Reissmueller made changes -
        Status In Review [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            admin Paul Phillips
            Reporter:
            admin Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: