Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-21101

Undefined index in CRM_Core_BAO_SchemaHandler::getMissingIndices()

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 4.7.23
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      None
    • Funding Source:
      Needs Funding
    • Verified?:
      No

      Description

      Since the recent addition of checks for indices, we've begun seeing warnings like:

      Notice: Undefined index: civicrm_location_type in CRM_Core_BAO_SchemaHandler::getMissingIndices() (line 747 of /path/to/civicrm/CRM/Core/BAO/SchemaHandler.php).
      Warning: Invalid argument supplied for foreach() in CRM_Core_BAO_SchemaHandler::getMissingIndices() (line 747 of /path/to/civicrm/CRM/Core/BAO/SchemaHandler.php).

      We're seeing a couple pages worth of these warnings, where the indicated index is one of:

      • civicrm_location_type
      • civicrm_option_group
      • civicrm_relationship_type
      • civicrm_contact_type
      • civicrm_batch
      • civicrm_survey
      • civicrm_case_type
      • civicrm_custom_group
      • civicrm_custom_field
      • civicrm_option_value
      • civicrm_group
      • civicrm_membership_type
      • civicrm_price_set
      • civicrm_uf_group
      • civicrm_uf_field
      • civicrm_event

      These warnings include multiple instances of some of the above.

      The code in question (around line 740 in CRM/Core/BAO/SchemaHandler.php) is:

         // Get missing indices
          $missingIndices = array();
          foreach ($missingSigs as $sig) {
            $sigParts = explode('::', $sig);
            foreach ($requiredIndices[$sigParts[0]] as $index) {
              if ($index['sig'] == $sig) {
                $missingIndices[$sigParts[0]][] = $index;
                continue;
              }
            }
          }
      

      Specifically, the problem is with:

      foreach ($requiredIndices[$sigParts[0]] as $index) { 

      Some of the indices in $requiredIndices are localized, whereas the signature that's being used as the key (from $missingSigs) is not.

      For example, $requiredIndices['civicrm_location_type_en_US'] looks like:

      array (
        'UI_name' =>
        array (
          'name' => 'UI_name',
          'field' =>
          array(
            0 => 'name,
          ),
          'localizable' => FALSE,
          'unique' => TRUE,
          'sig' => 'civicrm_location_type::1::name',
        ),
      )
      

      Whereas we're iterating over $missingSigs, where the equivalent item that'll be used as a key for $requiredIndices is: civicrm_location_type::1::name.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              ergonlogic Christopher Gervais
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: