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

Remove "Copy Case custom data" code (circa 2013) #15051

Merged
merged 2 commits into from
Aug 20, 2019

Conversation

jusfreeman
Copy link
Contributor

@jusfreeman jusfreeman commented Aug 16, 2019

Overview

Unable to merge Contacts and Cases with Case custom data, raises an error - DB Error: already exists (applies to CiviCRM 5.16.0 - CiviCRM 5.18.alpha1). See https://lab.civicrm.org/dev/core/issues/1183 for more details.

Before

Unable to merge Contacts and Cases with Case custom data, raises an error - DB Error: already exists.

Steps to reproduce:

  1. Create Contact A and Contact B
  2. Create custom fields for the Case Type
  3. Create a Case for Contact A
  4. Select the Case Type with the custom fields. Populate the custom fields.
  5. Create a Case for Contact B
  6. Select the Case Type with the custom fields. Populate the custom fields.
  7. Search for Contact A/B
  8. Merge Contact A/B
  9. Observe the DB Error: already exists and merge fails to complete

After

Can merge Contacts and Cases with Case custom data without error.

Technical Details

Removes code introduced with #1204 - CRM-11662 Add missing logic to copy case custom fields in CRM_Case_BAO_C... #1204

Comments

Happy to say goodbye to old code.

Agileware Ref: CIVICRM-1290

@civibot
Copy link

civibot bot commented Aug 16, 2019

(Standard links)

@civibot civibot bot added the master label Aug 16, 2019
@jusfreeman
Copy link
Contributor Author

Credit to @eileenmcnaughton for finding where to fix this!

@yashodha
Copy link
Contributor

@jusfreeman tested this, works fine.

@demeritcowboy
Copy link
Contributor

@jusfreeman jusfreeman changed the title CIVICRM-1290 Remove "Copy Case custom data" code Remove "Copy Case custom data" code Aug 16, 2019
@jusfreeman
Copy link
Contributor Author

I'll update this PR to include the unit test from #14213

@jusfreeman jusfreeman changed the title Remove "Copy Case custom data" code Remove "Copy Case custom data" code (circa 2013) Aug 16, 2019
@eileenmcnaughton
Copy link
Contributor

@jusfreeman can you please also target the 5.17 branch rather than master as this is a regression

@eileenmcnaughton eileenmcnaughton changed the base branch from master to 5.17 August 16, 2019 21:27
@civibot civibot bot added 5.17 and removed master labels Aug 16, 2019
@eileenmcnaughton
Copy link
Contributor

Hmm that wouldn't apply cleanly on master - I switched to 5.17 & still

[GitScan\Exception\ProcessErrorException]
Process failed:
[[ COMMAND: git apply --check --ignore-whitespace ]]
[[ CWD: /home/jenkins/bknix-dfl/build/core-15051-6faa5/web/sites/all/modules/civicrm ]]
[[ EXIT CODE: 1 ]]
[[ STDOUT ]]
[[ STDERR ]]
error: patch failed: tests/phpunit/CRM/Case/BAO/CaseTest.php:170
error: tests/phpunit/CRM/Case/BAO/CaseTest.php: patch does not apply

Can you do ```git pull --rebase origin/5.17``

@jusfreeman
Copy link
Contributor Author

@eileenmcnaughton that OK now?

@eileenmcnaughton
Copy link
Contributor

It's running - assuming it passes we will backport to 5.16 & drop a 5.16 release early next week

@jusfreeman
Copy link
Contributor Author

Great, back to my Weetibix then... nom nom nom. 🥄

@eileenmcnaughton
Copy link
Contributor

@jusfreeman failure relates :-(

@demeritcowboy
Copy link
Contributor

The problem is the file doesn't actually exist in the filesystem, so when copyGeneric (indirectly) calls CRM_Core_BAO_File::path() it returns nulls. Assuming the test system allows creating files, change the lines where you set fileA and fileB to something like:

    $path1 = Civi::paths()->getPath('[civicrm.files]/custom/test_file_uri');
    $path2 = Civi::paths()->getPath('[civicrm.files]/custom/test_file_uri_2');
    system('touch ' . $path1);
    system('touch ' . $path2);
    $fileA = $this->callAPISuccess('File', 'create', array(
      'uri' => $path1,
    ));
    $fileB = $this->callAPISuccess('File', 'create', array(
      'uri' => $path2,
    ));

Works for me.

@demeritcowboy
Copy link
Contributor

Just realized my C background took over for a second. Of course file_put_contents() would be a php way to create a file instead of system().

@eileenmcnaughton
Copy link
Contributor

@jusfreeman are you on this test - will try to get 5.16.x patch release out in next few days if this is merged

@jusfreeman
Copy link
Contributor Author

Yes, will update PR to get that pesky unit test passing.

@yashodha
Copy link
Contributor

@jusfreeman there seems to be a test failing. Also, can you squash all your commits?

@demeritcowboy
Copy link
Contributor

Cool I can see from the test log it's passing now. Guess the parent path is what it didn't like and wants it to be in civicrm/custom. Nice @jusfreeman!

https://test.civicrm.org/job/CiviCRM-Core-PR/28426/consoleText:
...
ok 75 - CRM_Case_BAO_CaseTest::testCaseReassignForCustomFiles

@eileenmcnaughton
Copy link
Contributor

@jusfreeman might be worth squashing the commits now if it has got past the sticking per per above

@eileenmcnaughton
Copy link
Contributor

erm - no - that didn't do it

@eileenmcnaughton
Copy link
Contributor

oh - I think you rebased in master commits.... this is against 5.17

…ts to new case on reassignment

Add unit test from PR civicrm#14213 Migrate custom file attachments to new case on reassignment. civicrm#14213
@jusfreeman
Copy link
Contributor Author

@eileenmcnaughton @demeritcowboy @yashodha @seamuslee001 thanks for all your support and encouragement along the way. It's been an interesting journey and I think this is done now.

@seamuslee001 seamuslee001 merged commit ebd5fc3 into civicrm:5.17 Aug 20, 2019
@eileenmcnaughton
Copy link
Contributor

May you live in interesting times :-)

eileenmcnaughton added a commit that referenced this pull request Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants