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

dev/core#4993 block Sync CMS Users form and functionality on Standalone #29351

Merged
merged 4 commits into from
Mar 6, 2024

Conversation

ufundo
Copy link
Contributor

@ufundo ufundo commented Feb 9, 2024

Overview

Block CMS user sync form when using Standaloneusers extension, because it doesn't do anything. And the most secure code is no code.

There was a note about the case when the contact of a user was deleted -- but deleting a contact with a user attached is prevented with #29026

Copy link

civibot bot commented Feb 9, 2024

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the master label Feb 9, 2024
Copy link

civibot bot commented Feb 9, 2024

The issue associated with the Pull Request can be viewed at https://lab.civicrm.org/dev/core/-/issues/4993

@ufundo ufundo force-pushed the no-cms-sync-on-standalone branch from ef3c3dd to 662ec86 Compare February 9, 2024 15:53
$config = CRM_Core_Config::singleton();
if ($config->userFramework === 'Standalone') {
throw new \Exception('No CMS to sync users to when using CiviCRM Standalone');
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is a draft but just noting two things:

  • A year or two ago we tried to remove most of the if Drupal from various files to make it more OO-ey. I know in standalone sometimes it hasn't booted yet and so there's no choice, but here I think it would be better to do something like if !$config->userSystem->allowsUserSync() and then CRM_Utils_System_Base::allowsUserSync would return true, and CRM_Utils_System_Standalone::allowsUserSync() would return false. In theory this also allows mocking both variations in backend unit tests (although it's not currently set up for more than one unittest mock).
  • In forms we usually use CRM_Core_Error::statusBounce instead of throwing exceptions. Even if it were to throw an exception it's preferred to use CRM_Core_Exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for these pointers 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This got me thinking -- it's specifically standaloneusers that the syncing is incompatible with. So I've made it conditional on that, leaving open the door for alternatives where syncing is a thing (external auth providers maybe?)

Copy link
Contributor

Choose a reason for hiding this comment

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

@ufundo 🤯 I think external auth providers might be dealt with in a way other than replacing the whole of standaloneusers. But ok!

@ufundo ufundo force-pushed the no-cms-sync-on-standalone branch from dab1344 to 7da08f0 Compare February 23, 2024 15:49
@ufundo ufundo force-pushed the no-cms-sync-on-standalone branch from 7da08f0 to 6e8e15f Compare February 23, 2024 15:55
@ufundo ufundo force-pushed the no-cms-sync-on-standalone branch from 6e8e15f to 7d8c738 Compare February 23, 2024 15:58
@ufundo ufundo marked this pull request as ready for review February 23, 2024 15:59
@artfulrobot
Copy link
Contributor

Tested, this does hide the menu item and prevent access to the page. Merging, thanks @ufundo

@artfulrobot artfulrobot merged commit ef3fc7f into civicrm:master Mar 6, 2024
3 checks passed
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.

3 participants