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

Undefined variable: imProvider in CRM_Core_BAO_Mapping

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.4.5, 4.0.5
    • Fix Version/s: 3.4.6, 4.0.6
    • Component/s: None
    • Labels:
      None

      Description

      I am submitting this here after submitting in the forum after reading that this is the preferred method for an outsider patch.

      I am running CiviCRM 4.0.5 with:

      Drupal 7.7 OK
      Database system MySQL, MariaDB, or equivalent OK
      Database system version 5.1.37 OK
      PHP 5.2.11 (more information) OK
      PHP extensions Enabled OK
      PHP memory limit 256M OK

      When I try to export a mapping that was defined several generations ago. I get this message many times:

      Notice: Undefined variable: imProvider in CRM_Core_BAO_Mapping::buildMappingForm() (line 746 of sites/all/modules/civicrm/CRM/Core/BAO/Mapping.php).

      This same error is also reported in http://forum.civicrm.org/index.php?topic=20437.0. I can not reproduce it on the demo site by creating a new mapping and then reusing it. But perhaps that scenario does not exercise this branch of the if statement.

      I am wondering if this might be a true bug. It is in a nested if statement and perhaps that path is not commonly triggered. I only partially understand the code in Mapping.php but it seems that imProvider really is not initialized.

      Programming by analogy suggests the following patch which may not be logically correct, but since it forces a value for imProvider it does remove the error. Perhaps the question is if mappingIMProvider is analogous to mappingPhoneType.

      Patch here and in attachment.

      diff --git a/mmm-civi/sites/all/modules/civicrm/CRM/Core/BAO/Mapping.php b/mmm-c
      index 45cdfd2..e205ed8 100644
      — a/mmm-civi/sites/all/modules/civicrm/CRM/Core/BAO/Mapping.php
      +++ b/mmm-civi/sites/all/modules/civicrm/CRM/Core/BAO/Mapping.php
      @@ -727,6 +727,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping
      $noneArray[] = array( $x, $i, 2 );
      } else {
      $phoneType = isset($mappingPhoneType[$x][$i]) ? $mappingPhoneType[$x][$i] : null;
      + $imProvider = isset($mappingImProvider[$x][$i]) ? $mappingImProvider[$x][$i] : null;

      if ( !$locationId && in_array($mappingName[$x][
      $locationId = " ";

      Looking at the code also brings up two additional questions.

      1. Should imProvider also be included in the defaults array a few lines below this patch?
      2. Should the other branch of the if statement have some similar code?

        Attachments

          Activity

            People

            • Assignee:
              rajan Rajan P Mayekar
              Reporter:
              ehowland Eric Howland
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: