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

minPHP route bug GET parameters containing "0".

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.9.0
    • Fix Version/s: 5.10.0-b2
    • Component/s: Plugins
    • Labels:
      None

      Description

      Typically encountered with a custom plugin, a GET parameter containing 0 is left out of the array. Consider the following example:

      As an example URL:
      /admin/plugin/myplugin/admin_forms/fields/0/lookup/51

      get[] array contains:
      get[0] = lookup
      get[1] = 51

      However, this example URL works as expected:
      /admin/plugin/myplugin/admin_forms/fields/15/lookup/1096

      get[] array contains:
      get[0] = 15
      get[1] = 'lookup'
      get[2] = 1096

      Basically the value 0 does not exist in the array, but if a non-zero value is provided, it is included in GET.

      Jono suggested the following fix:

      vendors/minphp/bridge/lib/Router.php around line 330 change

                  // Only assign GET parameters that are not query parameters
                  if (empty($part) || substr($part, 0, 1) === '?') {
                      continue;
                  }
      

      To

                  // Only assign GET parameters that are not query parameters
                  if ($part === '' || $part === null || substr($part, 0, 1) === '?') {
                      continue;
                  }
      

      NOTE! Customer stated that this was not sufficient, and suggested the following:

      Also had to do something similar near line 276 of same method:

      // Begin building URI
      for ($i = count($pathParts)1; $i >= 0; $i-) {
      //if (!empty($pathParts[$i])) {
      if ($pathParts[$i] != '' && $pathParts[$i] != null)

      { $uri[] = $pathParts[$i]; }

      }

      So with the edit suggested at line 330 and the edit above near line 276, the 0 is not skipped. I loaded several admin area pages and client area pages following these edits and it does not appear to have broken other pages loading.

        Activity

          People

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

            Dates

            • Created:
              Updated:
              Resolved:
              Fix Release Date:
              14/May/24

              Agile