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

Fix ACLs to use the correct name of the civicrm_group table #26615

Merged
merged 1 commit into from
Jun 23, 2023

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Jun 23, 2023

Overview

Fixes a weird quirk in the ACL code.

Technical Details

For unknown historical reasons, group-based ACLs incorrectly used 'civicrm_saved_search' as the value for 'object_table' when referencing a Group (the correct name of that table is 'civicrm_group').

This updates all ACL records, tests, and strings.

Hook Update: Unfortunately that incorrect value was being passed to hook_civicrm_aclGroup. This PR deals with that by calling the hook twice with both values. If your hook listener responds to the old 'civicrm_saved_search' value, it will emit a deprecation notice.

@civibot
Copy link

civibot bot commented Jun 23, 2023

(Standard links)

@civibot civibot bot added the master label Jun 23, 2023
@seamuslee001
Copy link
Contributor

ping @MegaphoneJon this maybe relevant to your things

@@ -1477,8 +1477,7 @@ public function testCreateWithLesserPermissions() {
* this from civicrm_generated.mysql
*/
private function setUpACLByCheating() {
CRM_Core_DAO::executeQuery("INSERT INTO civicrm_acl (name, deny, entity_table, entity_id, operation, object_table, object_id, acl_table, acl_id, is_active) VALUES ('Edit All Contacts', 0, 'civicrm_acl_role', 1, 'Edit', 'civicrm_saved_search', 0, NULL, NULL, 1)");
CRM_Core_DAO::executeQuery("INSERT INTO civicrm_acl (name, deny, entity_table, entity_id, operation, object_table, object_id, acl_table, acl_id, is_active) VALUES ('Core ACL',0,'civicrm_acl_role',0,'All','access CiviMail subscribe/unsubscribe pages',NULL,NULL,NULL,1)");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@demeritcowboy why did you include this? :) object_id surely should be an id not a string right? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's null, and I took it straight out of civicrm_generated, but the removed "Core ACL" line is necessary for the test above to work if I remember right. The test may now ALWAYS pass which wasn't the intent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to doing the test a different way - it might be useful to have the test installs mirror more closely a real install for ALL tests.

Copy link
Member Author

@colemanw colemanw Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@demeritcowboy the line I removed in the test is also being removed from real databases by this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I see. I'll do a followup after since the test isn't completely useless but it's not testing what it was testing and the ACL part of it now is a bit misleading.

@seamuslee001 seamuslee001 added merge on pass merge ready PR will be merged after a few days if there are no objections and removed merge on pass labels Jun 23, 2023
For unknown historical reasons, group-based ACLs incorrectly used 'civicrm_saved_search'
as the value for 'object_table' when referencing a group id.

This updates all ACL records, tests, and adds legacy handling for hook subscribers with a noisy deprecation notice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants