-
-
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
(REF) dev/core#2571 - Add helper functions for reCAPTCHA extension #20315
Conversation
(Standard links)
|
@mattwire @seamuslee001 @colemanw @totten - so this is an interesting one. With core extensions the goal is that after a (potentially long) transition period they would only interact with core in supported ways. In this case the goal is to interact with the quickforms and these functions have been added to support that. However, we don't actually support any calling of quickForm functions from the quick form hooks (the hooks kinda exist but the contract for what you can do in them is clear as mud). We normally rely on a mixture of paranoia, unit tests & review to prevent too much breakage when extensions interact with forms. The requirement here is to be able to retrieve the ufGroupIDs from the front end forms in a consistent manner - and I think the reason why that would be a good thing is fairly obvious. I am wondering whether we should start to define some supported functions for extensions to access on quickforms - perhaps by adding an interface which then can implement and, if they do, then they would provide what would be a growing list of functions like this - thoughts? |
The interface between forms / extensions has always been rather messy. We standardised a bit when developing some of the entityForm stuff. Effectively we have a number of public We could add:
which would provide a level of consistency and encourage anyone adding support for (eg. captcha) to another form to implement that function. |
I've never regarded our sloppiness in core about using public as meaning that accessing those functions from anywhere outside of tested core code is supported - if we are going to establish some supported interfaces we should be deliberate about it - & document it. I don't know if there is any code-way to demarcate other than being really clear in the comment blocks / developer docs |
Any extension that implements a quickform inherits from |
Well I'll wait & see what others think but I've always understood part of the process of converting stuff to core extensions being figuring out a supported way of doing the things that that they do in extensions - I'm guessing this will be the template for other recaptcha-type extensions so it's the guts of this project not a side issue. I had been wondering about adding supported functions via a object (SupportedInterface) e.g
I think we'd need to be somewhat strict about what could be added to it (eg only functions that return ids or apiv4 style result sets). I guess we could add these functions if we code comment them to say it is NOT supported to access them outside of tested core extension code - then it would unblock you without in any way increasing what people expect us to support - that would punt the issue of a supported version down the road a bit |
As far as I was concerned as an extension developer I considered CRM_Core_Form at the very least to be a supported interface given the hook_civicrm_buildForm, hook_civicrm_validateForm etc hooks that all passed through the form. I would also say that in terms of documentation we already have these pages which demonstrate a number of what I woulc consider as generally supported ways of interacting with Quickforms https://docs.civicrm.org/dev/en/latest/framework/quickform/ https://docs.civicrm.org/dev/en/latest/framework/quickform/entityref/ https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_buildForm/ https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postProcess/ |
@seamuslee001 yeah they do things like
& I agree those are super baked in - but that's different to assuming you can call functions on the form & they won't change |
ie those are very much quick form functions they are calling - which we agree won't change since .... quickform |
@eileenmcnaughton getAction is well ours not quickform civicrm-core/CRM/Core/Form.php Line 1145 in 5db0bc3
|
Hmm - yeah - we could maybe go through the form class & figure out which ones a legitimately supported for non-core use - a lot of them really DO relate the form itself - as opposed to this new front of adding functions that help people access individual form information. Most of those existing things on the base class are well tested already & are also simple + static If we want to start supporting this new type of interface for use outside core I still think we need to be very deliberate about it - in terms of protocols, tests!! & documentation - |
6156649
to
786a963
Compare
@eileenmcnaughton @seamuslee001 I have added a docblock + added a skeleton method to CRM_Core_Form and provided documentation via https://lab.civicrm.org/documentation/docs/dev/-/merge_requests/915 - hopefully this is ok now? |
786a963
to
29bb652
Compare
(etc etc) Lots of good points in this thread so far -- esp about the extent to which IMHO, it's OK to expand the contract of It was quite helpful reading 94366a0 to get some picture of how it would use However, a few issues/questions stick out at me (in no particular order):
I'd love to understand this better before saying more, but I appreciate it's hard to coordinate, so excuse me in jumping-ahead
|
@totten thankyou for the review.
This part is effectively resolved. The extension has the parts necessary to load the reCAPTCHA are already in the extension (buildForm + a validate callback).
This has always been a bit of a mess in core and is very inconsistent. Generally the activation policies are one or more of:
I would like to make those more consistent / configurable but the intention in phase 1 is "move to extension with no functional change". Once it's in one place it becomes much easier to see the different activation policies.
This part is not yet addressed and it's added manually by including a template in the form.
The intention of this PR is to get us to a point where we can move all the I have some ideas but have not yet explored in any detail how a third-party form might add a "captcha" provided by this extension. That is for the next phase! Are we ok to merge this step so we can move forward? |
By the way we have https://lab.civicrm.org/dev/core/-/issues/2571 which is a better place for the wider architecture discussion |
c9af559
to
4a535bb
Compare
Just copying across my response from chat - if the goal here is just to get this merged - then the suggestion I made 2 months back would achieve that & at least arguably punt the need to add unit tests to the follow up PRs |
4a535bb
to
1ebb728
Compare
Now updated with code comment: |
I think you missed the word 'tested' in your comments :-) |
Overview
There are a few simple checks that are used (inconsistently) on each form that adds a reCAPTCHA:
This PR does not make any functional changes. It adds the function
getUFGroupIDs()
, removes unusedhasToAddForcefully()
and addsgetIsCreateMode()
to profile form.Before
Different method required for each form to get a list of UFGroup (profile) IDs.
After
Single function
getUFGroupIDs()
can be called on all forms that implement reCAPTCHA and use profiles.Technical Details
Comments
You can see how this will be used here: 94366a0