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

multiple empty note records created

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.3.5
    • Fix Version/s: 3.3.6
    • Component/s: Core CiviCRM
    • Labels:
      None

      Description

      i found a situation where new empty notes attached to participant records are being created every time the registration is edited and saved. it manifested itself when we exported participants, as the one-to-many relationship between participant and notes caused duplicate records to be exported.

      i've fixed the immediate issue, but want to describe the problem before attaching a patch, as i'm not sure if my solution is how the core team would want to fix it.

      first issue is in CRM_Core_BAO_Note::getNote()
      our sql query adds "note is not null" – what that does is mean any time an empty note record exists, it is not returned by this function and thus not interacted with by whatever component is using it

      altering the query doesn't completely solve the problem.
      in CRM_Event_BAO_Participant::create() we retrieve existing notes via the above, and the pop/flip to get the id. but for a note with a null value, pop/flip doesn't work. which means even though fixing the sql in getNote returns the existing empty note record, we aren't setting $noteIDs['id'] to the existing note id – and thus still create a new note.

      to fix, i altered the sql and then in Participant::create did a quick foreach to retrieve the array key and set as the existing note id. that works.

      one thought I had was to do a better job of making sure a note record is never created if the value passed from the form is empty. but an empty note value is legitimate – if the user is altering an existing value. i.e. if there was an original note value, but the record was edited and the value removed. in that case, we do want to make sure that the empty form value is passed and processed to the existing note. so adding conditions on the content of the form note won't work.

      my fix above works fine. but i suspect code throughout the system would need to be modified to update how getNote is used.

        Attachments

          Activity

            People

            • Assignee:
              sushant Sushant Paste
              Reporter:
              lcdweb Brian Shaughnessy
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: