Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct inconsistent fileID reference #12931

Merged
merged 1 commit into from
Oct 14, 2018

Conversation

mecachisenros
Copy link
Contributor

Overview

Correct inconsistent $fileID reference causing new File entity creation when updating a Contact's custom field of type File.

Before

Steps to reproduce:

  1. Create a custom field of type File for Contacts entity.
  2. Create a file through the API:
$file = civicrm_api3('File', 'create', [
  'document' => "An attachment.",
  'mime_type' => "text/plain",
  'uri' => "some_attachment.txt",
]);

// result
    ...
    "values": {
        "id": "80",
        "mime_type": "text/plain",
        ...

  1. Update a Conctact's custom File field ( ie Attachment, custom_13) through the API passing the created file_id in step 1:
$contact = civicrm_api3('Contact', 'create', [
  'contact_type' => "Individual",
  'id' => 203,
  'custom_13' => 80,
]);

// result
    ...
    "values": [
            "contact_id": "203",
            "custom_13": "81", // file id 81, a new file has been created
            ...

After

The custom File (custom_13) is updated with the passed file_id as expected.

Technical Details

N/A

Comments

N/A

@civicrm-builder
Copy link

Can one of the admins verify this patch?

@civibot civibot bot added the master label Oct 13, 2018
@civibot
Copy link

civibot bot commented Oct 13, 2018

(Standard links)

@seamuslee001
Copy link
Contributor

Jenkins ok to test this

@seamuslee001
Copy link
Contributor

ping @jitendrapurohit @eileenmcnaughton

@kcristiano
Copy link
Member

I tested this on Drupal 7 and WP. I can recreate the issue without the patch, and once patched custom files are created correctly and when updating/creating the contact record the same id created is attached.

  • (r-explain) Pass
  • (r-test) Pass
  • (r-code) Pass
  • (r-doc) Pass
  • (r-maint) Pass
  • (r-run) Pass: tested via API using drush and cv on Drupal 7 and WP. Also tested via editing and updating Contact via UI (direct Edits) and via Profile.
  • (r-user) Pass
  • (r-tech) Pass: Changes should not affect external calls as they should use file_id which has not changed

@seamuslee001
Copy link
Contributor

Merging as per @kcristiano 's testing

@seamuslee001 seamuslee001 merged commit 098656a into civicrm:master Oct 14, 2018
@seamuslee001
Copy link
Contributor

thanks @mecachisenros and @kcristiano

@mecachisenros
Copy link
Contributor Author

thank you @seamuslee001 and @kcristiano

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants