ScheduledJob - Clean up form code & improve validation #26879
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Updates some old form code with better validation of job params.
Before
Api entity only validated against APIv3.
No validation of the api params input, even though it's easy to make mistakes since it's nothing but a textarea!
After
Api params are validated (at least to ensure the input is parseable)
Api entity is validated against whatever version is given in the params
Technical Details
There was no function to parse these params (because, of course there wasn't) so I extracted one from the scheduled job runner for re-use on the form.
While poking around in that
CRM_Core_ScheduledJob
I noticed that it relies heavily on setting undeclared class properties (watch out PHP8!) so added a few and left a TODO comment about the rest.Removed a very large outdated comment block about APIv2.