Problem/Motivation
The following functions in field.module have 'private' namespaces indicated by the preceding underscore. These would be useful as public functions for contib modules to use.
Proposed resolution
For D8, rename the functions to remove the underscores from the names. Current patch is in #1174444-23: Make the _element_validate_* functions in field.module available for all contrib modules to use.
For D7, additionally provide backwards-compatible wrappers for these functions with the original names, and document that these variants are deprecated. Current patch is in #1174444-22: Make the _element_validate_* functions in field.module available for all contrib modules to use.
Remaining tasks
A broader discussion of the technique for "forwards compatibility" used here is in #1221904: RFC: forwards compatibility in D7 / 'backports' defgroup, so take this into consideration when evaluating the patch for D7.
User interface changes
None.
API changes
Minor, backwards-compatible addition only. No existing code will be affected.
New supported function names for validation functions:
- element_validate_integer()
- element_validate_integer_positive()
- element_validate_number()
Since the backwards-compatible wrappers are still available (and the functions were previously "private" anyways), existing modules will not be impacted directly. However, modules should use the new function names moving forward.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | 1174444-23-D8-element-validate-public.patch | 7.09 KB | xjm |
| #22 | 1174444-elment-validate-public-22.patch | 7.72 KB | xjm |
| #19 | 1174444-element-validate-public-19-D7.patch | 7.72 KB | boobaa |
| #10 | 1174444-element-validate-public-D7.patch | 5.87 KB | boobaa |
| #1 | 1174444-element-validate-public.patch | 7.74 KB | dave reid |
Comments
Comment #1
dave reidEventually we'll want to deprecate these and use the proper #numberfield with #min and #max properties/validation once it lands via #675348: META: Support HTML5 form input elements.
Comment #2
boobaaSubscribing; this would be warmly welcomed, eg. for #589440: Reordering fails with more than 31 book pages in a book, too. Additionally, I think this should even be backported to D7, at least.
Comment #3
boobaaCorrecting myself: the patch does not need to be backported to D7 as it applies cleanly, without offsets. Anyways, the RTBC still stands.
Comment #4
dries commentedWhile this is an API change, I think it may be an acceptable one. It certainly makes sense to commit this patch to 8.x. Let's see what others have to say though.
Comment #5
tstoecklerActually this is not an API change, but an API addition, as the private functions are not part of the public API. Tagging as such, and re-tagging as backportable, so as not to forget.
RTBC +1
Comment #6
tstoecklerI should listen to myself better!
Comment #7
boobaaDon't know the exact meaning of "needs backport to D7" tag properly, but the patch in #1 applies cleanly to D7 as well, as mentioned in #3, without other side effects: the patch addresses all the occurences of the functions mentioned in OP.
Comment #8
tstoecklerTagging it as "needs backport to D7" is a quick indicator for reviewers and committers that this issue should be committed to D7 as well. It's not necessarily related to actually porting the patch.
Comment #9
webchickI'd be ok with a D7 patch that didn't remove the old functions.
But this seems clearly to be a feature request, which means it gets looked at after our critical count gets down to <= 15.
Comment #10
boobaaHere you are.
Comment #11
tstoecklerI don't see why we shouldn't remove the old functions. People that call these functions are not using the public API. They are on their own and they know that. If we treat these functions as public API we should roll a patch for D8 to remove all underscores from all functions in core.
Comment #12
webchickThey might know that, but their hapless users, who upgrade to Drupal 7.3 and are greeted with a fatal error they have no method of recovering from certainly won't know that.
Comment #13
dave reidYeah I'm not in favor of removing them from D7. We could rename them and make the old private versions as a wrapper for the renamed public versions. Also doc the private ones as deprecated.
Comment #14
tstoecklerIt's against our naming convention, against every piece of documentation ever written, and against common sense, but knock yourselves out...
Comment #15
dave reidNot sure what is wrong about #13:
Comment #16
webchickYep. #13/#15 is what I was thinking of. Not sure why this inspires such rage. ;)
Comment #17
tstoecklerNo rage involved :). Just don't expect me to roll this patch.
Comment #18
boobaaOK, I'm gonna roll this soonish; in the meantime I don't know why webchick changed component to token, so reverting. ;)
Comment #19
boobaaHere it is.
Comment #20
catchThis is blocking #589440: Reordering fails with more than 31 book pages in a book which is a major bug, and according to that issue Views is already using the private functions. Since there's a perfectly good patch there, it seems a shame to stall that one.
Patch looks completely fine to me, both the D7 patch in #19 and the D8 patch in #1.
Bumping to 'major' and task since it's holding up the book issue.
Comment #21
xjmPatch applies with offset to D8 and D7. I'll reroll it.
Edit: I also added an issue summary.
Comment #21.0
xjmAdded issue summary.
Comment #21.1
xjmClearer emphasis that it is a minor addition, not a change.
Comment #21.2
xjmAdded link to meta issue.
Comment #22
xjmComment #23
xjm#22 is for 7.x. This is a reroll of the patch for 8.x (which does not need the wrappers).
Comment #23.0
xjmTypo.
Comment #24
dries commentedThanks all. I committed this patch to 8.x. Moving to 7.x so we can consider the back-ported patch with the extra wrappers.
Comment #25
webchickI think the patch makes sense for D7. But the wrappers are definitely necessary since Views (at least) is using the old names.
Committed and pushed #22 to 7.x. Thanks!
Comment #26
yched commentedCompletely missed that thread. W00t !
Comment #27.0
(not verified) commentedUpdated issue summary.