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

API reports required variables with a value of zero as missing

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.4.1
    • Fix Version/s: 3.4.2
    • Component/s: CiviCRM API
    • Labels:
      None

      Description

      When creating an OptionValue via. API v3, a the weight attribute must be specified in order to pass the mandatory fields check. This is correct, as defined in the DAO.

      However, the mandatory_fields check uses empty() to evaluate each field in turn. In the case of weight, '0' is valid. However, PHP classes 0 as an empty value.

      In such a circumstance, 0 is actually correct and has a semantic meaning.

      Proposed patch for this bug is attached. However, I am unsure whether this is sufficient enough to allow robust validation.

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              tomgillett Tom Gillett
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: