-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Code fix and Test for dev/searchandreport#53 #19619
Code fix and Test for dev/searchandreport#53 #19619
Conversation
Can one of the admins verify this patch? |
(Standard links)
|
add to whitelist |
@@ -57,3 +57,4 @@ sql/dummy_processor.mysql | |||
distmaker/distmaker.conf | |||
distmaker/out | |||
/tmp | |||
/.idea/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I tried to add this one years ago & got told then I should do a local global gitignore https://docs.github.com/en/github/using-git/ignoring-files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the guide. The suggested change was a sign of my lack of control over .gitignore rather than a serious recommendation.
@alistairjames There's a bunch of styling errors preventing the tests from running. Beside the red failure notice here click on Details and then click on warnings and then on details. |
Ouch. I will work through this slowly and get it right - give me a little time. |
I'm running into a crash when you choose to Display As Cases and then just expand the activities section (can choose something but don't even need to fill in any fields anywhere to see it). If I give the table an alias inside the added function it seems better, e.g. And it's not technically wrong but style-wise usually civi doesn't have code that uses
|
I see the crash also. I am reasonably competent in SQL, but have never seen anything quite as involved as the query generated by the code, which I copied into issue #53 (https://lab.civicrm.org/dev/report/-/issues/53). So my proposed solution was always something of sticking plaster. I will step through to find where exactly the exception arises and report back. The '\n' was just for readability of the SQL query generated and so not part of my code syntax, but it is helpful to know the standard PHP line continuation. I did get civilint to give a report of syntax errors, having failed to get PhpStorm configured correctly. |
Getting phpstorm configured is definitely do-able - I've just reconfigured it for my docker instance - maybe something in here will help https://docs.civicrm.org/dev/en/latest/tools/phpstorm/ |
The SQL query generated with Display as Cases and the Activities section expanded fails when offered directly to the database in MySQL Workbench with Error Code 1066. Not unique table/alias: 'civicrm_case_activity' SELECT count( DISTINCT civicrm_case.id ) as rowCount FROM civicrm_contact contact_a LEFT JOIN civicrm_case_contact INNER JOIN civicrm_case LEFT JOIN civicrm_relationship case_relationship LEFT JOIN civicrm_relationship_type case_relation_type LEFT JOIN civicrm_activity_contact LEFT JOIN civicrm_activity INNER JOIN civicrm_contact INNER JOIN civicrm_case_activity INNER JOIN civicrm_activity case_activity LEFT JOIN civicrm_option_group option_group_case_status LEFT JOIN civicrm_option_value case_status LEFT JOIN civicrm_case_type INNER JOIN civicrm_case_activity WHERE ( civicrm_activity.status_id IN ("1", "2") |
I have added a comment to https://lab.civicrm.org/dev/report/-/issues/53, and will revise this fix when I have shown there that I have found the correct place at which to amend the code. I have added a request for suggestions now that I understand the underlying basis of the problem, and have some different ideas about how it could be fixed. I will update the code here after I have received some feedback and have something implemented. |
Closing this as I think that was the conclusion over in gitlab |
Overview
This change is to fix a problem in the Advanced Search described in this issue:
https://lab.civicrm.org/dev/report/-/issues/53
Before
An Advanced Search (constructed using the user interface) to collect Activities using the criteria:
Contact + ActivityType + ActivityStatus + CaseType
failed and collected all the Activities of the selected ActivityType and Status in any of the Cases involving the Contact.
The error was tracked to a missing join involving the civicrm_case_activity table. After manually testing, no other missing joins were found. (The same bug affected the results from searches constructed with the Search Builder).
After
The error was fixed by adding a helper method to append an additional join statement to the end of the fromClause when both civicrm_case and civicrm_activity were listed in the $tables array used to generate the fromClause in the method:
CRM/Contact/BAO/Query::fromClause()
The change also fixed the behaviour of the Search Builder, so that the correct list of Contacts was returned for searches of the same type as above.
Technical Details
Notes on the phpunit test created.
Comments
As someone quite new to PHP as a language. I am happy the fix works, and will not be at all offended if the code is radically restructured.