Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
field system
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
2 Aug 2025 at 01:20 UTC
Updated:
25 Oct 2025 at 14:44 UTC
Jump to comment: Most recent
Now that we no longer create body fields for new content types or block_content types. And in the process of moving their storage.body fields out lets update the createBodyField to not create text_with_summary fields but instead text_long field storage types.
NA
Update the createBodyField() function to create text_long storage types.
Implement
Fix tests
Review
NA
NA
NA
NA
When creating new content types or block_content types in tests the body field will now be text_long fields vs text_with_summary.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
smustgrave commentedComment #4
smustgrave commentedProbably postponed on a few steps.
Comment #5
nicxvan commentedComment #6
smustgrave commentedThis was smaller then I thought so may be good to go now
Comment #7
berdirI find it suspicious that \Drupal\Tests\node\Kernel\NodeTokenReplaceTest::testNodeTokenReplacement doesn't need a change. That probably works because it never reloads the node, so the summary is set as an undefined property and the token works.
Comment #8
smustgrave commentedWith regards to TextWithSummaryCreationTrait I did make that before I started fixing tests but shouldn't we offer a replacement for those who may have been relying on createBodyField to make a text_with_summary?
Comment #9
berdir> those who may have been relying on createBodyField to make a text_with_summary?
createBodyField was introduced in #3489266: Deprecate node_add_body_field(), as a replacement for node_add_body_field(), that's a non-issue, but you can of course ask the same question about node_add_body_field(). But that's not really a problem IMHO. There are going to be very, very few cases that specifically want a summary field. We'd need to deprecate and move this trait again to text_with_summary module, and then those contrib module would need to depend on that.
In all my contribs in my project, I see 7 calls or so to node_add_body_field(), I doubt any of them care about the summary. In contrast to that, there are 200+ calls to FieldStorageConfig::create() where tests set up their own fields explicitly. Which I think is where we want to go.
Same with core really, I don't even see any calls to createBodyField() except the one in createContentType(). Maybe there were and we refactored them away in that issue and shouldn't have introduced that trait and method at all? Core has 400+ FieldStorageConfig::create() calls where it sets up specific fields with specific configuration. We keep the concept of a "body" field being a default thing of a node type in tests while removing this on actual sites, that should IMHO be an intermediate step just to deal with the amount of tests relying on it for one reason or another.
Instead, what I think we should do is introduce an API version of \Drupal\Tests\field_ui\Traits\FieldUiTestTrait::fieldUIAddNewField(). That uses the UI, but most cases don't actually want to test the UI with this, they just want a field with a given name, type and configuration for their entity type.
Comment #10
smustgrave commentedFair enough, I pushed the changes up but this will actually be postponed on #3447617: Stop automatic storage creation of body field for node, added the code that will have to be un-commented out once that lands
Comment #11
smustgrave commentedOkay now the problem is summary missing is breaking token tests..
Comment #12
smustgrave commentedOkay to get around the tests problem. I copied the 2 tests that actually were testing summary and made new test files in the text module and removed the summary part from the existing tests. So when we make the deprecated module text_with_summary we can just copy these test files to it and when it lands in contrib I'll decide what to do with them then. But this way we aren't losing any coverage.
Comment #13
ironnuts commentedRe: #12
Just trying to get my head around the strategies described in this issue. Are you talking about creating a module named 'text_with_summary'? I suppose you mean deprecating the field type 'text_with_summary'?
Comment #14
mstrelan commentedAdded my thoughts to the MR. Setting NW because I think the copied tests should be trimmed down in this issue.
#13 - please see the parent issue / meta, the approach can be discussed there. TL;DR a new text_with_summary module is created for the text_with_summary field type, the module is then moved to contrib and deprecated in core. Then we remove it from core in the next major. This allows sites that rely on this field type to keep using it if they want to.
Comment #15
smustgrave commentedThanks! Going to keep assigned to myself and work on soon
Comment #16
ironnuts commented@mstrelan Thank you! Appreciated.
Comment #17
smustgrave commentedAddressed the feedback thanks @mstrelan!
Comment #19
smustgrave commentedComment #20
nicxvan commentedI think this is ready, I had some concerns about the file usage test and token changes, but the current test results were replicated to the new tests and align with the discussions here and in slack.
I wonder about the utility of the file usage test as it stands now, but I can see why resolving that would be out of scope here and the current test will prevent any regressions beyond. We probably need a follow up to untangle the file usage and token tests once this is all settled. I'll ask for them to be created.
Edited to add, I'm not sure this warrants a CR on it's own, but maybe a note on one related to these changes?
Comment #21
berdirAdding some thoughts, I think we should keep the new tests in the module that they're testing the code for.
Comment #22
smustgrave commentedHow come? The next step is going to be to move them to the deprecated text summary module
Comment #23
berdirSee comments. both of those test code in those modules, not in text module. the job isn't done by moving the tests, we need to deal with the actual logic of the summary token and the ->summary property in editor module.
Comment #24
smustgrave commentedI can move back but seems like a waste since all that logic is going to have and get moved too
Comment #25
smustgrave commentedMoved the test files
Comment #26
smustgrave commentedNow more tests are failing.
Comment #27
smustgrave commentedWas just 1 test really but rest test so failed a few spots.
Comment #28
berdirLeft one more note.
Comment #29
smustgrave commentedComment #30
berdirThanks for sticking with me for those nitpicks. My specific feedback has been addressed, so I'm putting this back to RTBC.
I still have some vague concerns around this and the whole change, not nothing specific to hold this up. This will break some tests, but there isn't really a way around that on our path toward stop using text_with_summary in core.
Comment #33
catchYeah it's been a bit like this with every issue, had no idea text_with_summary was so deeply embedded everywhere in core until we properly tried to remove it.
MR looks good to me - agree some of those tests will eventually have to move to the text_with_summary module but that can happen later on.
Committed/pushed to 11.x, thanks!
Comment #35
smustgrave commentedThanks everyone! Wait till you see the changes needed in the next one to remove from the standard profile lol