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

acl_role_id field is improperly aliased to id field in the aclRole API

    Details

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

      Description

      CiviCRM has some API magic which automatically aliases arguments such as contact_id (i.e., a foreign key in one table) to id (i.e., the name of the field in the contact table). Basically, CiviCRM assumes that if a parameter is named something_id and the name of the entity in question is something, then what you really must have meant to do is pass that value for the entity's id field.

      This magic is helpful in chaining together APIv3 calls, but it is problematic when the entity in question actually has a field named entity_id. One such entity is the aclRole, which has both an id field (the unique table ID) and an acl_role_id field (foreign key to ACL role, which is an option value pair and hence an implicit FK).

      The result is that the parameter becomes unusable. API calls submitted as:

      $result = civicrm_api3('AclRole', 'create', array(
        'acl_role_id' => 15,
        'entity_table' => 'civicrm_group',
        'entity_id' => 4,
      ));
      

      ... are interpreted as though the following had been submitted:

      $result = civicrm_api3('AclRole', 'create', array(
        'acl_role_id' => '',
        'id' => 15,
        'entity_table' => 'civicrm_group',
        'entity_id' => 4,
      ));

      I'm flagging this as a minor bug since the workaround is to use the BAO instead... unless of course you're trying to integrate with CiviCRM via REST/JS.

        Attachments

          Activity

            People

            • Assignee:
              pittstains Frank J. Gómez
              Reporter:
              pittstains Frank J. Gómez
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: