Background
- From #1696946: Rename field modules to [type]_field:
Proposed solution (long-term)
Convert all built-in fields in core into field plugins, provided by Field module itself.
- The goal of #2150511: [meta] Deduplicate the set of available field types is to merge the set of field types used by "base fields" and configurable fields.
- De facto, this would move most "basic" field types into Core/Field.
Objective
- As a preparation step for that, merge the simple field types (modules) into the Field module.
- Doing so requires to adjust a lot of tests to no longer try to enable/install the corresponding field type modules, but Field module instead.
Details
-
The majority of the field type .module files are almost empty:
-
They're just providing
- Help → obsolete
- Libraries → move/merge
- Conditional field info/formatter adjustments → obsolete (hopefully)
-
Only the following field modules are more complex:
-
By moving the simple field type plugins directly into Field module, we can
- Vastly simplify the user interface and experience.
- Get rid of some ugly circular dependency hell.
Aside from tests, doing this should be a really trivial patch.
Comment | File | Size | Author |
---|---|---|---|
#56 | move_simple_field_types-2202925-56.patch | 185.35 KB | njbarrett |
#52 | 2202925-simple-fields-52.patch | 106.15 KB | njbarrett |
#42 | 2202925-simple-fields-42.patch | 50.06 KB | andypost |
#23 | 2202925-simple-fields-23.patch | 19.47 KB | andypost |
Comments
Comment #1
sunComment #2
sunComment #3
sunI intentionally excluded Options module, because options.module contains too much legacy cruft that should not live in the .module file in the first place → needs to be cleaned up before we can move Options.
Comment #5
sunFixed bogus/obsolete moduleExists() checks in hook_field_info_alter().
Comment #7
sunFixed bogus/obsolete dependencies on field type modules.
Comment #9
sunComment #10
andypostWill need re-roll after #2198917: Use the string field type for the node title field
Comment #12
sunUpdated $modules property of tests.
Comment #14
longwaveRebased against latest HEAD, and fixed one set of fails.
Not sure what to do about Drupal\field\Tests\reEnableModuleFieldTest - this test seems like it needs further work outside this issue, as disabling and re-enabling modules is no longer supported, and this test doesn't really do what it claims any more.
Comment #15
longwaveCreated #2204153: Remove or repurpose reEnableModuleFieldTest
Comment #17
andypostThe meta now move duplicated field types to Core
Comment #18
andypostemail and number modules are moved to Core #2218199: Move email and number field types to \Drupal\Core\Field, remove modules
Comment #19
sunWhy did we only move email and number into core?
At least link and telephone are equally simple?
Text is theoretically too, although text.module contains the much-behated
text_summary()
function, which could be moved into a helper class (or ideally killed and replaced altogether with a new + proper re-implementation).Only Options module is basically blocked on #2171397: Move options_allowed_values() to a method somewhere ?
Comment #20
BerdirBecause that issue was/is not about simple/not simple, it's about *duplicate* field types, we had a email type in Core and then email.module extended it and we have integer/float field types in Core\Field and number. Also, we wanted to get that in as a first step. The meta is still open.
Moving more to Core\Field is fine with me.
Comment #21
yched CreditAttribution: yched commentedRepurposing, then. Moving some field types to field.module would make little sense now that Core/Field has most of them.
Comment #22
andypostSo datetime, link and telephone could be moved to Core/Field
options and text - still needs some polish
image and file - is not simple
Comment #23
andyposttelephone field, in
FieldImportDeleteUninstallUiTest
moduke is replaced withoptions
Comment #25
andypostFix broken test, now test able to use field_test module.
Converted a link module
Comment #26
andypostDatetime module is tricky, it has collision with #2226493: Apply formatters and widgets to Node base fields but probably
datetime_form_node_form_alter()
could be removed here or in context of #2150511: [meta] Deduplicate the set of available field typesAlso filed #2331783: hook_ENTITY_TYPE_prepare_form() is not documented
Comment #28
andypostFix broken test and outdated @todo (once touched)
Comment #29
yched CreditAttribution: yched commentedVery much +1, but won't be able to review before DC Amsterdam, so I hope someone else can.
Also, there are two patches in the RTBC queue that, combined, remove almost all code from the datetime.module file (sorry, browsing issues & pasting links from my phone is super tedious :-/)
[edit: sorry, one of them, that moves helper #validate callbacks into the widget classes, is not RTBC yet actually]
Comment #30
andypostPostponed #2331961: Move datetime module into Core/Field on both issues.
This is a separate issue because api changes:
1) removal of
datetime_date_default_time()
2) conversion of
DATETIME_*
constzComment #31
BerdirNot sure what this @todo was about exactly and how that issue was related, but it looks like a useful test to me.
No need to keep an empty array around.
Same here.
Woah, weird class name.
I don't think we need to keep that comment around then or at least not the admin/modules part. Interesting side effect of the removal of hidden for test modules, though...
I don't remember what we did for other help texts, like email_help(). Did we jus just remove them too? Maybe part of it should be moved to field_help() ? There seems to be some useful explanation here, unlike email had.
I will ask @jhodgdon to comment on this.
Comment #32
andypost1) That's why I remove the @todo because this is only test that tests fieldability of content blocks, otoh
BlockContentCreationTest
uses body field on block2) fixed
3) fixed
5) changed comment to point that we are able to use test module for the test, seems a time ago test modules are not displayed at module's page. So while test modules are visible...
6) Looking at #2218199: Move email and number field types to \Drupal\Core\Field, remove modules we simply remove this, but it makes sense to file follow-up to return all of them somehow but not in field module...
Comment #33
BerdirIMHO, it makes sense in field.module, because it is documentation for site builders on how those field types can be used as configurable fields. That is still field.module specific.
Comment #34
andypostFiled follow-up #2332687: Lost help for field types from Core/Field
Comment #37
andypostre-roll
Comment #38
jhodgdonRegarding the hook_help(), we do definitely need to have help describing the available field types. Rather than just removing the hook_help() entirely, probably this should be added to the Field module help. Some of the field modules' hook_help() had specific help on configuration options, which would be a shame to lose.
Comment #39
andypost@jhodgdon is there any idea where to put the removed help?
field module help better left in separate issue
Comment #40
jhodgdonPrevious to this effort of moving field types into Core/Field, if you went to admin/help/field, you would get a list of enabled modules that provide fields/widgets (for some reason not including formatters??), with a link to their module help pages, so you could click through to get more help:
This list is generated in function field_help() in field.module.
So what I think we need to do is:
a) Rewrite this help text so that it mentions that some field types, formatters, and widgets are provided by Drupal Core without even enabling a module. Right now it doesn't even say this.
b) If any of the previous patches on this effort removed useful information that was previously in the module help for these fields/widgets, add it to the Field module help. Same for any future field modules that are being removed in this effort, such as Telephone, which definitely does have specific information that shouldn't be lost.
Comment #41
andypostre-roll, well discus the way to move hook_help() tommorow
Comment #42
andypostImplemented a part of #40a - added a list of core field types.
There's no place to put a removed hook_help parts but there's a bug in
field_help()
- no closing DLI think we should properly fix that in #2332687: Lost help for field types from Core/Field
Comment #43
jhodgdonThanks @andypost!
I took a look at your patch, mostly looks great!
A few nitpicks:
a) core/config/schema/core.entity.schema.yml has newlines between the new schema items you added, but not one before the first schema item you added:
Be consistent?
b) field_help():
I'm not sure I'm happy with the "... additional modules and core" wording. ... I think it would be fine if it said "Drupal core" instead of just "core". I just don't think that readers of this help know what "... and core" really means.
c) field_help()
Is this still true?
d) field_help()
I believe that item lists can have headers. It would be better to put the "Field types provided by core" in as a header, because I think there are some accessibility concerns? I guess this should be done with the field modules list as well?
e) If we are going to display the descriptions of fields in this list we need to make sure that they have descriptions that are readable and appropriate for help. Things like "An entity field containing a boolean value" are not OK. I guess that can be filed as a separate issue, but the more things we put off to separate issues, the less likely they are to be fixed at all. Most of these descriptions look like developer-speak and not end-user-speak... so either we need to fix them so they are aimed at end users (and document this somewhere in the Field annotation class too!), or if they are aimed at developers we should not be displaying them in hook_help().
f) core/modules/field/src/Tests/FieldImportDeleteUninstallTest.php
The changes to this file are very confusing...
Comment needs updating?
g) same file
If the first change is using the filter module for this test, shouldn't the others be? And I thought the text fields were being moved to core and that module was going away?
h)core/modules/field/src/Tests/reEnableModuleFieldTest.php
Huh? Confusing comment.
Comment #44
yched CreditAttribution: yched commentedTotaly agreed with the need to come up with good, non-dev-lingo descriptions for those, but I don't think we can reasonably put that in the scope of that issue, or make it a pre-requisite. That's an issue of its own, and we should move forward with moving the field types to Core before that.
Comment #45
jhodgdonRight now there is no viable strategy for retaining the help that we have now for these modules, which includes a coherent, user-friendly description of the fields and in some cases, some necessary help on how to use them.
I fundamentally disagree with proceeding on this patch without also moving the *existing* documentation to someplace where users can find the information. We already have written the text (it is in the hook_help()). It needs to be moved someplace where it can still be accessed through hook_help(), not discarded. We should not regress on the existing help just because it seems nicer or cleaner to have these fields in core instead of in modules, where as far as I know, they are working fine and not causing loads of trouble.
But that will be a decision for another core maintainer. I've stated my objections...
Comment #46
yched CreditAttribution: yched commented@jhodgdon: #44 was not about losing existing help, it was about proceeding here without having to polish the "descriptions" of all existing core field types as a preliminary.
Comment #47
jhodgdonBut we are losing existing help. The short descriptions we had previously, when you clicked the links to the previously-existing field modules, have vanished, and they've been replaced in this patch by incomprehensible developer-oriented descriptions.
Comment #48
jhodgdonWe now have a strategy for replacing this help. See the issue summary in #2332687: Lost help for field types from Core/Field.
Basically, on that issue I'm going to add a patch to field_help() to add a section to put this help in. For now, we decided the only information that got lost was from the Number module help, so I'll put that in the section. I'm going to write a patch right now for that.
On this issue, what we'll need to do is: as fields are removed, if they have details in their hook_help() that are important for UI users to know, add notes to that same help section.
Comment #49
jhodgdonAnd on comment #27 on that other issue, here's an overview the information that was identified that we wouldn't really like to lose as we lose the modules:
Comment #50
andypostAs #2332687: Lost help for field types from Core/Field got commited we can move here, but now removal of telephone module is a question
Comment #51
jhodgdonRight, if any of the 4 modules listed in #49 is being removed, the information listed in #49 should be added to the field_help() function, similar to what was done for Number... It looks like the current patch is removing Link and Telephone modules. I'm not sure about the others?
Comment #52
njbarrett CreditAttribution: njbarrett commentedRerolled on 8.0.x
Comment #53
njbarrett CreditAttribution: njbarrett commentedComment #55
andypostpatch looks strange because it is twice bigger
Comment #56
njbarrett CreditAttribution: njbarrett commentedTrying again
Comment #57
njbarrett CreditAttribution: njbarrett commentedComment #59
njbarrett CreditAttribution: njbarrett commentedIt seems core has changed significantly, I don't have the knowledge to fix up the patch here.
Comment #60
BerdirI think the patch is just that big because you haven't set up git diff properly to deal with moving files. See https://www.drupal.org/documentation/git/configure, the part about rename.
Once you upload a new patch, then we should see what changed in those classes, maybe you dropped some changes by keeping old moved files.
Comment #61
njbarrett CreditAttribution: njbarrett commentedThanks for your help Berdir, I checked my .gitconfig and it conforms to all of those rules. (I am using Aquia dev desktop).
Comment #70
Gábor HojtsyIs this still something to be done? If so, we should slot this under #3118154: [meta] Deprecate dependencies, libraries, modules, and themes that will be removed from Drupal 10 core by 9.4.0-beta1 at least for modules to be deprecated / removed.
Comment #71
andypost